40 lines
1.3 KiB
Python
40 lines
1.3 KiB
Python
|
|
# main.py
|
|||
|
|
import time
|
|||
|
|
from hardware.relay import RelayController
|
|||
|
|
from hardware.transmitter import TransmitterController
|
|||
|
|
from service.mould_service import app_web_service
|
|||
|
|
import time
|
|||
|
|
# from LED_send.led_send import send_led_data
|
|||
|
|
|
|||
|
|
|
|||
|
|
def main():
|
|||
|
|
|
|||
|
|
relay_c = RelayController()
|
|||
|
|
transmitter_c = TransmitterController(relay_c)
|
|||
|
|
while True:
|
|||
|
|
led_info = app_web_service.get_pouring_led()
|
|||
|
|
upper_weight=transmitter_c.read_data(1)
|
|||
|
|
lower_weight=transmitter_c.read_data(2)
|
|||
|
|
if led_info:
|
|||
|
|
# 提取RingTypeCode,从第3个字符开始到"-"之前的部分
|
|||
|
|
if "-" in led_info.MouldCode:
|
|||
|
|
# 找到"-"的位置
|
|||
|
|
dash_index = led_info.MouldCode.index("-")
|
|||
|
|
# 从索引2开始提取到"-"之前的部分
|
|||
|
|
led_info.RingTypeCode = led_info.MouldCode[2:dash_index]
|
|||
|
|
if led_info.MouldCode.find("F")>=0:
|
|||
|
|
led_info.VibrationFrequency="4min/"+ led_info.VibrationFrequency
|
|||
|
|
else:
|
|||
|
|
led_info.VibrationFrequency="5min/"+ led_info.VibrationFrequency
|
|||
|
|
|
|||
|
|
|
|||
|
|
led_info.UpperWeight=upper_weight
|
|||
|
|
led_info.LowerWeight=lower_weight
|
|||
|
|
# led_info.VibrationFrequency="5min/220hz"
|
|||
|
|
send_led_data(led_info)
|
|||
|
|
time.sleep(1)
|
|||
|
|
|
|||
|
|
|
|||
|
|
if __name__ == "__main__":
|
|||
|
|
main()
|