def checkHold(self): ''' This is a helper function that keeps the loop held in same temp. It recreates the expected values with updated times at the end TODO: NOTE: if a hold is held less than updateTime it might not recalculate or even get in here ''' try: if ProfileInstance.getInstance().inHold: startHoldTime = int(time.time()) Logging.logEvent( "Event", "Hold Start", { "message": "In hold for first time", "ProfileInstance": ProfileInstance.getInstance() }) while ProfileInstance.getInstance().inHold: for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: zone = self.zones[zone] # self.temp_temperature = zone.updateDutyCycle() time.sleep(.5) endHoldTime = int(time.time()) holdTime = endHoldTime - startHoldTime self.startTime = self.startTime + holdTime Logging.logEvent( "Event", "HoldEnd", { "message": "Just Left hold", "ProfileInstance": ProfileInstance.getInstance() }) Logging.logEvent( "Debug", "Status Update", { "message": "Leaving hold after {} seconds in hold, new startTime {}" .format(holdTime, self.startTime), "ProfileInstance": ProfileInstance.getInstance(), "level": 2 }) # regenerate expected time, moving things forward to account for hold for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: self.zones[ zone].expected_temp_values, self.expected_time_values = self.zones[ zone].createExpectedValues( self.zones[zone].zoneProfile. thermalProfiles, startTime=self.startTime) except Exception as e: Logging.debugPrint( 1, "DCCS: Error in check Hold, Duty Cycle: {}".format(str(e))) if Logging.debug: raise e
def __init__(self, parent=None): Logging.logEvent("Debug", "Status Update", { "message": "Creating DutyCycleControlStub", "level": 2 }) self.zoneProfiles = ProfileInstance.getInstance().zoneProfiles self.parent = parent Thread.__init__(self) self.updatePeriod = ProfileInstance.getInstance( ).zoneProfiles.updatePeriod self.d_out = HardwareStatusInstance.getInstance().PC_104.digital_out self.zones = { "zone1": ZoneControlStub(name='zone1', lamps=['IR Lamp 1', 'IR Lamp 2'], parent=self), "zone2": ZoneControlStub(name='zone2', lamps=['IR Lamp 3', 'IR Lamp 4'], parent=self), "zone3": ZoneControlStub(name='zone3', lamps=['IR Lamp 6', 'IR Lamp 5'], parent=self), "zone4": ZoneControlStub(name='zone4', lamps=['IR Lamp 7', 'IR Lamp 8'], parent=self), "zone5": ZoneControlStub(name='zone5', lamps=['IR Lamp 9', 'IR Lamp 10'], parent=self), "zone6": ZoneControlStub(name='zone6', lamps=['IR Lamp 12', 'IR Lamp 11'], parent=self), "zone7": ZoneControlStub(name='zone7', lamps=['IR Lamp 13', 'IR Lamp 14'], parent=self), "zone8": ZoneControlStub(name='zone8', lamps=['IR Lamp 15', 'IR Lamp 16'], parent=self), # zone9 is the platen "zone9": ZoneControlStub(name='zone9', parent=self) } self.currentSetpoint = 1 self.ramp = False self.soak = False
def checkPause(self): ''' This is a helper function that pauses the loop ''' try: if ProfileInstance.getInstance().inPause: startPauseTime = int(time.time()) Logging.logEvent("Event", "Pause Start", { "message": "In Pause for first time", "level": 3 }) while ProfileInstance.getInstance().inPause: for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: zone = self.zones[zone] self.d_out.update({zone.lamps[1] + " PWM DC": 0}) self.d_out.update({zone.lamps[0] + " PWM DC": 0}) zone.pid.error_value = 0 zone.dutyCycle = 0 time.sleep(.5) endPauseTime = int(time.time()) pauseTime = endPauseTime - startPauseTime self.startTime = self.startTime + pauseTime Logging.logEvent("Event", "pauseEnd", { "message": "Just Left pause", "level": 3 }) Logging.logEvent( "Debug", "Status Update", { "message": "Leaving pause after {} seconds in pause, new startTime {}" .format(pauseTime, self.startTime), "level": 3 }) # regenerate expected time, moving things forward to account for pause for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: self.zones[ zone].expected_temp_values, self.expected_time_values = self.zones[ zone].createExpectedValues( self.zones[zone].zoneProfile. thermalProfiles, startTime=self.startTime) except Exception as e: Logging.debugPrint( 1, "Error in check Pause, Duty Cycle Control Stub: {}".format( str(e))) if Logging.debug: raise e
def __init__(self): # self.zoneThreadDict = self.createZoneCollection() self.dutyCycleThread = DutyCycleControlStub(parent=self) self.hardwareInterfaceThreadDict = self.createHardwareInterfaces( parent=self) self.safetyThread = SafetyCheck(parent=self) self.zoneProfiles = ProfileInstance.getInstance().zoneProfiles self.runThreads() # if there is a half finished profile in the database result = self.returnActiveProfile() Logging.debugPrint(3, "Active Profile?: {}".format(result)) if result: Logging.debugPrint( 1, "Unfinished profile found: {}".format( str(result['profile_name']))) # load up ram (zone collection) with info from the database and the given start time self.zoneProfiles.load_profile(result['profile_name'], result['profile_Start_Time'], result['thermal_Start_Time'], result['first_Soak_Start_Time']) # after it's in memory, run it! self.runProfile(firstStart=False)
def __init__(self, name, lamps=None, parent=None): Logging.logEvent("Debug", "Status Update", { "message": "Creating ZoneControlStub: {}".format(name), "level": 3 }) self.zoneProfile = ProfileInstance.getInstance().zoneProfiles.getZone( name) self.lamps = lamps self.name = name self.parent = parent self.temp_temperature = None self.pid = PID() if lamps: # These are the PID settings for the lamps proportional_gain = .2 integral_gain = 0 derivative_gain = 0 else: # These are the PID settings for the heaters in the platen proportional_gain = .4 integral_gain = 0 derivative_gain = 0 self.pid.setKp(proportional_gain) self.pid.setKi(integral_gain) self.pid.setKd(derivative_gain)
def __init__(self, group=None, target=None, name=None, args=(), kwargs=None, verbose=None): Logging.logEvent("Debug", "Status Update", { "message": "Creating VacuumControlStub:", "level": 3 }) Thread.__init__(self, group=group, target=target, name=name) self.args = args self.kwargs = kwargs self.zoneProfiles = ProfileInstance.getInstance().zoneProfiles self.profile = ProfileInstance.getInstance() self.hw = HardwareStatusInstance.getInstance() self.state = None self.pres_opVac = 9e-5 self.pres_atm = 100 self.pres_cryoP_Prime = 40e-3 self.pres_chamber_crossover = 25e-3 self.pres_chamber_max_crossover = 40e-3 self.pres_min_roughing = 9e-4 self.pres_ruffon = 70 self.cryoPumpPressure = None self.chamberPressure = None self.roughPumpPressure = None self.updatePeriod = 1 # # FOR TESTING ################################ # self.state = "Operational Vacuum" # self.hw.OperationalVacuum = True # # FOR TESTING ################################ if os.name == "posix": userName = os.environ['LOGNAME'] else: userName = "******"
def __init__(self, parent=None, group=None, target=None, name=None, args=(), kwargs=None, verbose=None): Thread.__init__(self, group=group, target=target, name=name) self.args = args self.kwargs = kwargs self.parent = parent self.pwr_supply = Tdk_lambda_Genesys() self.zoneProfiles = ProfileInstance.getInstance().zoneProfiles self.hw = HardwareStatusInstance.getInstance() self.ps_read_peroid = 4.0 # 0.5s loop period
def releaseHoldThread(): ProfileInstance.getInstance().inHold = False sql = "UPDATE System_Status SET in_hold=0;" mysql = MySQlConnect() try: mysql.cur.execute(sql) mysql.conn.commit() except Exception as e: Logging.debugPrint(3, "sql: {}".format(sql)) Logging.debugPrint( 1, "Error in ThreadCollection, holdThread: {}".format(str(e))) if Logging.debug: raise e
def holdThread(self, data=None): Logging.debugPrint(3, "Holding Zones") ProfileInstance.getInstance().inHold = True sql = "UPDATE System_Status SET in_hold=1;" mysql = MySQlConnect() try: mysql.cur.execute(sql) mysql.conn.commit() except Exception as e: Logging.debugPrint(3, "sql: {}".format(sql)) Logging.debugPrint( 1, "Error in ThreadCollection, holdThread: {}".format(str(e))) if Logging.debug: raise e
def updateDutyCycle(self): ''' Given that temp_temperature is assigned to a value, this will update the duty cycle for the lamps ''' self.pid.SetPoint = self.temp_temperature # TODO: Don't leave this hardcoded self.pid.update(self.zoneProfile.getTemp(self.zoneProfile.average)) self.dutyCycle = self.pid.error_value / self.maxTempRisePerUpdate # TODO: pick what lamp you want to use if self.lamps: self.parent.d_out.update( {self.lamps[1] + " PWM DC": self.dutyCycle}) self.parent.d_out.update( {self.lamps[0] + " PWM DC": self.dutyCycle}) else: # for zone 9, the platen HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Platen Duty Cycle', self.dutyCycle]) Logging.debugPrint( 2, "{}: avg ({})\goal({}) -- {}".format( self.name, self.zoneProfile.getTemp(self.zoneProfile.average), self.temp_temperature, self.dutyCycle)) # Logging.logEvent("Debug","Status Update", # {"message": "{}: Current temp: {}".format(self.name,self.zoneProfile.getTemp(self.zoneProfile.average)), # "level":2}) # Logging.logEvent("Debug","Status Update", # {"message": "{}: Temp Goal temperature is {}".format(self.name,self.temp_temperature), # "level":2}) # Logging.logEvent("Debug","Status Update", # {"message": "{}: Current duty Cycle: {}".format(self.name,self.dutyCycle), # "level":2}) Logging.logExpectedTemperatureData({ "expected_temp_values": [self.temp_temperature], "expected_time_values": [time.time()], "zone": self.name, "profileUUID": self.zoneProfile.profileUUID, "ProfileInstance": ProfileInstance.getInstance() })
def __init__(self, parent=None, group=None, target=None, name=None, args=(), kwargs=None, verbose=None): Thread.__init__(self, group=group, target=target, name=name) self.args = args self.kwargs = kwargs self.parent = parent self.zoneProfiles = ProfileInstance.getInstance().zoneProfiles self.Pgauge = PfeifferGauge() self.hw = HardwareStatusInstance.getInstance() self.gauges = self.hw.PfeifferGuages self.pressure_read_peroid = 0.5 # 0.5s loop period self.param_period = 5 # 5 second period
def heatUpPlaten(self, data): dutyCycle = float(data['dutyCycle']) tdKs = HardwareStatusInstance.getInstance().TdkLambda_PS if not ProfileInstance.getInstance().activeProfile: if dutyCycle == 0: if tdKs.get_platen_left( ).output_enable or tdKs.get_platen_right().output_enable: HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Disable Platen Output']) return "{'result':'Disabled Platen'}" else: return "{'result':'Platen Off'}" else: if not (tdKs.get_platen_left().output_enable and tdKs.get_platen_right().output_enable): HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Setup Platen']) HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Platen Duty Cycle', dutyCycle]) return "{'result':'Platen duty cycle set'}" else: return "{'result':'Not used in Profile'}"
def runProfile(self, firstStart=True): ''' This assumes a profile is already loaded in RAM, it will start the profile Also making an entry in the DB ''' # Check to make sure there is an active profile in memory if not self.zoneProfiles.profileName: return "{'Error':'No Profile loaded in memory'}" if firstStart: result = self.addProfileInstancetoBD() # If there is an error connecting to the DB, return it if result != True: return result # starts all the HWcontrol threads try: for thread in self.zoneThreadDict: if self.zoneThreadDict[thread].zoneProfile.zone > 0: self.zoneThreadDict[thread].running = True self.zoneThreadDict[thread].daemon = True self.zoneThreadDict[thread].start() Logging.logEvent( "Debug", "Status Update", { "message": "Zone {} is handled, about the start".format( self.zoneThreadDict[thread].zoneProfile.zone), "level": 1 }) except Exception as e: pass ProfileInstance.getInstance().activeProfile = True Logging.debugPrint(2, "Setting Active Profile to True") return "{'result':'success'}"
def heatUpShroud(self, data): dutyCycle = float(data['dutyCycle']) tdKs = HardwareStatusInstance.getInstance().TdkLambda_PS if not ProfileInstance.getInstance().activeProfile: if dutyCycle == 0: if tdKs.get_shroud_left( ).output_enable or tdKs.get_shroud_right().output_enable: HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Disable Shroud Output']) return "{'result':'Disabled Shroud'}" else: return "{'result':'Shroud Off'}" else: if not (tdKs.get_shroud_left().output_enable and tdKs.get_shroud_right().output_enable): HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Setup Shroud']) print("Turning on Shroud") HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Shroud Duty Cycle', dutyCycle]) return "{'result':'Shroud duty cycle set'}" else: return "{'result':'Not used in Profile'}"
def run(self): # This should always stay on while True: # initialization of the safety Thread try: # Temps are in Kelvin MAX_OPERATING_TEMP = 437 # safe at all lower bounds # MIN_OPERATING_TEMP MAX_TOUCH_TEMP = 318.15 MIN_TOUCH_TEMP = 269.15 # TODO, make this user defined # These are test values, they will change when the code is written to change them self.MAX_UUT_TEMP = {} self.MIN_UUT_TEMP = {} SLEEP_TIME = 1 # in seconds # Used to keep track of the first time through a loop vacuum = False hardwareStatusInstance = HardwareStatusInstance.getInstance() Logging.logEvent("Debug", "Status Update", { "message": "Starting Safety Checker Thread", "level": 3 }) # stop when the program ends while True: Logging.logEvent("Debug", "Status Update", { "message": "Running Safety Checker Thread", "level": 4 }) tempErrorDict = { "System Alarm: High Temperature": False, "Product Saver Alarm: High Temperature": False, "Product Saver Alarm: Low Temperature": False, "Human Touch Alarm: High Temperature": False, "Human Touch Alarm: Low Temperature": False, "Pressure Loss In Profile": False, } TCs = hardwareStatusInstance.Thermocouples.ValidTCs for tc in TCs: # if there are any TC's higher than max temp if tc.temp > MAX_OPERATING_TEMP: # print("{}-> {}".format(tc.Thermocouple, tc.temp)) errorDetail = "TC # {} is above MAX_OPERATING_TEMP ({}). Currently {}c".format( tc.Thermocouple, MAX_OPERATING_TEMP, tc.temp) error = { "time": str(datetime.now()), "event": "System Alarm: High Temperature", "item": "Thermocouple", "itemID": tc.Thermocouple, "details": errorDetail, "actions": ["Turned off heater", "Log Event"] } self.logEvent(error) tempErrorDict[error['event']] = True d_out = HardwareStatusInstance.getInstance( ).PC_104.digital_out ProfileInstance.getInstance().activeProfile = False Logging.debugPrint( 1, "ERROR Heat was above max operating temperature ({})" .format(tc.temp)) vacuum = False d_out.update({"IR Lamp 1 PWM DC": 0}) d_out.update({"IR Lamp 2 PWM DC": 0}) d_out.update({"IR Lamp 3 PWM DC": 0}) d_out.update({"IR Lamp 4 PWM DC": 0}) d_out.update({"IR Lamp 5 PWM DC": 0}) d_out.update({"IR Lamp 6 PWM DC": 0}) d_out.update({"IR Lamp 7 PWM DC": 0}) d_out.update({"IR Lamp 8 PWM DC": 0}) d_out.update({"IR Lamp 9 PWM DC": 0}) d_out.update({"IR Lamp 10 PWM DC": 0}) d_out.update({"IR Lamp 11 PWM DC": 0}) d_out.update({"IR Lamp 12 PWM DC": 0}) d_out.update({"IR Lamp 13 PWM DC": 0}) d_out.update({"IR Lamp 14 PWM DC": 0}) d_out.update({"IR Lamp 15 PWM DC": 0}) d_out.update({"IR Lamp 16 PWM DC": 0}) HardwareStatusInstance.getInstance( ).TdkLambda_Cmds.append(['Shroud Duty Cycle', 0]) HardwareStatusInstance.getInstance( ).TdkLambda_Cmds.append(['Platen Duty Cycle', 0]) releaseHoldThread() # end of max operational test if tc.userDefined: # print("tc: {} zone: {}".format(tc.Thermocouple,tc.zone)) if tc.zone != 0: if tc.temp > ProfileInstance.getInstance( ).zoneProfiles.getZone(tc.zone).maxHeatError: errorDetail = "TC # {} is above MAX_UUT_TEMP ({}). Currently {}c".format( tc.Thermocouple, ProfileInstance.getInstance(). zoneProfiles.getZone( tc.zone).maxHeatError, tc.temp) error = { "time": str(datetime.now()), "event": "Product Saver Alarm: High Temperature", "item": "Thermocouple", "itemID": tc.Thermocouple, "details": errorDetail, "actions": ["Turned off heater", "Log Event"] } self.logEvent(error) tempErrorDict[error['event']] = True # end of max user test if tc.temp < ProfileInstance.getInstance( ).zoneProfiles.getZone(tc.zone).minHeatError: errorDetail = "TC # {} is below MIN_UUT_TEMP ({}). Currently {}c".format( tc.Thermocouple, ProfileInstance.getInstance(). zoneProfiles.getZone( tc.zone).minHeatError, tc.temp) error = { "time": str(datetime.now()), "event": "Product Saver Alarm: Low Temperature", "item": "Thermocouple", "itemID": tc.Thermocouple, "details": errorDetail, "actions": ["Turned off LN flow", "Log Event"] } self.logEvent(error) tempErrorDict[error['event']] = True # end of min user test # end of user test # Get the full list OutsideThermoCouples = [] if tc.Thermocouple in OutsideThermoCouples: if tc.temp > MAX_TOUCH_TEMP: errorDetail = "TC # {} is above MAX_TOUCH_TEMP ({}). Currently {}c".format( tc.Thermocouple, MAX_TOUCH_TEMP, tc.temp) error = { "time": str(datetime.now()), "event": "Human Touch Alarm: High Temperature", "item": "Thermocouple", "itemID": tc.Thermocouple, "details": errorDetail, "actions": ["Log Event"] } self.logEvent(error) tempErrorDict[error['event']] = True # end of max touch test if tc.temp < MIN_TOUCH_TEMP: errorDetail = "TC # {} is below MIN_TOUCH_TEMP ({}). Currently {}c".format( tc.Thermocouple, MIN_TOUCH_TEMP, tc.temp) error = { "time": str(datetime.now()), "event": "Human Touch Alarm: Low Temperature", "item": "Thermocouple", "itemID": tc.Thermocouple, "details": errorDetail, "actions": ["Log Event"] } self.logEvent(error) tempErrorDict[error['event']] = True # end of min touch test # if of outside thermaltest # End of TC for loop for errorType in self.errorDict: # for every type of error if self.errorDict[ errorType] and not tempErrorDict[errorType]: # It was true and now is not, log it. # make a event log errorLog = { "time": str(datetime.now()), "event": errorType, "item": "Thermocouple", "itemID": tc.Thermocouple, "details": "The current event has ended", "actions": ["Log Event"] } self.logEvent(errorLog) self.errorDict = tempErrorDict # Logging if you've entered operational vacuum, and then left it # TODO: OperationalVacuum can't be updated if there isn't an active profile...this needs to change if HardwareStatusInstance.getInstance().OperationalVacuum: vacuum = True if os.name == "posix": userName = os.environ['LOGNAME'] else: userName = "******" if "root" in userName: if vacuum and HardwareStatusInstance.getInstance( ).PfeifferGuages.get_chamber_pressure() > 1e-4: d_out = HardwareStatusInstance.getInstance( ).PC_104.digital_out ProfileInstance.getInstance().activeProfile = False Logging.debugPrint( 1, "ERROR Pressure is above 10^-4. ({})".format( HardwareStatusInstance.getInstance( ).PfeifferGuages.get_chamber_pressure())) vacuum = False # TODO: Send Error d_out.update({"IR Lamp 1 PWM DC": 0}) d_out.update({"IR Lamp 2 PWM DC": 0}) d_out.update({"IR Lamp 3 PWM DC": 0}) d_out.update({"IR Lamp 4 PWM DC": 0}) d_out.update({"IR Lamp 5 PWM DC": 0}) d_out.update({"IR Lamp 6 PWM DC": 0}) d_out.update({"IR Lamp 7 PWM DC": 0}) d_out.update({"IR Lamp 8 PWM DC": 0}) d_out.update({"IR Lamp 9 PWM DC": 0}) d_out.update({"IR Lamp 10 PWM DC": 0}) d_out.update({"IR Lamp 11 PWM DC": 0}) d_out.update({"IR Lamp 12 PWM DC": 0}) d_out.update({"IR Lamp 13 PWM DC": 0}) d_out.update({"IR Lamp 14 PWM DC": 0}) d_out.update({"IR Lamp 15 PWM DC": 0}) d_out.update({"IR Lamp 16 PWM DC": 0}) HardwareStatusInstance.getInstance( ).TdkLambda_Cmds.append(['Shroud Duty Cycle', 0]) HardwareStatusInstance.getInstance( ).TdkLambda_Cmds.append(['Platen Duty Cycle', 0]) releaseHoldThread() # end if vacuum in bad condintion # end if root time.sleep(SLEEP_TIME) # end of inner while true loop except Exception as e: Logging.debugPrint( 1, "Error in Safety Checker: {}".format(str(e))) if Logging.debug: raise e time.sleep(SLEEP_TIME)
def run(self): ''' ''' # used for testing first = True while True: # While true to restart the thread if it errors out try: # Thread "Start up" stuff goes here Logging.logEvent( "Debug", "Status Update", { "message": "Starting Pfeiffer Guage Updater Thread", "level": 2 }) if os.name == "posix": userName = os.environ['LOGNAME'] else: userName = "******" # userName = '******' if "root" in userName: self.read_all_params() next_pressure_read_time = time.time() next_param_read_time = time.time() while True: next_pressure_read_time += self.pressure_read_peroid if "root" in userName: try: self.gauges.update([{ 'addr': 1, 'Pressure': self.Pgauge.GetPressure(1) }, { 'addr': 2, 'Pressure': self.Pgauge.GetPressure(2) }, { 'addr': 3, 'Pressure': self.Pgauge.GetPressure(3) }]) Logging.logEvent( "Debug", "Status Update", { "message": "Reading and writing with PfeifferGaugeUpdater.\n" "Cryopump: {:f}; Chamber: {:f}; RoughPump: {:f}\n" "".format( self.gauges.get_cryopump_pressure(), self.gauges.get_chamber_pressure(), self.gauges.get_roughpump_pressure()), "level": 4 }) if time.time() > next_param_read_time: self.gauges.update([{ 'addr': 1, 'error': self.Pgauge.GetError(1), 'cc on': self.Pgauge.GetCCstate(1) }, { 'addr': 2, 'error': self.Pgauge.GetError(2), 'cc on': self.Pgauge.GetCCstate(2) }, { 'addr': 3, 'error': self.Pgauge.GetError(3) }]) if __name__ != '__main__': if ProfileInstance.getInstance( ).recordData: self.logPressureData() next_param_read_time += self.param_period except ValueError as err: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split( exc_tb.tb_frame.f_code.co_filename)[1] Logging.logEvent( "Error", 'Error in PfeifferGaugeUpdater reading values: "%s"' % err, { "type": exc_type, "filename": fname, "line": exc_tb.tb_lineno, "thread": "PfeifferGaugeUpdater" }) else: Logging.logEvent( "Debug", "Status Update", { "message": "Test run of Pfeiffer Guages loop", "level": 4 }) if first: # TODO: Test the system at differnt starting pressures, it could restart at any point # What happens when pressure in roughing is more than cryo? self.gauges.update([{ 'addr': 1, 'Pressure': 1000 }, { 'addr': 2, 'Pressure': 0.001 }, { 'addr': 3, 'Pressure': 999 }]) first = False goingUp = False else: if True or self.gauges.get_chamber_pressure( ) > 0.0000001 and not goingUp: self.gauges.update([{ 'addr': 1, 'Pressure': self.gauges.get_cryopump_pressure() / 2.5 }, { 'addr': 2, 'Pressure': self.gauges.get_chamber_pressure() / 5 }, { 'addr': 3, 'Pressure': self.gauges.get_roughpump_pressure() / 3 }]) else: goingUp = True self.gauges.update([{ 'addr': 1, 'Pressure': self.gauges.get_cryopump_pressure() * 2.5 }, { 'addr': 2, 'Pressure': self.gauges.get_chamber_pressure() * 5 }, { 'addr': 3, 'Pressure': self.gauges.get_roughpump_pressure() * 3 }]) # Just to see the screen for longer time.sleep(5) Logging.logEvent( "Debug", "Status Update", { "message": "Current Pressure in Chamber is {}".format( self.gauges.get_chamber_pressure()), "level": 4 }) currentTime = time.time() if currentTime < next_pressure_read_time: time.sleep(next_pressure_read_time - currentTime) except Exception as e: # FileCreation.pushFile("Error",self.zoneUUID,'{"errorMessage":"%s"}'%(e)) exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] Logging.logEvent( "Error", "Pfeiffer Interface Thread", { "type": exc_type, "filename": fname, "line": exc_tb.tb_lineno, "thread": "PfeifferGaugeUpdater" }) Logging.logEvent( "Debug", "Status Update", { "message": "There was a {} error in PfeifferGaugeUpdater. File: {}:{}\n{}" .format(exc_type, fname, exc_tb.tb_lineno, e), "level": 1 }) if Logging.debug: raise e time.sleep(4)
def run(self): # While true to restart the thread if it errors out while True: # Check to make sure there is an active profile # and that we are sitting in an operational vacuum # and that all drivers and updaters are running if ProfileInstance.getInstance().activeProfile and \ HardwareStatusInstance.getInstance().OperationalVacuum and \ ProfileInstance.getInstance().zoneProfiles.getActiveProfileStatus(): try: Logging.logEvent("Debug", "Status Update", { "message": "DCCS: Starting Duty Cycle thread", "level": 2 }) Logging.logEvent( "Event", "Start Profile", { 'time': datetime.time(), "message": ProfileInstance.getInstance(). zoneProfiles.profileName, "ProfileInstance": ProfileInstance.getInstance() }) ProfileInstance.getInstance( ).zoneProfiles.updateThermalStartTime(time.time()) # local temp variables for checking state #TODO: Start time should gotten somewhere else, not made here if self.zoneProfiles.thermalStartTime: self.startTime = self.zoneProfiles.thermalStartTime else: self.startTime = int(time.time()) currentSetpointTemporary = 1 rampTemporary = False soakTemporary = True Logging.logEvent("Debug", "Status Update", { "message": "DCCS: Setting up Platen", "level": 2 }) HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Setup Platen', '']) for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: self.zones[zone].maxTempRisePerMin = self.zones[ zone].zoneProfile.maxHeatPerMin self.zones[zone].maxTempRisePerUpdate = ( self.zones[zone].maxTempRisePerMin / 60) * self.updatePeriod self.zones[ zone].expected_temp_values, self.expected_time_values = self.zones[ zone].createExpectedValues( self.zones[zone].zoneProfile. thermalProfiles, startTime=self.zoneProfiles. thermalStartTime) # Program loop is here while ProfileInstance.getInstance().activeProfile: Logging.logEvent( "Debug", "Status Update", { "message": "DCCS: Running Duty Cycle Thread", "level": 3 }) # You might need to stay is pause # get current time currentTime = time.time() # if there is no more expected time values, break out of while True loop if len(self.expected_time_values) <= 0: break # this will find the time value matching the current time # and give us the temp value it should be at that time. # print("currentTime: {}".format(currentTime)) # print("expected_time_values: {}".format(self.expected_time_values)) while currentTime > self.expected_time_values[0]: for zone in self.zones: if self.zones[ zone].zoneProfile.activeZoneProfile: self.zones[ zone].temp_temperature = self.zones[ zone].expected_temp_values[0] self.zones[ zone].expected_temp_values = self.zones[ zone].expected_temp_values[1:] self.expected_time_values = self.expected_time_values[ 1:] if len(self.setpoint_start_time) > 0: if currentTime > self.setpoint_start_time[0][0]: rampTemporary = True soakTemporary = False if currentTime > self.setpoint_start_time[ 0][1]: rampTemporary = False soakTemporary = True self.setpoint_start_time = self.setpoint_start_time[ 1:] currentSetpointTemporary += 1 if len(self.setpoint_start_time) <= 0: break if len(self.expected_time_values) <= 0: break self.checkPause() self.checkHold() # compare the temps just made with the values in self. # if they are different, or important log it if rampTemporary == True and self.ramp == False: ProfileInstance.getInstance( ).currentSetpoint = currentSetpointTemporary Logging.logEvent( "Event", "Profile", { "message": "Profile {} has entered setpoint {} Ramp". format( ProfileInstance.getInstance( ).zoneProfiles.profileName, currentSetpointTemporary), "ProfileInstance": ProfileInstance.getInstance() }) if soakTemporary == True and self.soak == False: if currentSetpointTemporary > 1: Logging.logEvent( "Event", "Profile", { "message": "Profile {} has entered setpoint {} Soak" .format( ProfileInstance.getInstance( ).zoneProfiles.profileName, currentSetpointTemporary - 1), "ProfileInstance": ProfileInstance.getInstance() }) ProfileInstance.getInstance.inRamp = False self.ramp = rampTemporary self.soak = soakTemporary # With the temp goal tempurture picked, make the duty cycle for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: # This checks to see if a current temp has been made... if self.zones[zone].temp_temperature: self.zones[zone].updateDutyCycle() else: print("Waiting...") if len(self.expected_time_values) <= 0: break # sleep until the next time around time.sleep(self.updatePeriod) # end of inner while True # end of test # turning off lamps at the end of test for zone in self.zones: if self.zones[zone].zoneProfile.activeZoneProfile: zone = self.zones[zone] if zone.lamps: self.d_out.update( {zone.lamps[1] + " PWM DC": 0}) self.d_out.update( {zone.lamps[0] + " PWM DC": 0}) else: HardwareStatusInstance.getInstance( ).TdkLambda_Cmds.append( ['Platen Duty Cycle', 0]) #TODO: Turn off the heaters here Logging.logEvent( "Event", "End Profile", { 'time': datetime.time(), "message": ProfileInstance.getInstance(). zoneProfiles.profileName, "ProfileInstance": ProfileInstance.getInstance() }) HardwareStatusInstance.getInstance().TdkLambda_Cmds.append( ['Disable Platen Output', '']) self.updateDBwithEndTime() self.running = False tcList = HardwareStatusInstance.getInstance( ).Thermocouples.tcList for tc in tcList: tc.update({"zone": 0, "userDefined": False}) # self.zoneProfile.activeZoneProfile = False # This assumes all zones have the same end time ProfileInstance.getInstance().activeProfile = False ProfileInstance.getInstance().vacuumWanted = False except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split( exc_tb.tb_frame.f_code.co_filename)[1] print("Error: {} in file {}:{}".format( exc_type, fname, exc_tb.tb_lineno)) self.running = False ProfileInstance.getInstance( ).zoneProfiles.activeProfile = False Logging.debugPrint( 1, "DCCS: Error in run, Duty Cycle: {}".format(str(e))) Logging.logEvent( "Error", "Duty Cycle Control Stub Thread", { "type": exc_type, "filename": fname, "line": exc_tb.tb_lineno, "thread": "DutyCycleControlStub", "ThreadCollection": self.parent, "item": "Duty Cycle Control Stub", "itemID": -1, "details": "There is a software error ({})".format(e) }) if Logging.debug: raise e # end of try, catch else: Logging.debugPrint( 4, "DCCS: activeProfile: {}".format( ProfileInstance.getInstance().activeProfile)) Logging.debugPrint( 4, "DCCS: OperationalVacuum: {}".format( HardwareStatusInstance.getInstance().OperationalVacuum) ) Logging.debugPrint( 4, "DCCS: getActiveProfileStatus: {}".format( ProfileInstance.getInstance( ).zoneProfiles.getActiveProfileStatus())) # Sleeping so it doesn't busy wait time.sleep(1)
def saveProfile(self, data): profileInstance = ProfileInstance.getInstance() return profileInstance.zoneProfiles.saveProfile(data)
def run(self): # While true to restart the thread if it errors out while True: # This has no startup, but should wait until all drivers and updaters are running Logging.logEvent("Debug", "Status Update", { "message": "VCS: Starting VacuumControlStub", "level": 2 }) try: while not self.wait_for_hardware( ): # Wait for hardware drivers to read sensors. Logging.logEvent( "Debug", "Status Update", { "message": "VCS: VacuumControlStub waiting for hardware to read the sensors.", "level": 4 }) time.sleep(1) self.cryoPumpPressure = self.hw.PfeifferGuages.get_cryopump_pressure( ) self.chamberPressure = self.hw.PfeifferGuages.get_chamber_pressure( ) self.roughPumpPressure = self.hw.PfeifferGuages.get_roughpump_pressure( ) self.state = self.determin_current_vacuum_state() if self.hw.ShiCryopump.is_regen_active(): Logging.logEvent( "Event", "Vacuum State", { "message": "Starting in Vacuum State: '{}' with a Cryopump Regeneration Active." "".format(self.state), "ProfileInstance": ProfileInstance.getInstance() }) else: Logging.logEvent( "Event", "Vacuum State", { "message": "Starting in Vacuum State: '{}'".format( self.state), "ProfileInstance": ProfileInstance.getInstance() }) # self.hw.OperationalVacuum = True while True: # With an active profile, we start putting the system under pressure Logging.logEvent("Debug", "Status Update", { "message": "VCS: Running Vacuum Control Stub", "level": 5 }) # Reading of pressure gauges self.cryoPumpPressure = self.hw.PfeifferGuages.get_cryopump_pressure( ) self.chamberPressure = self.hw.PfeifferGuages.get_chamber_pressure( ) self.roughPumpPressure = self.hw.PfeifferGuages.get_roughpump_pressure( ) Logging.logEvent( "Debug", "Status Update", { "message": "VCS: Current chamber pressure: {}".format( self.chamberPressure), "level": 4 }) old_state = self.state { 'Chamber: Atm; CryoP: Vac': self.state_00, 'Chamber: Atm; CryoP: Atm': self.state_01, 'PullingVac: Start': self.state_02, 'PullingVac: RoughingCryoP': self.state_03, 'PullingVac: CryoCool; Rough Chamber': self.state_04, 'PullingVac: M CryoCool; Rough Chamber': self.state_05, 'PullingVac: Cryo Pumping; Cross Over': self.state_06, 'PullingVac: Cryo Pumping Chamber': self.state_07, 'Operational Vacuum: Cryo Pumping': self.state_08, 'Operational Vacuum': self.state_09, 'Non-Operational Vacuum': self.state_10, }[self.state]() if self.hw.ShiCryopump.is_regen_active(): self.hw.PC_104.digital_out.update( {'RoughP GateValve': False}) step = self.hw.ShiCryopump.get_mcc_status('Regen Step') if self.hw.ShiCryopump.get_mcc_status( 'Roughing Interlock: Roughing Needed'): if self.hw.PC_104.digital_in.getVal( 'RoughP_On_Sw'): if self.roughPumpPressure < self.cryoPumpPressure: self.hw.Shi_MCC_Cmds.append( ['Clear_RoughingInterlock']) Logging.logEvent( "Event", "Cryopump Regeneration", { "message": "Clearing Roughing Interlock.". format(self.state), "ProfileInstance": ProfileInstance.getInstance() }) else: if self.hw.PC_104.digital_in.getVal( 'RoughP_Powered'): self.hw.PC_104.digital_out.update( {'RoughP PurgeGass': True}) self.hw.PC_104.digital_out.update( {'RoughP Start': True}) else: self.hw.PC_104.digital_out.update( {'RoughP Pwr Relay': True}) self.hw.PC_104.digital_out.update( {'RoughP PurgeGass': True}) elif (not self.hw.ShiCryopump.get_mcc_status('Roughing Valve State')) and \ (not step.startswith('T:')) and (not step.startswith('J:')) and \ (not step.startswith('H:')): self.hw.PC_104.digital_out.update( {'RoughP Pwr Relay': False}) self.hw.PC_104.digital_out.update( {'RoughP PurgeGass': False}) if step.startswith('C:') or step.startswith( 'D:') or step.startswith('E:'): self.hw.Shi_Compressor_Cmds.append('off') if self.hw.ShiCryopump.get_mcc_status( 'PumpOn?') or step.startswith('M:'): self.hw.Shi_Compressor_Cmds.append('on') self.hw.VacuumState = self.state if "Operational Vacuum" in self.state: self.hw.OperationalVacuum = True else: self.hw.OperationalVacuum = False Logging.logEvent( "Debug", "Status Update", { "message": "VCS: Current chamber state: {}".format( self.state), "level": 4 }) if old_state != self.state: Logging.logEvent( "Event", "Vacuum State", { "message": "New Vacuum State: '{}'".format(self.state), "ProfileInstance": ProfileInstance.getInstance() }) # sleep until the next time around time.sleep(self.updatePeriod) # end of inner while True except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] print("Error: {} in file {}:{}".format(exc_type, fname, exc_tb.tb_lineno)) # FileCreation.pushFile("Error",self.zoneUUID,'{"errorMessage":"%s"}'%(e)) ProfileInstance.getInstance( ).zoneProfiles.activeProfile = False Logging.debugPrint( 1, "VCS: Error in check run, vacuum Control Stub: {}".format( str(e))) if Logging.debug: raise e
def run(self): if os.name == "posix": userName = os.environ['LOGNAME'] else: userName = "******" # While true to restart the thread if it errors out while True: # Catch anything that goes wrong # This has no check because it should always be running try: # Thread "Start up" stuff goes here Logging.logEvent("Debug", "Status Update", { "message": "Starting Shi Mcc Control Stub Thread", "level": 2 }) if "root" in userName: # Live systems go here Logging.logEvent("Debug", "Status Update", { "message": "Power on the Shi Mcc", "level": 3 }) self.mcc.open_port() while self.hw.PC_104.digital_out.getVal( 'CryoP Pwr Relay 1') is None: time.sleep(1) Currently_powered = self.hw.PC_104.digital_out.getVal( 'MCC2 Power') self.hw.PC_104.digital_out.update({'MCC2 Power': True}) if not Currently_powered: time.sleep(5) self.mcc.flush_port() # Now send some initialization commands # The maximum second stage temperature the cryopump may start to restart after a power failure. val = self.mcc.Get_RegenParam_6() if val['Error']: Logging.logEvent( "Debug", "Status Update", { "message": 'Shi MCC GetRegenParam_6" Error Response: %s' % (val), "level": 4 }) raise Exception( "Shi MCC Error with Get_RegenParam_6: %s" % val['Response']) else: if val['Data'] != 65: self.run_set_cmd(self.mcc.Set_RegenParam, [' ', '6', 65]) # 2: Power failure recovery enabled only when T2 is less than the limit set point. val = self.mcc.Get_PowerFailureRecovery() if val['Error']: Logging.logEvent( "Debug", "Shi MCC Error", { "message": "Set_RegenParam: %s" % val['Response'], "level": 3 }) raise Exception( "Shi MCC Error with Set_RegenParam: %s" % val['Response']) else: if val['Data'] != 2: self.run_set_cmd(self.mcc.Set_RegenParam, [' ', 2]) next_param_read_time = time.time() # setup is done, this loop is the normal thread loop while True: next_mcc_read_time = time.time() + self.mcc_read_period if "root" in userName: try: Logging.logEvent( "Debug", "Status Update", { "message": "Reading and writing with ShiMccUpdater.", "level": 4 }) val = self.mcc.get_Status() if val['Error']: Logging.logEvent( "Debug", "Status Update", { "message": "Shi MCC Error Response: %s" % val['Response'], "level": 4 }) else: self.hw.ShiCryopump.update( {'MCC Status': val['Response']}) Logging.logEvent( "Debug", "Status Update", { "message": "Cryopump Stage 1: {:.1f}K; Stage 2: {:.1f}K" "".format( self.hw.ShiCryopump.get_mcc_status( 'Stage 1 Temp'), self.hw.ShiCryopump.get_mcc_status( 'Stage 2 Temp')), "level": 4 }) if time.time() > next_param_read_time: val = self.mcc.get_ParamValues() if val['Error']: Logging.logEvent( "Debug", "Status Update", { "message": "Shi MCC Error Response: %s" % val['Response'], "level": 4 }) else: self.hw.ShiCryopump.update( {'MCC Params': val['Response']}) next_param_read_time = time.time( ) + self.param_period while len(self.hw.Shi_MCC_Cmds): cmd = self.hw.Shi_MCC_Cmds.pop() if 'FirstStageTempCTL' == cmd[ 0]: # 2.9 • First Stage Temperature Control pg:10 self.run_set_cmd( self.mcc.Set_FirstStageTempCTL, cmd) self.run_get_cmd( self.mcc.Get_FirstStageTempCTL, "First Stage Temp CTL") elif 'PowerFailureRecovery' == cmd[ 0]: # 2.12 • Power Failure Recovery pg:11 self.run_set_cmd( self.mcc.Set_PowerFailureRecovery, cmd) self.run_get_cmd( self.mcc.Get_PowerFailureRecovery, "Power Failure Recovery") elif 'Turn_CryoPumpOn' == cmd[ 0]: # 2.14 • Pump On/Off/Query pg:13 self.run_set_cmd(self.mcc.Turn_CryoPumpOn, cmd) elif 'Turn_CryoPumpOff' == cmd[ 0]: # 2.14 • Pump On/Off/Query pg:13 self.run_set_cmd(self.mcc.Turn_CryoPumpOff, cmd) elif 'Close_PurgeValve' == cmd[ 0]: # 2.15 • Purge On/Off/Query pg:14 self.run_set_cmd(self.mcc.Close_PurgeValve, cmd) elif 'Open_PurgeValve' == cmd[ 0]: # 2.15 • Purge On/Off/Query pg:14 if self.hw.PC_104.digital_in.getVal( 'CryoP_GV_Closed'): self.run_set_cmd( self.mcc.Open_PurgeValve, cmd) else: Logging.logEvent( "Debug", "Status Update", { "message": 'Cryopump Gate Valve not closed. Purge valve not opened.', "level": 2 }) elif 'Start_Regen' == cmd[ 0]: # 2.16 • Regeneration pg:14 self.run_set_cmd(self.mcc.Start_Regen, cmd) Logging.logEvent( "Event", "Cryopump Regeneration", { "message": "Cryopump regeneration starting", "ProfileInstance": ProfileInstance.getInstance() }) elif 'Set_RegenParam' == cmd[ 0]: # 2.19 • Regeneration Parameters pg:16 self.run_set_cmd(self.mcc.Set_RegenParam, cmd) val = self.mcc.Get_RegenParam(cmd[1]) if val['Error']: Logging.logEvent( "Debug", "Status Update", { "message": 'Shi MCC GetRegenParam_%s" Error Response: %s' % (cmd[1], val), "level": 4 }) else: self.hw.ShiCryopump.update({ 'MCC Params': { "Regen Param_%s" % cmd[1]: val['Data'] } }) elif 'RegenStartDelay' == cmd[ 0]: # 2.21 • Regeneration Start Delay pg.18 self.run_set_cmd( self.mcc.Set_RegenStartDelay, cmd) self.run_get_cmd( self.mcc.Get_RegenStartDelay, "Regen Start Delay") elif 'Open_RoughingValve' == cmd[ 0]: # 2.24 • Rough On/Off/Query pg:19 self.run_set_cmd( self.mcc.Open_RoughingValve, cmd) elif 'Close_RoughingValve' == cmd[ 0]: # 2.24 • Rough On/Off/Query pg:19 self.run_set_cmd( self.mcc.Close_RoughingValve, cmd) elif 'Clear_RoughingInterlock' == cmd[ 0]: # 2.25 • Rough Valve Interlock pg:20 self.run_set_cmd( self.mcc.Clear_RoughingInterlock, cmd) elif 'SecondStageTempCTL' == cmd[ 0]: # 2.27 • Second Stage Temperature Control pg:21 self.run_set_cmd( self.mcc.Set_SecondStageTempCTL, cmd) self.run_get_cmd( self.mcc.Get_SecondStageTempCTL, "Second Stage Temp CTL") elif 'Turn_TcPressureOn' == cmd[ 0]: # 2.29 • TC On/Off/Query pg:22 self.run_set_cmd( self.mcc.Turn_TcPressureOn, cmd) elif 'Turn_TcPressureOff' == cmd[ 0]: # 2.29 • TC On/Off/Query pg:22 self.run_set_cmd( self.mcc.Turn_TcPressureOff, cmd) else: Logging.logEvent( "Error", 'Unknown Shi_MCC_Cmd: "%s"' % cmd[0], { "type": 'Unknown Shi_MCC_Cmd', "filename": 'ThreadControls/ShiMccUpdater.py', "line": 0, "thread": "ShiMccUpdater" }) except ValueError as err: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split( exc_tb.tb_frame.f_code.co_filename)[1] Logging.logEvent( "Error", 'Error in ShiMccUpdater reading values: "%s"' % err, { "type": exc_type, "filename": fname, "line": exc_tb.tb_lineno, "thread": "ShiMccUpdater" }) if Logging.debug: raise err else: Logging.logEvent("Debug", "Status Update", { "message": "Test run of Shi MCC loop", "level": 4 }) if time.time() < next_mcc_read_time: time.sleep(next_mcc_read_time - time.time()) except Exception as e: exc_type, exc_obj, exc_tb = sys.exc_info() fname = os.path.split(exc_tb.tb_frame.f_code.co_filename)[1] Logging.logEvent( "Error", "Shi MCC Interface Thread", { "type": exc_type, "filename": fname, "line": exc_tb.tb_lineno, "thread": "ShiMccUpdater" }) Logging.logEvent( "Debug", "Status Update", { "message": "There was a {} error in ShiMccUpdater. File: {}:{}\n{}" .format(exc_type, fname, exc_tb.tb_lineno, e), "level": 1 }) if Logging.debug: raise e self.mcc.close_port() time.sleep(4)
def loadProfile(self, data): profileInstance = ProfileInstance.getInstance() return profileInstance.zoneProfiles.load_profile(data["profile_name"])
Logging.verbos = arg.count("v") if(len(sys.argv)>2): for arg in sys.argv: if "--debug" in arg: Logging.debug = True Logging.logEvent("Debug","Status Update", {"message": "Verbos on: Level {}".format(Logging.verbos), "level":1}) PORT = 8000 Logging.logEvent("Debug","Status Update", {"message": "Starting initializing threads and drivers", "level":1}) hardwareStatusInstance = HardwareStatusInstance.getInstance() profileInstance = ProfileInstance.getInstance() threadInstance = ThreadCollectionInstance.getInstance() Logging.logEvent("Event","System", {"message": "Server is fully booted", "ProfileInstance": profileInstance.getInstance()}) Logging.logEvent("Debug","Status Update", {"message": "Finished initializing threads and drivers", "level":1}) httpd = ReuseAddrTCPServer(("", PORT), VerbHandler) Logging.logEvent("Debug","Status Update", {"message": "Start Up Complete, Server is listening for request...", "level":1})
def run(self): # While true to restart the thread if it errors out while True: # Check to make sure there is an active profile # and that we are sitting in an operational vacuum # and that all drivers and updaters are running a_out = self.hardwareStatus.getInstance().PC_104.analog_out # todo: better variable name? d_out = self.hardwareStatus.getInstance().PC_104.digital_out a_out.update({'LN2 Shroud': 0,'LN2 Platen': 0}) d_out.update({'LN2-S Sol': False, 'LN2-P Sol': False, }) if ProfileInstance.getInstance().activeProfile and HardwareStatusInstance.getInstance().OperationalVacuum: # try and catch anything that might go wrong try: # some start up stuff here ln2_max = 0.1 ln2_min = -0.2 valveMax = 4095/2 time.sleep(self.SLEEP_TIME) # hwStatus = self.hardwareStatus.getInstance() if os.name == "posix": userName = os.environ['LOGNAME'] else: userName = "******" # Normal program loop while ProfileInstance.getInstance().activeProfile and HardwareStatusInstance.getInstance().OperationalVacuum: dutycyclelist = [] platenDuty = None for zoneStr in self.ThreadCollection.dutyCycleThread.zones: zone = self.ThreadCollection.dutyCycleThread.zones[zoneStr] # If a zone doesn't have a dutyCycle, they aren't running, so we can safely ignore them try: if zoneStr != "zone9": dutycyclelist.append(zone.dutyCycle) else: platenDuty = zone.dutyCycle except Exception as e: pass if dutycyclelist: dutycyclemin = min(dutycyclelist) Logging.debugPrint(3,"Min Duty Cycle: {}".format(dutycyclemin)) if dutycyclemin < ln2_max: # todo: arb_value to be determined # throw safety up d_out.update({'LN2-S Sol': True}) # 2500 is the point the valve should be opened too #a_out.update({'LN2 Shroud': 4095, 'LN2 Platen': 4095}) PercentVavleopen = valveMax*(dutycyclemin-ln2_max)/(ln2_min-ln2_max) if dutycyclemin < ln2_min: PercentVavleopen = valveMax a_out.update({'LN2 Shroud': PercentVavleopen}) Logging.debugPrint(3,"The Shroud LN2 should be on {}".format(PercentVavleopen)) else: Logging.debugPrint(3,"The Shroud LN2 should be off") # What's the difference between this and... d_out.update({'LN2-S Sol': False}) a_out.update({'LN2 Shroud': 0}) # end of if/else # end of if DutycycleList if platenDuty: if platenDuty < ln2_max: # todo: arb_value to be determined # throw safety up d_out.update({'LN2-P Sol': True}) # 2500 is the point the valve should be opened too #a_out.update({'LN2 Shroud': 4095, 'LN2 Platen': 4095}) PercentVavleopen = valveMax*(platenDuty-ln2_max)/(ln2_min-ln2_max) if platenDuty < ln2_min: PercentVavleopen = valveMax a_out.update({'LN2 Platen': PercentVavleopen}) Logging.debugPrint(3,"The Platen LN2 should be on {}".format(PercentVavleopen)) else: Logging.debugPrint(3,"The Platen LN2 should be off") # What's the difference between this and... d_out.update({'LN2-P Sol': False, }) a_out.update({'LN2 Platen': 0}) time.sleep(self.SLEEP_TIME) # end of Inner While True except Exception as e: Logging.debugPrint(1, "Error in run, LN2 Control Stub: {}".format(str(e))) if Logging.debug: raise e # end of try catch else: Logging.debugPrint(4,"LN2: AP: {}, Vacuum: {}".format(ProfileInstance.getInstance().activeProfile,HardwareStatusInstance.getInstance().OperationalVacuum)) # end of If should be running time.sleep(self.SLEEP_TIME)