Beispiel #1
0
 def _rtd_switch(switch, fq_gpio):
     # name = "fq1_ctrl"
     rtd_gpio = Constant.fq1_ctrl
     if fq_gpio == Constant.get_val(Constant.fq2_ctrl_r):
         # name = "fq2_ctrl"
         rtd_gpio = Constant.fq2_ctrl
     if switch:
         # print("%s 打开" % name)
         PCM(rtd_gpio).pin_on()
     else:
         # print("%s 关闭" % name)
         PCM(rtd_gpio).pin_off()
Beispiel #2
0
    def send_fq2(self):
        fq2_dict = dict(self._fqm_rul)["fq2"]
        fq2_gpio = Constant.get_val(Constant.fq2_ctrl_r)
        fq2_switch = fq2_dict['switch']
        fq2_rate = fq2_dict['rate']
        fq2_rtd = fq2_dict['rtd']

        if fq2_switch:
            # 设置频率信号电阻
            self._rtd_switch(fq2_rtd, fq2_gpio)
            p = GPIO.PWM(fq2_gpio, fq2_rate)
            p.start(50)
            print("fq2 gpio=%s rate=%s" % (fq2_gpio, fq2_rate))

        while True:
            if not Common.pwm_is_run:
                break
Beispiel #3
0
 def __init__(self, gpio=None):
     self.gpio = Constant.get_val(gpio)
Beispiel #4
0
import spidev
import can
import json
import binascii
import uds_server
from convert import Convert
from config import Constant, Common, RuleConfig
from validate import Validate, ValidateDataOp
import RPi.GPIO as GPIO
import threading
import struct
import mysql_service

GPIO.setmode(GPIO.BCM)  # 使用BCM引还脚编号,此外有 GPIO.BOARD
GPIO.setwarnings(False)
GPIO.setup(Constant.get_val(Constant.vb), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.vb1), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.vb2), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.amp_5), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.amp_12), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.amp_19), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.fq1_ctrl), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.fq1_ctrl_r), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.fq2_ctrl), GPIO.OUT)
GPIO.setup(Constant.get_val(Constant.fq2_ctrl_r), GPIO.OUT)
GPIO.setup(19, GPIO.OUT)


# 日志
class Log:
    def __init__(self, serial_code=""):