second leak test tbt
This commit is contained in:
parent
c2cf424e95
commit
938f0dd8dd
@ -36,6 +36,7 @@ class USB_586x(Component):
|
||||
def __init__(self, config=None, name=None, period=1, lazy=True, paused=False, threaded=True):
|
||||
super().__init__(config=config, name=name, period=period, lazy=lazy, paused=paused, threaded=threaded)
|
||||
self.mutex = QMutex()
|
||||
|
||||
# DEVICE INFORMATION
|
||||
self.id=config["digital_io"]["id"]
|
||||
if "5860" in self.id:
|
||||
@ -52,6 +53,19 @@ class USB_586x(Component):
|
||||
# self.info.DeviceNumber = -1
|
||||
self.info.DeviceMode = 1
|
||||
self.info.ModuleIndex = 0
|
||||
|
||||
self.open_device()
|
||||
|
||||
# SET ALL RELAYS OFF
|
||||
for bit in range(0, self.out_size*8):
|
||||
self.set_bit(int(bit/8), bit%8, False)
|
||||
|
||||
self.state_delay = 1
|
||||
self.last_get = None
|
||||
self.state_count = None
|
||||
self.last_out = None
|
||||
|
||||
def open_device(self):
|
||||
# DIGITAL INPUTS CLASS
|
||||
if is_win:
|
||||
self.di_ctrl = InstantDiCtrl(self.info.Description)
|
||||
@ -90,15 +104,8 @@ class USB_586x(Component):
|
||||
self.do_ctrl = self.do_create()
|
||||
self.di_init_status = self.di_setSelectedDevice(self.di_ctrl, ctypes.byref(self.info))
|
||||
self.do_init_status = self.do_setSelectedDevice(self.do_ctrl, ctypes.byref(self.info))
|
||||
|
||||
# SET ALL RELAYS OFF
|
||||
for bit in range(0, self.out_size*8):
|
||||
self.set_bit(int(bit/8), bit%8, False)
|
||||
|
||||
self.state_delay = 1
|
||||
self.last_get = None
|
||||
self.state_count = None
|
||||
self.last_out = None
|
||||
def close_device(self):
|
||||
pass
|
||||
|
||||
@pyqtSlot()
|
||||
def start(self):
|
||||
@ -177,6 +184,23 @@ class USB_586x(Component):
|
||||
else:
|
||||
ret=self.do_write_bit(self.do_ctrl, byte, bit, int(val))
|
||||
self.mutex.unlock()
|
||||
return ret
|
||||
|
||||
def set_bit_verify(self, byte, bit, val):
|
||||
|
||||
ok = False
|
||||
retry=0
|
||||
max_retry = 3
|
||||
while not ok and retry <max_retry:
|
||||
ret = self.components["digital_io"].set_bit(byte, bit, val)
|
||||
if ret != ErrorCode.Success:
|
||||
self.log.error(f"SET BIT ERROR")
|
||||
self.open_device()
|
||||
retry+=1
|
||||
else:
|
||||
ok = True
|
||||
|
||||
return ok
|
||||
|
||||
# val from buffer channel
|
||||
def vfbc(self, buffer, channel):
|
||||
|
||||
@ -2,8 +2,10 @@ import sys
|
||||
import time
|
||||
import weakref
|
||||
|
||||
from ui.test_test import Test_Test
|
||||
from PyQt5.QtWidgets import QMessageBox
|
||||
|
||||
from ui.test_test import Test_Test
|
||||
from src.components.Automation.BDaq import ErrorCode
|
||||
|
||||
class Test_Leak(Test_Test):
|
||||
def __init__(self, components=None, recipe=None, step=None, pieces=None, run_once=False, reset_on_start=True, enable_override=True):
|
||||
@ -35,15 +37,18 @@ class Test_Leak(Test_Test):
|
||||
if "relay_config" in step.spec.keys():
|
||||
relay_config = step.spec["relay_config"]
|
||||
if relay_config == 1:
|
||||
self.components["digital_io"].set_bit(0, 0, 1)
|
||||
ret=self.components["digital_io"].set_bit_verify(0, 0, 1)
|
||||
else:
|
||||
self.components["digital_io"].set_bit(0, 0, 0)
|
||||
ret=self.components["digital_io"].set_bit_verify(0, 0, 0)
|
||||
|
||||
if ret:
|
||||
time.sleep(1)
|
||||
# AUTO START SECOND TEST
|
||||
if relay_config == 1:
|
||||
self.start_b.setEnabled(True)
|
||||
self.start_b.click()
|
||||
|
||||
else:
|
||||
QMessageBox.critical(None, "Errore", f"Errore di pilotaggio elettrovalvole")
|
||||
return show
|
||||
|
||||
def stop(self):
|
||||
|
||||
Loading…
Reference in New Issue
Block a user