Skip to content
Snippets Groups Projects
Commit 5816ddef authored by Arno Schoenmakers's avatar Arno Schoenmakers
Browse files

Bug 1319: Removed DOS characters

parent 447ba3bc
Branches
Tags
No related merge requests found
# beamformermformer test for 96 rcu's in LBA mode (LBL & LBH input) # beamformermformer test for 96 rcu's in LBA mode (LBL & LBH input)
# two antennas per beam, four beams # two antennas per beam, four beams
# object zenith # object zenith
# version 1.5 27 may 2009 M.J.Norden # version 1.5 27 may 2009 M.J.Norden
killall beamctl killall beamctl
eval swlevel 3 eval swlevel 3
beamctl --array=LBAINNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=124:185 --direction=0,0,LOFAR_LMN& beamctl --array=LBAINNER --rcumode=3 --rcus=0:1 --subbands=270:331 --beamlets=124:185 --direction=0,0,LOFAR_LMN&
beamctl --array=LBAINNER --rcumode=3 --rcus=0:47 --subbands=270:331 --beamlets=186:247 --direction=0,0,LOFAR_LMN& beamctl --array=LBAINNER --rcumode=3 --rcus=0:47 --subbands=270:331 --beamlets=186:247 --direction=0,0,LOFAR_LMN&
beamctl --array=LBAOUTER --rcumode=1 --rcus=47:48 --subbands=270:331 --beamlets=0:61 --direction=0,0,LOFAR_LMN& beamctl --array=LBAOUTER --rcumode=1 --rcus=47:48 --subbands=270:331 --beamlets=0:61 --direction=0,0,LOFAR_LMN&
beamctl --array=LBAOUTER --rcumode=1 --rcus=48:95 --subbands=270:331 --beamlets=62:123 --direction=0,0,LOFAR_LMN& beamctl --array=LBAOUTER --rcumode=1 --rcus=48:95 --subbands=270:331 --beamlets=62:123 --direction=0,0,LOFAR_LMN&
sleep 5 sleep 5
rspctl --wg=0 rspctl --wg=0
rspctl --rcuprsg=0 rspctl --rcuprsg=0
rspctl --rcuenable=1 rspctl --rcuenable=1
rspctl --rcumode=3 --sel=0:47 rspctl --rcumode=3 --sel=0:47
sleep 3 sleep 3
rspctl --rcumode=1 --sel=48:95 rspctl --rcumode=1 --sel=48:95
rspctl --stati=beamlet rspctl --stati=beamlet
#!/usr/bin/python #!/usr/bin/python
import socket import socket
import time import time
import struct import struct
VERSION = '1.0.2' # version of this script VERSION = '1.0.2' # version of this script
## to use other commands, see playground on the bottom of this file ## to use other commands, see playground on the bottom of this file
##== change only next settings ==================================== ##== change only next settings ====================================
printToScreen = 1 printToScreen = 1
printToFile = 0 printToFile = 0
printDataToFile = 0 # save setpoint, temp, humidity to data.txt printDataToFile = 0 # save setpoint, temp, humidity to data.txt
# select test modes # select test modes
doCheckRelayPanel = 0 doCheckRelayPanel = 0
doCheckFans = 0 doCheckFans = 0
doCheckDoors = 0 doCheckDoors = 0
doChangeSettings = 0 # fill in table below doChangeSettings = 0 # fill in table below
#HOST = '192.168.178.111' # Home TempControl #HOST = '192.168.178.111' # Home TempControl
#HOST = '10.151.19.2' # CS010c TempControl #HOST = '10.151.19.2' # CS010c TempControl
#HOST = '10.151.134.3' # RS106c TempControl #HOST = '10.151.134.3' # RS106c TempControl
HOST = '10.151.162.3' # RS302c TempControl HOST = '10.151.162.3' # RS302c TempControl
#HOST = '10.151.66.3' # CS030c TempControl #HOST = '10.151.66.3' # CS030c TempControl
#HOST = '10.151.161.3' # CS301c TempControl #HOST = '10.151.161.3' # CS301c TempControl
#HOST = '10.87.2.239' # ASTRON TempControl on desk PD #HOST = '10.87.2.239' # ASTRON TempControl on desk PD
# settings for (cab0, cab1, cab2, cab3) # settings for (cab0, cab1, cab2, cab3)
# for LOFAR NL stations cab2 is not available # for LOFAR NL stations cab2 is not available
# cab0 = rack with receiver 0, cab3 = always control rack # cab0 = rack with receiver 0, cab3 = always control rack
MinTemp = (0.00, 0.00, 0.00, 10.0) MinTemp = (0.00, 0.00, 0.00, 10.0)
MaxTemp = (35.0, 35.0, 35.0, 30.0) MaxTemp = (35.0, 35.0, 35.0, 30.0)
MinMinTemp = (0.00, 0.00, 0.00, 8.0) MinMinTemp = (0.00, 0.00, 0.00, 8.0)
MaxMaxTemp = (40.0, 40.0, 40.0, 35.0) MaxMaxTemp = (40.0, 40.0, 40.0, 35.0)
MaxHum = (90.0, 90.0, 90.0, 80.0) MaxHum = (90.0, 90.0, 90.0, 80.0)
MaxMaxHum = (95.0, 95.0, 95.0, 85.0) MaxMaxHum = (95.0, 95.0, 95.0, 85.0)
ControlSpan = (2.00, 2.00, 2.00, 2.00) ControlSpan = (2.00, 2.00, 2.00, 2.00)
MaxDayChange = (1.00, 1.00, 1.00, 1.00) MaxDayChange = (1.00, 1.00, 1.00, 1.00)
#================================================================== #==================================================================
PORT = 10000 # Gateway port PORT = 10000 # Gateway port
ecSck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) ecSck = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
# === TCP PROTOCOL from controller === # === TCP PROTOCOL from controller ===
EC_NONE = 0 EC_NONE = 0
EC_STATUS = 1 EC_STATUS = 1
EC_SETTINGS = 2 EC_SETTINGS = 2
EC_CTRL_TEMP = 3 EC_CTRL_TEMP = 3
EC_VERSION = 5 EC_VERSION = 5
EC_SET_MODE = 10 EC_SET_MODE = 10
EC_SET_TEMP = 15 EC_SET_TEMP = 15
EC_SET_48 = 20 EC_SET_48 = 20
EC_RESET_48 = 22 EC_RESET_48 = 22
EC_SET_230 = 25 EC_SET_230 = 25
EC_RESET_230 = 27 EC_RESET_230 = 27
EC_SET_DOOR_CTRL = 50 EC_SET_DOOR_CTRL = 50
EC_SET_HUM_CTRL = 52 EC_SET_HUM_CTRL = 52
EC_SET_MAX_TEMP = 100 EC_SET_MAX_TEMP = 100
EC_SET_MIN_TEMP = 101 EC_SET_MIN_TEMP = 101
EC_SET_MAXMAX_TEMP = 102 EC_SET_MAXMAX_TEMP = 102
EC_SET_MINMIN_TEMP = 103 EC_SET_MINMIN_TEMP = 103
EC_SET_MAX_HUM = 105 EC_SET_MAX_HUM = 105
EC_SET_MAXMAX_HUM = 106 EC_SET_MAXMAX_HUM = 106
EC_SET_CTRL_SPAN = 110 EC_SET_CTRL_SPAN = 110
EC_SET_MAX_CHANGE = 111 EC_SET_MAX_CHANGE = 111
EC_SET_SECOND = 115 EC_SET_SECOND = 115
EC_SET_FANS = 116 EC_SET_FANS = 116
MODE_OFF = 0 MODE_OFF = 0
MODE_ON = 1 MODE_ON = 1
MODE_AUTO = 2 MODE_AUTO = 2
MODE_MANUAL = 3 MODE_MANUAL = 3
MODE_STARTUP = 4 MODE_STARTUP = 4
PWR_OFF = 0 PWR_OFF = 0
PWR_ON = 1 PWR_ON = 1
LCU = 230 LCU = 230
# used variables # used variables
cabs =(0,1,3) # cabs in station cabs =(0,1,3) # cabs in station
version = 0 # EC version version = 0 # EC version
#--------------------------------------- #---------------------------------------
# open files if needed # open files if needed
if (printToFile == 1): if (printToFile == 1):
#(hostname, aliaslist, ipaddrlist) = socket.gethostbyaddr(HOST) #(hostname, aliaslist, ipaddrlist) = socket.gethostbyaddr(HOST)
#stationname = hostname.split('.')[0] #stationname = hostname.split('.')[0]
#print stationname #print stationname
filename = "tempctrl.txt" filename = "tempctrl.txt"
f = open(filename, mode='w') f = open(filename, mode='w')
#--------------------------------------- #---------------------------------------
def closeFile(): def closeFile():
if (printToFile == 1): if (printToFile == 1):
f.close() f.close()
#--------------------------------------- #---------------------------------------
# print information to screen or file # print information to screen or file
def printInfo(info): def printInfo(info):
if (printToScreen == 1): if (printToScreen == 1):
print info print info
if (printToFile == 1): if (printToFile == 1):
f.write(info) f.write(info)
f.write('\n') f.write('\n')
#--------------------------------------- #---------------------------------------
# connect to station EC_controller # connect to station EC_controller
def connectToHost(): def connectToHost():
info = "connecting to %s on port %d\n" %(HOST, PORT) info = "connecting to %s on port %d\n" %(HOST, PORT)
printInfo(info) printInfo(info)
ecSck.connect((HOST, PORT)) ecSck.connect((HOST, PORT))
ecSck.settimeout(5.0) ecSck.settimeout(5.0)
#--------------------------------------- #---------------------------------------
def disconnectHost(): def disconnectHost():
ecSck.close() ecSck.close()
#--------------------------------------- #---------------------------------------
def sendCmd(cmdId=EC_NONE, cab=-1, value=0): def sendCmd(cmdId=EC_NONE, cab=-1, value=0):
if (cmdId == EC_NONE): if (cmdId == EC_NONE):
return (false) return (false)
cmd = struct.pack('hhh', cmdId, cab, int(value)) cmd = struct.pack('hhh', cmdId, cab, int(value))
ecSck.send(cmd) ecSck.send(cmd)
#--------------------------------------- #---------------------------------------
def recvAck(): def recvAck():
data = ecSck.recv(6) data = ecSck.recv(6)
header = struct.unpack('hhh', data) header = struct.unpack('hhh', data)
cmdId = header[0] cmdId = header[0]
status = header[1] status = header[1]
PLSize = header[2] PLSize = header[2]
if (PLSize > 0): if (PLSize > 0):
data = ecSck.recv(PLSize) data = ecSck.recv(PLSize)
fmt = 'h' * int(PLSize / 2) fmt = 'h' * int(PLSize / 2)
PL = struct.unpack(fmt, data) PL = struct.unpack(fmt, data)
else: else:
PL = [] PL = []
return (cmdId, status, PL) return (cmdId, status, PL)
#--------------------------------------- #---------------------------------------
def setSecond(sec=0): def setSecond(sec=0):
sendCmd(EC_SET_SECOND, 0, sec) sendCmd(EC_SET_SECOND, 0, sec)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
#--------------------------------------- #---------------------------------------
def waitForSync(): def waitForSync():
while ((time.gmtime()[5] % 10) != 7): while ((time.gmtime()[5] % 10) != 7):
time.sleep(0.5) time.sleep(0.5)
time.sleep(1.0) time.sleep(1.0)
#--------------------------------------- #---------------------------------------
def waitForUpdate(): def waitForUpdate():
while ((time.gmtime()[5] % 10) != 3): while ((time.gmtime()[5] % 10) != 3):
time.sleep(0.5) time.sleep(0.5)
time.sleep(1.0) time.sleep(1.0)
#--------------------------------------- #---------------------------------------
def setMode(cab=-1, mode=MODE_AUTO): def setMode(cab=-1, mode=MODE_AUTO):
sendCmd(EC_SET_MODE, cab, mode) sendCmd(EC_SET_MODE, cab, mode)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetMode cab %d to %d' %(cab, mode)) printInfo('SetMode cab %d to %d' %(cab, mode))
#--------------------------------------- #---------------------------------------
def setPower(pwr=-1, state=PWR_ON): def setPower(pwr=-1, state=PWR_ON):
if ((pwr == 48) or (pwr == -1)): if ((pwr == 48) or (pwr == -1)):
sendCmd(EC_SET_48, 0, state) sendCmd(EC_SET_48, 0, state)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('Power Set 48V to %d' %(state)) printInfo('Power Set 48V to %d' %(state))
if ((pwr == LCU) or (pwr == -1)): if ((pwr == LCU) or (pwr == -1)):
sendCmd(EC_SET_230, 0, state) sendCmd(EC_SET_230, 0, state)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('Power Set LCU to %d' %(state)) printInfo('Power Set LCU to %d' %(state))
#--------------------------------------- #---------------------------------------
def resetPower(pwr=-1): def resetPower(pwr=-1):
if ((pwr == 48) or (pwr == -1)): if ((pwr == 48) or (pwr == -1)):
sendCmd(EC_RESET_48, 0, 0) sendCmd(EC_RESET_48, 0, 0)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('PowerReset 48V') printInfo('PowerReset 48V')
if ((pwr == LCU) or (pwr == -1)): if ((pwr == LCU) or (pwr == -1)):
sendCmd(EC_RESET_230, 0, 0) sendCmd(EC_RESET_230, 0, 0)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('PowerReset LCU') printInfo('PowerReset LCU')
#--------------------------------------- #---------------------------------------
## mode 1 = moving setpoint ## mode 1 = moving setpoint
## mode 2 = constant setpoint, preset to 25.0 C ## mode 2 = constant setpoint, preset to 25.0 C
def setControlMode(cab=-1, mode=1): def setControlMode(cab=-1, mode=1):
sendCmd(EC_SET_CTRL_MODE, cab, mode) sendCmd(EC_SET_CTRL_MODE, cab, mode)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetControlMode cab %d to %d' %(cab, mode)) printInfo('SetControlMode cab %d to %d' %(cab, mode))
#--------------------------------------- #---------------------------------------
## search for new setpoint, works only in control mmode 1 ## search for new setpoint, works only in control mmode 1
def seekNewSetpoint(cab=-1): def seekNewSetpoint(cab=-1):
if (version < 102): if (version < 102):
printInfo('to use this function update firmware') printInfo('to use this function update firmware')
return return
sendCmd(EC_SET_MODE, cab, MODE_STARTUP) sendCmd(EC_SET_MODE, cab, MODE_STARTUP)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('Find newSetpoint cab %d' %(cab)) printInfo('Find newSetpoint cab %d' %(cab))
#--------------------------------------- #---------------------------------------
## set seek time in minutes ## set seek time in minutes
def setSeekTime(cab=-1, time=60): def setSeekTime(cab=-1, time=60):
sendCmd(EC_SET_SEEK_TIME, cab, time) sendCmd(EC_SET_SEEK_TIME, cab, time)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetTemperature cab %d to %4.2f' %(cab,temp)) printInfo('SetTemperature cab %d to %4.2f' %(cab,temp))
#--------------------------------------- #---------------------------------------
## set max temperature change in given seek time ## set max temperature change in given seek time
def setSeekChange(cab=-1, temp=5.0): def setSeekChange(cab=-1, temp=5.0):
temperature = int(temp * 100.) temperature = int(temp * 100.)
sendCmd(EC_SET_SEEK_CHANGE, cab, temperature) sendCmd(EC_SET_SEEK_CHANGE, cab, temperature)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetTemperature cab %d to %4.2f' %(cab,temp)) printInfo('SetTemperature cab %d to %4.2f' %(cab,temp))
#--------------------------------------- #---------------------------------------
## set new setpoint, works only in manual mode ## set new setpoint, works only in manual mode
def setTemperature(cab=-1, temp=20.0): def setTemperature(cab=-1, temp=20.0):
temperature = int(temp * 100.) temperature = int(temp * 100.)
sendCmd(EC_SET_TEMP, cab, temperature) sendCmd(EC_SET_TEMP, cab, temperature)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetTemperature cab %d to %4.2f' %(cab,temp)) printInfo('SetTemperature cab %d to %4.2f' %(cab,temp))
#--------------------------------------- #---------------------------------------
## set new setpoint, works only in manual mode ## set new setpoint, works only in manual mode
def setFans(cab=-1, fans=0x0f): def setFans(cab=-1, fans=0x0f):
sendCmd(EC_SET_FANS, cab, fans) sendCmd(EC_SET_FANS, cab, fans)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetFans cab %d to %X' %(cab,fans)) printInfo('SetFans cab %d to %X' %(cab,fans))
#--------------------------------------- #---------------------------------------
## set door control to on(1) or off(0) ## set door control to on(1) or off(0)
def setDoorControl(cab=-1, state=1): def setDoorControl(cab=-1, state=1):
sendCmd(EC_SET_DOOR_CTRL, cab, state) sendCmd(EC_SET_DOOR_CTRL, cab, state)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetDoorControl cab %d to %d' %(cab, state)) printInfo('SetDoorControl cab %d to %d' %(cab, state))
#--------------------------------------- #---------------------------------------
## set hum control to on(1) or off(0) ## set hum control to on(1) or off(0)
def setHumControl(cab=-1, state=1): def setHumControl(cab=-1, state=1):
sendCmd(EC_SET_HUM_CTRL, cab, state) sendCmd(EC_SET_HUM_CTRL, cab, state)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
printInfo('SetHumidityControl cab %d to %d' %(cab, state)) printInfo('SetHumidityControl cab %d to %d' %(cab, state))
#--------------------------------------- #---------------------------------------
def getVersion(): def getVersion():
sendCmd(EC_VERSION) sendCmd(EC_VERSION)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
version = int((PL[0]*100)+(PL[1]*10)+PL[2]) version = int((PL[0]*100)+(PL[1]*10)+PL[2])
printInfo('EC software version %d.%d.%d' %(PL)) printInfo('EC software version %d.%d.%d' %(PL))
return version return version
#--------------------------------------- #---------------------------------------
def getStatus(): def getStatus():
ec_mode = ('OFF','ON','AUTO','MANUAL','STARTUP','ABSENT') ec_mode = ('OFF','ON','AUTO','MANUAL','STARTUP','ABSENT')
fan = ('. . . .','. . . .','. 2 . .','1 2 . .',\ fan = ('. . . .','. . . .','. 2 . .','1 2 . .',\
'. . 3 .','. . . .','. 2 3 .','1 2 3 .',\ '. . 3 .','. . . .','. 2 3 .','1 2 3 .',\
'. . . .','. . . .','. . . .','. . . .',\ '. . . .','. . . .','. . . .','. . . .',\
'. . 3 4','. . . .','. 2 3 4','1 2 3 4') '. . 3 4','. . . .','. 2 3 4','1 2 3 4')
door = ('CLOSED','FRONT_OPEN','BACK_OPEN','ALL_OPEN') door = ('CLOSED','FRONT_OPEN','BACK_OPEN','ALL_OPEN')
onoff = ('OFF','ON') onoff = ('OFF','ON')
badok = ('BAD','OK') badok = ('BAD','OK')
# get information from EC # get information from EC
sendCmd(EC_CTRL_TEMP) sendCmd(EC_CTRL_TEMP)
(cmdId, status, PL1) = recvAck() (cmdId, status, PL1) = recvAck()
sendCmd(EC_STATUS) sendCmd(EC_STATUS)
(cmdId, status, PL2) = recvAck() (cmdId, status, PL2) = recvAck()
# fill lines with data # fill lines with data
lines = [] lines = []
lines.append(' |') lines.append(' |')
lines.append('mode |') lines.append('mode |')
lines.append('status |') lines.append('status |')
lines.append('set point |') lines.append('set point |')
lines.append('temperature |') lines.append('temperature |')
lines.append('humidity |') lines.append('humidity |')
lines.append('fans |') lines.append('fans |')
lines.append('doors |') lines.append('doors |')
lines.append('heater |') lines.append('heater |')
for cab in cabs: for cab in cabs:
lines[0] += ' cabinet %1d |' %(cab) lines[0] += ' cabinet %1d |' %(cab)
lines[1] += '%11s |' %(ec_mode[PL2[(cab*7)]]) lines[1] += '%11s |' %(ec_mode[PL2[(cab*7)]])
lines[2] += '%11X |' %(PL2[(cab*7)+1]) lines[2] += '%11X |' %(PL2[(cab*7)+1])
lines[3] += '%11.2f |' %(PL1[cab]/100.) lines[3] += '%11.2f |' %(PL1[cab]/100.)
lines[4] += '%11.2f |' %(PL2[(cab*7)+2]/100.) lines[4] += '%11.2f |' %(PL2[(cab*7)+2]/100.)
lines[5] += '%11.2f |' %(PL2[(cab*7)+3]/100.) lines[5] += '%11.2f |' %(PL2[(cab*7)+3]/100.)
lines[6] += '%11s |' %(fan[(PL2[(cab*7)+4]&0x0f)]) lines[6] += '%11s |' %(fan[(PL2[(cab*7)+4]&0x0f)])
lines[7] += '%11s |' %(door[(PL2[(cab*7)+5]&0x03)]) lines[7] += '%11s |' %(door[(PL2[(cab*7)+5]&0x03)])
if (cab != 3): if (cab != 3):
lines[8] += '%11s |' %('none') lines[8] += '%11s |' %('none')
else: else:
lines[8] += '%11s |' %(onoff[PL2[(cab*7)+6]]) lines[8] += '%11s |' %(onoff[PL2[(cab*7)+6]])
lines.append('power 48V state = %s' %(onoff[(PL2[28] & 1)])) lines.append('power 48V state = %s' %(onoff[(PL2[28] & 1)]))
lines.append('power LCU state = %s' %(onoff[(PL2[28] >> 1)])) lines.append('power LCU state = %s' %(onoff[(PL2[28] >> 1)]))
lines.append('lightning state = %s' %(badok[(PL2[29] & 1)])) lines.append('lightning state = %s' %(badok[(PL2[29] & 1)]))
# print lines to screen or file, see printInfo # print lines to screen or file, see printInfo
printInfo('=== Station status ===') printInfo('=== Station status ===')
for line in lines: for line in lines:
printInfo(line) printInfo(line)
printInfo(' ') printInfo(' ')
# print data to df if selected # print data to df if selected
if (printDataToFile == 1): if (printDataToFile == 1):
df = open("data.txt", mode='a') df = open("data.txt", mode='a')
for cab in cabs: for cab in cabs:
df.write(' %3.2f %3.2f %3.2f' %\ df.write(' %3.2f %3.2f %3.2f' %\
(PL1[cab]/100., PL2[(cab*7)+2]/100., PL2[(cab*7)+3]/100.)) (PL1[cab]/100., PL2[(cab*7)+2]/100., PL2[(cab*7)+3]/100.))
df.write('\n') df.write('\n')
df.close() df.close()
#--------------------------------------- #---------------------------------------
def getControlTemp(): def getControlTemp():
sendCmd(EC_CTRL_TEMP) sendCmd(EC_CTRL_TEMP)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
lines = [] lines = []
lines.append(' |') lines.append(' |')
lines.append('min control temp |') lines.append('min control temp |')
for cab in cabs: for cab in cabs:
lines[0] += ' cab-%1d |' %(cab) lines[0] += ' cab-%1d |' %(cab)
lines[1] += '%9.2f |' %(PL[cab]/100.) lines[1] += '%9.2f |' %(PL[cab]/100.)
#--------------------------------------- #---------------------------------------
def getSettings(): def getSettings():
sendCmd(EC_SETTINGS) sendCmd(EC_SETTINGS)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
# fill lines with data # fill lines with data
lines = [] lines = []
lines.append(' |') lines.append(' |')
lines.append('min control temp |') lines.append('min control temp |')
lines.append('max control temp |') lines.append('max control temp |')
lines.append('minmin temp |') lines.append('minmin temp |')
lines.append('maxmax temp |') lines.append('maxmax temp |')
lines.append('max humidity |') lines.append('max humidity |')
lines.append('maxmax humidity |') lines.append('maxmax humidity |')
lines.append('max day change |') lines.append('max day change |')
lines.append('control span |') lines.append('control span |')
for cab in cabs: for cab in cabs:
lines[0] += ' cab-%1d |' %(cab) lines[0] += ' cab-%1d |' %(cab)
lines[1] += '%9.2f |' %(PL[(cab*8)+0]/100.) lines[1] += '%9.2f |' %(PL[(cab*8)+0]/100.)
lines[2] += '%9.2f |' %(PL[(cab*8)+1]/100.) lines[2] += '%9.2f |' %(PL[(cab*8)+1]/100.)
lines[3] += '%9.2f |' %(PL[(cab*8)+2]/100.) lines[3] += '%9.2f |' %(PL[(cab*8)+2]/100.)
lines[4] += '%9.2f |' %(PL[(cab*8)+3]/100.) lines[4] += '%9.2f |' %(PL[(cab*8)+3]/100.)
lines[5] += '%9.2f |' %(PL[(cab*8)+4]/100.) lines[5] += '%9.2f |' %(PL[(cab*8)+4]/100.)
lines[6] += '%9.2f |' %(PL[(cab*8)+5]/100.) lines[6] += '%9.2f |' %(PL[(cab*8)+5]/100.)
lines[7] += '%9.2f |' %(PL[(cab*8)+6]/100.) lines[7] += '%9.2f |' %(PL[(cab*8)+6]/100.)
lines[8] += '%9.2f |' %(PL[(cab*8)+7]/100.) lines[8] += '%9.2f |' %(PL[(cab*8)+7]/100.)
# print lines to screen or file, see printInfo # print lines to screen or file, see printInfo
printInfo('=== Station settings ===') printInfo('=== Station settings ===')
for line in lines: for line in lines:
printInfo(line) printInfo(line)
printInfo(' ') printInfo(' ')
#--------------------------------------- #---------------------------------------
def setSettings(): def setSettings():
for i in range(4): for i in range(4):
sendCmd(EC_SET_MIN_TEMP, i, int(MinTemp[i]*100)) sendCmd(EC_SET_MIN_TEMP, i, int(MinTemp[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_MAX_TEMP, i, int(MaxTemp[i]*100)) sendCmd(EC_SET_MAX_TEMP, i, int(MaxTemp[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_MINMIN_TEMP, i, int(MinMinTemp[i]*100)) sendCmd(EC_SET_MINMIN_TEMP, i, int(MinMinTemp[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_MAXMAX_TEMP, i, int(MaxMaxTemp[i]*100)) sendCmd(EC_SET_MAXMAX_TEMP, i, int(MaxMaxTemp[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_MAX_HUM, i, int(MaxHum[i]*100)) sendCmd(EC_SET_MAX_HUM, i, int(MaxHum[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_MAXMAX_HUM, i, int(MaxMaxHum[i]*100)) sendCmd(EC_SET_MAXMAX_HUM, i, int(MaxMaxHum[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_CTRL_SPAN, i, int(ControlSpan[i]*100)) sendCmd(EC_SET_CTRL_SPAN, i, int(ControlSpan[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
sendCmd(EC_SET_MAX_CHANGE, i, int(MaxDayChange[i]*100)) sendCmd(EC_SET_MAX_CHANGE, i, int(MaxDayChange[i]*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
#--------------------------------------- #---------------------------------------
def checkFans(): def checkFans():
setMode(cab=-1, mode=MODE_ON) setMode(cab=-1, mode=MODE_ON)
# fans and vane check # fans and vane check
printInfo('\nFan and Vane check') printInfo('\nFan and Vane check')
setFans(-1,0) # turn off all fans setFans(-1,0) # turn off all fans
time.sleep(15.0) time.sleep(15.0)
# check all cabinets # check all cabinets
for cab in cabs: for cab in cabs:
# turn on fans in front door # turn on fans in front door
waitForSync() waitForSync()
setFans(cab,2) setFans(cab,2)
waitForSync() waitForSync()
setFans(cab,3) setFans(cab,3)
# check vane state # check vane state
waitForUpdate() waitForUpdate()
waitForUpdate() waitForUpdate()
sendCmd(EC_STATUS) sendCmd(EC_STATUS)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
if (PL[(cab * 7) + 4] & 0x10): if (PL[(cab * 7) + 4] & 0x10):
printInfo('Fans and vane of cab-%d front OK' %(cab)) printInfo('Fans and vane of cab-%d front OK' %(cab))
else: else:
printInfo('Fans or vane of cab-%d front NOT OK' %(cab)) printInfo('Fans or vane of cab-%d front NOT OK' %(cab))
setFans(-1,0) # turn off all fans setFans(-1,0) # turn off all fans
# turn on fans in back door # turn on fans in back door
waitForSync() waitForSync()
setFans(cab,4) setFans(cab,4)
waitForSync() waitForSync()
setFans(cab,12) setFans(cab,12)
# check vane state # check vane state
waitForUpdate() waitForUpdate()
waitForUpdate() waitForUpdate()
sendCmd(EC_STATUS) sendCmd(EC_STATUS)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
if (PL[(cab * 7) + 4] & 0x20): if (PL[(cab * 7) + 4] & 0x20):
printInfo('Fans and vane of cab-%d back OK\n' %(cab)) printInfo('Fans and vane of cab-%d back OK\n' %(cab))
else: else:
printInfo('Fans or vane of cab-%d back NOT OK\n' %(cab)) printInfo('Fans or vane of cab-%d back NOT OK\n' %(cab))
setFans(-1,0) # turn off all fans setFans(-1,0) # turn off all fans
setMode(cab=0, mode=MODE_AUTO) setMode(cab=0, mode=MODE_AUTO)
#--------------------------------------- #---------------------------------------
def checkDoors(): def checkDoors():
printInfo('\nDoor contact check') printInfo('\nDoor contact check')
printInfo('Close doors and press last doorcontact') printInfo('Close doors and press last doorcontact')
doorOpenCheck = 0 doorOpenCheck = 0
doorCloseCheck = 0 doorCloseCheck = 0
doorsOpen = 6 doorsOpen = 6
cycles = 0 cycles = 0
while ((doorsOpen > 0) and (cycles < 6)): while ((doorsOpen > 0) and (cycles < 6)):
doorsOpen = 0 doorsOpen = 0
waitForUpdate() waitForUpdate()
sendCmd(EC_STATUS) sendCmd(EC_STATUS)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
for cab in range(4): for cab in range(4):
if (cab == 2): if (cab == 2):
continue continue
if (PL[(cab * 7) + 5] & 1): if (PL[(cab * 7) + 5] & 1):
doorsOpen += 1 doorsOpen += 1
if (PL[(cab * 7) + 5] & 2): if (PL[(cab * 7) + 5] & 2):
doorsOpen += 1 doorsOpen += 1
cycles += 1 cycles += 1
printInfo('doors closed=%d' %(6 - doorsOpen)) printInfo('doors closed=%d' %(6 - doorsOpen))
if (doorsOpen == 0): if (doorsOpen == 0):
printInfo('all doors are closed, Open all doors') printInfo('all doors are closed, Open all doors')
doorCloseCheck = 1 doorCloseCheck = 1
else: else:
printInfo('not all doors are closed') printInfo('not all doors are closed')
doorsOpen = 0 doorsOpen = 0
cycles = 0 cycles = 0
while ((doorsOpen < 6) and (cycles < 6)): while ((doorsOpen < 6) and (cycles < 6)):
doorsOpen = 0 doorsOpen = 0
waitForUpdate() waitForUpdate()
sendCmd(EC_STATUS) sendCmd(EC_STATUS)
(cmdId, status, PL) = recvAck() (cmdId, status, PL) = recvAck()
for cab in range(4): for cab in range(4):
if (cab == 2): if (cab == 2):
continue continue
if (PL[(cab * 7) + 5] & 1): if (PL[(cab * 7) + 5] & 1):
doorsOpen += 1 doorsOpen += 1
if (PL[(cab * 7) + 5] & 2): if (PL[(cab * 7) + 5] & 2):
doorsOpen += 1 doorsOpen += 1
cycles += 1 cycles += 1
printInfo('doors open=%d' %(doorsOpen)) printInfo('doors open=%d' %(doorsOpen))
if (doorsOpen == 6): if (doorsOpen == 6):
printInfo('all doors are open') printInfo('all doors are open')
doorOpenCheck = 1 doorOpenCheck = 1
else: else:
printInfo('not all doors are open') printInfo('not all doors are open')
if (doorOpenCheck and doorCloseCheck): if (doorOpenCheck and doorCloseCheck):
printInfo('all door contacs OK\n') printInfo('all door contacs OK\n')
else: else:
printInfo('door contact failure\n') printInfo('door contact failure\n')
#--------------------------------------- #---------------------------------------
def checkRelayPanel(): def checkRelayPanel():
printInfo('\nRelay panel check') printInfo('\nRelay panel check')
resetPower(48) resetPower(48)
waitForUpdate() waitForUpdate()
waitForUpdate() waitForUpdate()
resetPower(230) resetPower(230)
waitForUpdate() waitForUpdate()
waitForUpdate() waitForUpdate()
# heater test # heater test
sendCmd(EC_SET_MINMIN_TEMP, 3, int(30.0*100)) sendCmd(EC_SET_MINMIN_TEMP, 3, int(30.0*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
printInfo("heater test") printInfo("heater test")
waitForUpdate() waitForUpdate()
waitForUpdate() waitForUpdate()
sendCmd(EC_SET_MINMIN_TEMP, 3, int(8.0*100)) sendCmd(EC_SET_MINMIN_TEMP, 3, int(8.0*100))
(cmdId, status, payload) = recvAck() (cmdId, status, payload) = recvAck()
printInfo('Relay panel check done\n') printInfo('Relay panel check done\n')
##======================================================================= ##=======================================================================
## start of main program ## start of main program
##======================================================================= ##=======================================================================
## do not delete next lines ## do not delete next lines
connectToHost() connectToHost()
time.sleep(1.0) time.sleep(1.0)
setSecond(int(time.gmtime()[5])) setSecond(int(time.gmtime()[5]))
# version is used to check if function is available in firmware # version is used to check if function is available in firmware
version = getVersion() version = getVersion()
## do not change if statements ## do not change if statements
if (doCheckRelayPanel == 1): if (doCheckRelayPanel == 1):
checkRelayPanel() checkRelayPanel()
if (doCheckFans == 1): if (doCheckFans == 1):
checkFans() checkFans()
if (doCheckDoors == 1): if (doCheckDoors == 1):
checkDoors() checkDoors()
if (doChangeSettings == 1): if (doChangeSettings == 1):
printInfo('Change control settings\nold settings') printInfo('Change control settings\nold settings')
getSettings() getSettings()
setSettings() setSettings()
printInfo('new settings') printInfo('new settings')
getSettings() getSettings()
printInfo('Done\n') printInfo('Done\n')
## end if statements ## end if statements
##----------------------------------------------------------------------- ##-----------------------------------------------------------------------
## playground ## playground
## cab = -1(all) or 0,1,3 ## cab = -1(all) or 0,1,3
## search for new temperature setpoint ## search for new temperature setpoint
#seekNewSetpoint() #seekNewSetpoint()
## set cab to mode ## set cab to mode
## mode = MODE_OFF, MODE_ON, MODE_AUTO, MODE_MANUAL, MODE_STARTUP ## mode = MODE_OFF, MODE_ON, MODE_AUTO, MODE_MANUAL, MODE_STARTUP
#setMode(cab=-1, mode=MODE_MANUAL) #setMode(cab=-1, mode=MODE_MANUAL)
## set cab to given temp, only posible in manual mode ## set cab to given temp, only posible in manual mode
#setTemperature(cab=-1,temp=25.0) #setTemperature(cab=-1,temp=25.0)
## set cab to auto ## set cab to auto
#setMode(cab=-1, mode=MODE_AUTO) #setMode(cab=-1, mode=MODE_AUTO)
## turn on fans of cab ## turn on fans of cab
## fans=bitfield(0000,0010,0011,0100,0110,0111,1100,1110,1111) ## fans=bitfield(0000,0010,0011,0100,0110,0111,1100,1110,1111)
## lsb = fan1 ## lsb = fan1
#setFans(cab=-1,fans=0x0c) #setFans(cab=-1,fans=0x0c)
## set door control on(1) or off(0) ## set door control on(1) or off(0)
#setDoorControl(cab=-1,state=1) #setDoorControl(cab=-1,state=1)
## get controller settings ## get controller settings
#getSettings() #getSettings()
## reset or set power for 48V or LCU ## reset or set power for 48V or LCU
#resetPower(48) #resetPower(48)
#resetPower(LCU) #resetPower(LCU)
#setPower(48,0) #setPower(48,0)
#setPower(LCU,0) #setPower(LCU,0)
stop = False stop = False
while (not stop): while (not stop):
waitForUpdate() waitForUpdate()
printInfo('====== %s ====================' %(time.asctime()) ) printInfo('====== %s ====================' %(time.asctime()) )
getStatus() getStatus()
##---------------------------------------------------------------------- ##----------------------------------------------------------------------
## do not delete next lines ## do not delete next lines
disconnectHost() disconnectHost()
closeFile() closeFile()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment