def createIote2eRequest(self ):
        time.sleep(1)
        logger.info('ProcessTempToFan createIote2eRequest:')
        #TODO: get temp from DAQC
        tempC = str(round(DAQC.getTEMP(0,0,'c'),2))
        pairs = { self.sensorName: tempC }

        iote2eRequest = Iote2eRequest( login_name=self.loginVo.loginName,source_name=self.loginVo.sourceName, source_type='temperature', 
                                       request_uuid=str(uuid.uuid4()), 
                                       request_timestamp=ClientUtils.nowIso8601(), 
                                       pairs=pairs, operation='SENSORS_VALUES')
        return iote2eRequest
Example #2
0
def showTemperature():
    for i in range(0, 10):
        t = round(DAQC.getTEMP(0, 0, 'c'), 2)
        print(t)
        sleep(1)
Example #3
0
    def send_data(self):
        # create the sensor data message
        if self.verbose:
            #convert to string and keep order by naming keys
            data = json.dumps(
                {
                    "00-Board address": self.address,
                    "01-Input Channel": self.channel,
                    "02-Description": self.name,
                    "03-Readout": DAQC.getTEMP(self.address, self.channel,
                                               "f"),
                    "04-Unit": "F",
                    "05-Switch status": bool(DAQC.getSWstate(0)),
                    "06-Sensor1 status": bool(MOTOR.getSENSORS(0) & 0x01),
                    "07-Sensor2 status": bool(MOTOR.getSENSORS(0) & 0x02),
                    "08-Sensor3 status": bool(MOTOR.getSENSORS(0) & 0x04),
                    "09-Sensor4 status": bool(MOTOR.getSENSORS(0) & 0x08),
                    "10-Timestamp": time.strftime("%Y-%m-%d %H:%M:%S")
                },
                sort_keys=True)

            states = json.dumps(
                {
                    "00-FSM Name": 'test FSM',
                    "01-FSM state": self.fsm.state,
                    "02-Timestamp": time.strftime("%Y-%m-%d %H:%M:%S")
                },
                sort_keys=True)

            relay_state = json.dumps(
                {
                    "Relay 1": bool(RELAY.relaySTATE(0)
                                    & 0x01),  # just a int right now 1,2,4 etc
                    "Relay 2": bool(RELAY.relaySTATE(0) & 0x02),
                    "Relay 3": bool(RELAY.relaySTATE(0) & 0x04),
                    "Relay 4": bool(RELAY.relaySTATE(0) & 0x08),
                    "Relay 5": bool(RELAY.relaySTATE(0) & 0x10),
                    "Relay 6": bool(RELAY.relaySTATE(0) & 0x20),
                    "Relay 7": bool(RELAY.relaySTATE(0) & 0x40),
                    "Relay 8": bool(RELAY.relaySTATE(1) & 0x01),
                    "Relay 9": bool(RELAY.relaySTATE(1) & 0x02),
                    "Relay 10": bool(RELAY.relaySTATE(1) & 0x04),
                    "Relay 11": bool(RELAY.relaySTATE(1) & 0x08),
                    "Relay 12": bool(RELAY.relaySTATE(1) & 0x10),
                    "Relay 13": bool(RELAY.relaySTATE(1) & 0x20),
                    "Relay 14": bool(RELAY.relaySTATE(1) & 0x40)
                },
                sort_keys=True)

        else:
            #short version
            # takes a while to get the sensor reading
            data = DAQC.getTEMP(self.address, self.channel, "f")
            states = self.fsm.state

        #TODO big combersome testing led message
        '''
        dict=json.loads(data)
        if dict['Switch status']:
            DAQC.setDOUTbit(0, 0)
        else :
            DAQC.clrDOUTbit(0, 0)
        '''

        #publish.single("sensors/data", data, hostname=broker)
        self.mqttc.publish(hostname + "/sensors/data", data, 0)  # publish

        #report state
        self.mqttc.publish("sys/state", states, 0)  # publish

        # report relay state
        self.mqttc.publish(topic=hostname + "/relays/state",
                           payload=relay_state,
                           qos=0,
                           retain=True)  # publish
Example #4
0
                    except AssertionError:
                        DP2.toggleDOUTbit(addr, bit)
                    resp['bit'] = bit
                    resp['state'] = 'UNKNOWN'
                elif (cmd == "getADC"):
                    channel = args['channel']
                    try:
                        voltage = DP.getADC(addr, channel)
                    except AssertionError:
                        voltage = DP2.getADC(addr, channel)
                    resp['channel'] = channel
                    resp['voltage'] = voltage
                elif (cmd == "getTEMP"):
                    bit = args['bit']
                    scale = args['scale']
                    try:
                        temp = DP.getTEMP(addr, bit, scale)
                    except AssertionError:
                        temp = DP2.getTEMP(addr, bit, scale)
                    resp['temp'] = temp
                    resp['bit'] = bit
                else:
                    sys.stderr.write("unknown daqc cmd: " + cmd)
                print(json.dumps(resp))
        elif (plate_type == "MOTOR"):
            break
        else:
            sys.stderr.write("unknown plate_type: " + plate_type)
    except (EOFError, SystemExit):
        sys.exit(0)
Example #5
0
	c = open("{0}/set.temp".format(PID_PATH), 'r')
	SetTemp = float(c.read())
	c.close()
	d = open("{0}/set.delta".format(PID_PATH), 'r')
	SetDelta = float(d.read())
	d.close()
	
	MinTemp = SetTemp - SetDelta
	MaxTemp = SetTemp + SetDelta
	
	#Get Sensor Data
	InputVoltage = Vrms(0,3)
	MainAmps = Curr(0,0)
	HotAmps = Curr(0,1)
	ColdAmps = Curr(0,2)
	Temp = daqc.getTEMP(0, 0, TempUnits[0])

	#Check our last run time, if > minCycle, see if we need to toggle SSRs
	lrf = open("{0}/last.run".format(PID_PATH), 'r')
	lastRun = float(lrf.read())
	lrf.close()
	now = time.time()
	if now > (lastRun + MinCycle):
		Toggled = 0
		if Temp > MaxTemp:
			if ColdState == 0:
				daqc.clrDOUTbit(0,0) #Hot Off
				daqc.setDOUTbit(0,1) #Cold On
				HotState = 0
				ColdState = 1
				Toggled = 1