From 8c1105895d337eb7d53b9193ccae6fd44fe5c53d Mon Sep 17 00:00:00 2001 From: Menno Norden <norden@astron.nl> Date: Fri, 15 Apr 2011 14:11:41 +0000 Subject: [PATCH] bug 1315: remove old EC scripts --- .gitattributes | 4 - LCU/StationTest/test/envcontroltest/ecCtrl.py | 354 ---------- .../test/envcontroltest/eccontrol.py | 604 ------------------ LCU/StationTest/test/envcontroltest/power.py | 139 ---- .../test/envcontroltest/stations.py | 149 ----- 5 files changed, 1250 deletions(-) delete mode 100755 LCU/StationTest/test/envcontroltest/ecCtrl.py delete mode 100755 LCU/StationTest/test/envcontroltest/eccontrol.py delete mode 100755 LCU/StationTest/test/envcontroltest/power.py delete mode 100755 LCU/StationTest/test/envcontroltest/stations.py diff --git a/.gitattributes b/.gitattributes index f8fe5421d95..bb567669bcd 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1015,15 +1015,11 @@ LCU/StationTest/test/beamformertest/beamformertest_LBH_RCU96.sh eol=lf LCU/StationTest/test/beamformertest/beamformertest_LBL_RCU96.sh eol=lf LCU/StationTest/test/beamformertest/beamformertest_splitter.sh eol=lf LCU/StationTest/test/beamformertest/hba0_hba1_azel.sh eol=lf -LCU/StationTest/test/envcontroltest/ecCtrl.py eol=lf -LCU/StationTest/test/envcontroltest/eccontrol.py eol=lf LCU/StationTest/test/envcontroltest/isEcLib.py -text LCU/StationTest/test/envcontroltest/isReset48V.py -text LCU/StationTest/test/envcontroltest/isStatus.py -text LCU/StationTest/test/envcontroltest/nlEcLib.py -text LCU/StationTest/test/envcontroltest/nlStatus.py -text -LCU/StationTest/test/envcontroltest/power.py eol=lf -LCU/StationTest/test/envcontroltest/stations.py eol=lf LCU/StationTest/test/hbatest/beamduur.sh eol=lf LCU/StationTest/test/hbatest/determinepeak.py eol=lf LCU/StationTest/test/hbatest/gold/hba_modem1.gold eol=lf diff --git a/LCU/StationTest/test/envcontroltest/ecCtrl.py b/LCU/StationTest/test/envcontroltest/ecCtrl.py deleted file mode 100755 index 82642a1887a..00000000000 --- a/LCU/StationTest/test/envcontroltest/ecCtrl.py +++ /dev/null @@ -1,354 +0,0 @@ -#!/usr/bin/python - -from eccontrol import * -from stations import * -import sys -import time - -VERSION = '1.2.4' # version of this script - -## to use other commands, see playground on the bottom of this file - -##== change only next settings ==================================== - -printToScreen = 1 -printToFile = 0 -#printDataToFile = 0 # save setpoint, temp, humidity to data.txt - -# select test modes -doCheckRelayPanel = 0 -doCheckFans = 0 -doCheckDoors = 0 -doChangeSettings = 0 # fill in table below - -# settings for (cab0, cab1, cab2, cab3) -# for LOFAR NL stations cab2 is not available -# cab0 = rack with receiver 0, cab3 = always control rack -MaxHourChange= (0.50, 0.50, 0.50, 0.50) -StartSide = (1 , 1 , 1 , 0 ) -BalancePoint = (20 , 20 , 20 , 20 ) -SeekTime = (15 , 15 , 15 , 15 ) -SeekChange = (10.0, 10.0, 10.0, 10.0) -MinCtrlTemp = (10.0, 10.0, 10.0, 10.0) -MaxCtrlTemp = (35.0, 35.0, 35.0, 35.0) -HeaterTemp = (1.00, 1.00, 1.00, 8.00) -WarnTemp1 = (39.0, 39.0, 39.0, 39.0) -WarnTemp2 = (39.5, 39.5, 39.5, 39.5) -TripTemp = (40.0, 40.0, 40.0, 40.0) -MaxHum = (90.0, 90.0, 90.0, 80.0) -TripHum = (95.0, 95.0, 95.0, 85.0) -##================================================================== - - -if len(sys.argv) == 1: - print '--------------------------------------------' - print 'Error: no arguments found' - print '--------------------------------------------' - print '' - print 'usage power.py host' - print ' host = this (get IP based on LCU)' - print ' host = ip (set ip manualy)' - print '' - print '--------------------------------------------' - print '' - exit(0) - -Station = str(sys.argv[1]) - -station = STATION() -stations = station.ec(Station) - -#host = '10.87.2.239' -#station = host - - -# used variables -version = 0 # EC version -versionstr = 'V-.-.-' - - -#--------------------------------------- -# open files if needed -if (printToFile == 1): - #(hostname, aliaslist, ipaddrlist) = socket.gethostbyaddr(HOST) - #stationname = hostname.split('.')[0] - #print stationname - filename = "tempctrl.txt" - f = open(filename, mode='w') -#--------------------------------------- -def closeFile(): - if (printToFile == 1): - f.close() -#--------------------------------------- -# print information to screen or file -def printInfo(info): - if (printToScreen == 1): - print info - - if (printToFile == 1): - f.write(info) - f.write('\n') -#--------------------------------------- -def setSettings(): - for i in range(4): - ec.setSetting(ec.SET_MAX_CHANGE, i, int(MaxHourChange[i]*100)) - ec.setSetting(ec.SET_START_SIDE, i, int(StartSide[i])) - ec.setSetting(ec.SET_BALANCE_POINT, i, int(BalancePoint[i])) - ec.setSetting(ec.SET_SEEK_TIME, i, int(SeekTime[i])) - ec.setSetting(ec.SET_SEEK_CHANGE, i, int(SeekChange[i]*100)) - ec.setSetting(ec.SET_MIN_CTRL_TEMP, i, int(MinCtrlTemp[i]*100)) - ec.setSetting(ec.SET_MAX_CTRL_TEMP, i, int(MaxCtrlTemp[i]*100)) - ec.setSetting(ec.SET_HEATER_TEMP, i, int(HeaterTemp[i]*100)) - ec.setSetting(ec.SET_WARN1_TEMP, i, int(WarnTemp1[i]*100)) - ec.setSetting(ec.SET_WARN2_TEMP, i, int(WarnTemp2[i]*100)) - ec.setSetting(ec.SET_TRIP_TEMP, i, int(TripTemp[i]*100)) - ec.setSetting(ec.SET_MAX_HUM, i, int(MaxHum[i]*100)) - ec.setSetting(ec.SET_TRIP_HUM, i, int(TripHum[i]*100)) - - -#--------------------------------------- -def checkFans(): - setMode(cab=-1, mode=MODE_ON) - # fans and vane check - printInfo('\nFan and Vane check') - setFans(-1,0) # turn off all fans - time.sleep(15.0) - - # check all cabinets - for cab in cabs: - # turn on fans in front door - waitForSync() - setFans(cab,2) - waitForSync() - setFans(cab,3) - - # check vane state - waitForUpdate() - waitForUpdate() - sendCmd(EC_STATUS) - (cmdId, status, PL) = recvAck() - if (PL[(cab * 7) + 4] & 0x10): - printInfo('Fans and vane of cab-%d front OK' %(cab)) - else: - printInfo('Fans or vane of cab-%d front NOT OK' %(cab)) - setFans(-1,0) # turn off all fans - - # turn on fans in back door - waitForSync() - setFans(cab,4) - waitForSync() - setFans(cab,12) - - # check vane state - waitForUpdate() - waitForUpdate() - sendCmd(EC_STATUS) - (cmdId, status, PL) = recvAck() - if (PL[(cab * 7) + 4] & 0x20): - printInfo('Fans and vane of cab-%d back OK\n' %(cab)) - else: - printInfo('Fans or vane of cab-%d back NOT OK\n' %(cab)) - setFans(-1,0) # turn off all fans - setMode(cab=0, mode=MODE_AUTO) -#--------------------------------------- -def checkDoors(): - printInfo('\nDoor contact check') - printInfo('Close doors and press last doorcontact') - - doorOpenCheck = 0 - doorCloseCheck = 0 - - doorsOpen = 6 - cycles = 0 - while ((doorsOpen > 0) and (cycles < 6)): - doorsOpen = 0 - waitForUpdate() - sendCmd(EC_STATUS) - (cmdId, status, PL) = recvAck() - for cab in range(4): - if (cab == 2): - continue - if (PL[(cab * 7) + 5] & 1): - doorsOpen += 1 - if (PL[(cab * 7) + 5] & 2): - doorsOpen += 1 - cycles += 1 - printInfo('doors closed=%d' %(6 - doorsOpen)) - if (doorsOpen == 0): - printInfo('all doors are closed, Open all doors') - doorCloseCheck = 1 - else: - printInfo('not all doors are closed') - - doorsOpen = 0 - cycles = 0 - while ((doorsOpen < 6) and (cycles < 6)): - doorsOpen = 0 - waitForUpdate() - sendCmd(EC_STATUS) - (cmdId, status, PL) = recvAck() - for cab in range(4): - if (cab == 2): - continue - if (PL[(cab * 7) + 5] & 1): - doorsOpen += 1 - if (PL[(cab * 7) + 5] & 2): - doorsOpen += 1 - - cycles += 1 - printInfo('doors open=%d' %(doorsOpen)) - if (doorsOpen == 6): - printInfo('all doors are open') - doorOpenCheck = 1 - else: - printInfo('not all doors are open') - - - if (doorOpenCheck and doorCloseCheck): - printInfo('all door contacs OK\n') - else: - printInfo('door contact failure\n') -#--------------------------------------- -def checkRelayPanel(): - printInfo('\nRelay panel check') - # heater test - setHeater(1) - printInfo("heater test") - waitForUpdate() - waitForUpdate() - setHeater(0) - # power switch test - resetPower(48) - waitForUpdate() - waitForUpdate() - resetPower(230) - waitForUpdate() - waitForUpdate() - printInfo('Relay panel check done\n') - - - -##======================================================================= -## start of main program -##======================================================================= -## do not delete next lines -if __name__ == '__main__': - for station in stations: - host = station -# (hostname, aliaslist, ipaddrlist) = socket.gethostbyaddr(host) -# stationname = hostname.split('.')[0] -# print stationname - print host - nCabs = 3 - if host.find('10.209') != -1: - nCabs = 4 - - ec = EC(host,nCabs) - ec.connectToHost() - - ec.printInfo(True) - ec.printFile(False) - - time.sleep(1.0) - ## synchronize EC and PC - #ec.setSecond(int(time.gmtime()[5])) - # version is used to check if function is available in firmware - version,versionstr = ec.getVersion() - type, wxt50 = ec.getStationInfo() -## do not change if statements - if (doCheckFans == 1): - checkFans() - if (doCheckDoors == 1): - checkDoors() - if (doCheckRelayPanel == 1): - checkRelayPanel() - if (doChangeSettings == 1): - printInfo('Change control settings\nold settings') - ec.getSettings() - setSettings() - printInfo('new settings') - ec.getSettings() - printInfo('Done\n') - ## end if statements - ##----------------------------------------------------------------------- - ## playground - ## cab = -1(all) or 0,1,3 - stop = False - ## set cab to mode, default=MODE_AUTO - ## mode = MODE_OFF, MODE_ON, MODE_AUTO, MODE_MANUAL, MODE_STARTUP, MODE_SEEK - ## MODE_STARTUP and MODE_SEEK will automatically return to MODE_AUTO - #ec.setControlMode(cab=-1, mode=ec.MODE_MANUAL) - #ec.setControlMode(cab=-1, mode=ec.MODE_OFF) - #ec.setControlMode(cab=-1, mode=ec.MODE_ON) - - ## set cab to given temp, only posible in MODE_MANUAL - #ec.setTemperature(cab=0,temp=33.78) - #ec.setTemperature(cab=1,temp=30.53) - #ec.setTemperature(cab=3,temp=26.97) - #ec.setTemperature(cab=-1,temp=12.00) - - ## search for new temperature setpoint - #ec.seekNewSetpoint() - - ## turn on fans of cab, only possible in MODE_ON - ## fans=bitfield(0000,0010,0011,0100,0110,0111,1100,1110,1111) - ## lsb = fan1 - #ec.setFans(cab=-1,fans=0x0c) - #ec.setFans(cab=3,fans=0x0f) - - ## set door control on(1) or off(0) - #ec.setDoorControl(cab=-1,state=1) - #ec.setDoorControl(cab=1,state=0) - - ## set humidity control on(1) or off(0) - #ec.setHumControl(cab=-1,state=1) - - ## reset or set power for 48V or LCU - #ec.resetPower(48) - #ec.resetPower(LCU) - #ec.setPower(48,1) - #ec.setPower(LCU,1) - - ## set Heater mode default=MODE_AUTO - ## mode = MODE_OFF | MODE_ON | MODE_AUTO - #ec.setHeater(ec.MODE_AUTO) - - ## restart controller, works from EC version 1.0.7 - #if ec.restart() == 1: stop = True - - ## reset trip system - #ec.resetTrip() - - ## set cab to mode, default=MODE_AUTO - ## mode = MODE_OFF, MODE_ON, MODE_AUTO, MODE_MANUAL, MODE_STARTUP, MODE_SEEK - ## MODE_STARTUP and MODE_SEEK will automatically return to MODE_AUTO - #ec.setControlMode(cab=-1, mode=ec.MODE_AUTO) - #ec.setControlMode(cab=-1, mode=ec.MODE_STARTUP) - - ## get controller settings - #ec.getSettings() - #setSettings() - #ec.getSettings() - #ec.getSensorSettings() - #ec.setSetting(ec.SET_HUM_MULT,0,118) - #ec.setSetting(ec.SET_HUM_MULT,1,118) - #ec.setSetting(ec.SET_HUM_MULT,3,118) - #ec.setSetting(ec.SET_HUM_MULT,0,100) - #ec.setSetting(ec.SET_HUM_MULT,1,100) - #ec.setSetting(ec.SET_HUM_MULT,3,100) -# ec.getStatus() - ec.getSensorSettings() - #stop = False - #stop = True - while (not stop): - #ec.waitForUpdate() - ec.getStatus() - time.sleep(10.0) - - ##---------------------------------------------------------------------- - ## do not delete next lines - ec.disconnectHost() - if (printToFile == 1): - closeFile() - - diff --git a/LCU/StationTest/test/envcontroltest/eccontrol.py b/LCU/StationTest/test/envcontroltest/eccontrol.py deleted file mode 100755 index e41fb66b51f..00000000000 --- a/LCU/StationTest/test/envcontroltest/eccontrol.py +++ /dev/null @@ -1,604 +0,0 @@ -## P.Donker ASTRON februari 2010 -## EC control module - -import socket -import struct -import time - -class EC: - # cmdIDs from TCP PROTOCOL ec-controller - EC_NONE = 0 - EC_STATUS = 1 - EC_SETTINGS = 2 - EC_CTRL_TEMP = 3 - EC_VERSION = 5 - EC_STATION_INFO = 6 - EC_SET_CTRL_MODE = 10 - EC_SET_FANS = 11 - EC_SET_TEMP = 15 - EC_SET_HEATER = 17 - EC_SET_48 = 20 - EC_RESET_48 = 22 - EC_SET_230 = 25 - EC_RESET_230 = 27 - EC_RESET_TRIP = 28 - EC_SET_DOOR_CTRL = 50 - EC_SET_HUM_CTRL = 52 - EC_SET_SECOND = 115 - - SET_MAX_CTRL_TEMP = 150 - SET_MIN_CTRL_TEMP = 151 - SET_WARN1_TEMP = 152 - SET_WARN2_TEMP = 153 - SET_TRIP_TEMP = 154 - SET_HEATER_TEMP = 155 - SET_MAX_HUM = 160 - SET_TRIP_HUM = 161 - SET_START_SIDE = 170 - SET_BALANCE_POINT = 171 - SET_MAX_CHANGE = 172 - SET_SEEK_TIME = 173 - SET_SEEK_CHANGE = 174 - - SET_TEMP_OFFSET = 180 - SET_TEMP_MULT = 181 - SET_HUM_OFFSET = 182 - SET_HUM_MULT = 183 - SENSOR_SETTINGS = 184 - SET_LOG = 1111 - FLASH_ERASE = 2330 - FLASH_WRITE = 2331 - RESTART = 2440 - - MODE_OFF = 0 - MODE_ON = 1 - MODE_AUTO = 2 - MODE_MANUAL = 3 - MODE_STARTUP = 4 - MODE_SEEK = 5 - PWR_OFF = 0 - PWR_ON = 1 - P48 = 48 - LCU = 230 - - printToScreen = False - printToFile = False - cabs = None - nCabs = None - host = None - station = None - port = 10000 - sck = None - logger = False - info = '' - version = 0 - versionstr = 'V-.-.-' - - def __init__(self, addr='0.0.0.0', nCabs=3): - self.nCabs = nCabs - if nCabs == 1: self.cabs = [0] - if nCabs == 3: self.cabs = [0,1,3] - if nCabs == 4: self.cabs = [0,1,2,3] - self.host = addr - try: - (hostname,a,b) = socket.gethostbyaddr(addr) - self.station = hostname.split('.')[0] - except: - self.station = 'Unknown' - - def setInfo(self, info): - self.info = info - if self.printToScreen: - print self.info - self.info = '' - else: self.info += '\n' - return - - def addInfo(self, info): - self.info += info - if self.printToScreen: - print self.info - self.info = '' - else: self.info += '\n' - return - - def printInfo(self, state=True): - self.printToScreen = state - return - - def printFile(self, state=True): - self.printToFile = state - return - - def hex2bit(self, val=0, bits=16): - bit = '' - for i in range(bits-1,-1,-1): - if val & (1 << i): - bit += '1' - else: - bit += '0' - return(bit) - - #--------------------------------------- - def connectToHost(self): - self.setInfo("connecting to %s on port %d" %(self.host, self.port)) - connected = False - - try: - self.sck = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - except socket.error: - self.sck.close() - return(connected) - - try: - self.sck.settimeout(3.0) - self.sck.connect((self.host, self.port)) - connected = True - #time.sleep(0.1) - except socket.error: - self.sck.close() - return(connected) - - #--------------------------------------- - def disconnectHost(self): - self.setInfo("closing %s" %(self.host)) - self.sck.close() - #time.sleep(0.1) - return - - #--------------------------------------- - def sendCmd(self, cmdId=0, cab=-1, value=0): - if (cmdId == self.EC_NONE): - return (false) - try: - cmd = struct.pack('hhh', cmdId, cab, int(value)) - self.sck.send(cmd) - except socket.error: - self.setInfo("socket error, try to reconnect") - self.disconnectHost() - time.sleep(10.0) - self.connectToHost() - return - #--------------------------------------- - def recvAck(self): - socketError = False - try: - self.sck.settimeout(1.0) - data = self.sck.recv(6) - except socket.error: - socketError = True - self.setInfo("socket error, try to reconnect") - #self.disconnectHost() - #self.connectToHost() - if socketError: - return(0,0,[]) - - header = struct.unpack('hhh', data) - cmdId = header[0] - status = header[1] - PLSize = header[2] - if (PLSize > 0): - data = self.sck.recv(PLSize) - fmt = 'h' * int(PLSize / 2) - PL = struct.unpack(fmt, data) - else: - PL = [] - return (cmdId, status, PL) - #--------------------------------------- - def recvLog(self): - socketError = False - try: - self.sck.settimeout(10.0) - data = self.sck.recv(200) - except socket.error: - socketError = True - if socketError: - return - print str(data).replace('\r',''), - return - - #--------------------------------------- - def setSecond(self, sec=0): - self.sendCmd(self.EC_SET_SECOND, 0, sec) - (cmdId, status, PL) = self.recvAck() - return - #--------------------------------------- - def waitForSync(self): - while ((time.gmtime()[5] % 10) != 7): - time.sleep(0.5) - time.sleep(1.0) - return - #--------------------------------------- - def waitForUpdate(self): - while ((time.gmtime()[5] % 10) != 3): - time.sleep(0.5) - time.sleep(1.0) - return - #--------------------------------------- - def setLogger(self, level=0): - if (self.version >= 150): - self.setInfo('EC set logger to level %d' %(level)) - self.sendCmd(self.SET_LOG, 0, level) - #(cmdId, status, PL) = self.recvAck() - return - else: - self.setInfo('setting log level not possible in this EC version') - return - #--------------------------------------- - - def restart(self): - if (self.version >= 107) or (self.version == 1): - self.setInfo('EC restart') - if self.version < 110: - self.sendCmd(211) - elif self.version < 141: - self.sendCmd(210) - else: - self.sendCmd(self.RESTART) - time.sleep(2.0) - #(cmdId, status, PL) = self.recvAck() - return 1 - else: - self.setInfo('restart not possible in this EC version') - return 0 - #--------------------------------------- - def setControlMode(self, cab=-1, mode=MODE_AUTO): - self.sendCmd(self.EC_SET_CTRL_MODE, cab, mode) - (cmdId, status, PL) = self.recvAck() - self.setInfo('SetControlMode cab %d to %d' %(cab, mode)) - return - #--------------------------------------- - def setPower(self, pwr=-1, state=PWR_ON): - if ((pwr == self.P48) or (pwr == -1)): - self.sendCmd(self.EC_SET_48, 0, state) - (cmdId, status, PL) = self.recvAck() - self.setInfo('Power Set 48V to %d' %(state)) - if ((pwr == self.LCU) or (pwr == -1)): - self.sendCmd(self.EC_SET_230, 0, state) - (cmdId, status, PL) = self.recvAck() - self.setInfo('Power Set LCU to %d' %(state)) - return - #--------------------------------------- - def resetPower(self, pwr=-1): - if ((pwr == self.P48) or (pwr == -1)): - self.sendCmd(self.EC_RESET_48, 0, 0) - (cmdId, status, PL) = self.recvAck() - self.setInfo('PowerReset 48V') - if ((pwr == self.LCU) or (pwr == -1)): - self.sendCmd(self.EC_RESET_230, 0, 0) - (cmdId, status, PL) = self.recvAck() - self.setInfo('PowerReset LCU') - - #--------------------------------------- - def resetTrip(self): - self.sendCmd(self.EC_RESET_TRIP, -1, 0) - (cmdId, status, PL) = self.recvAck() - self.setInfo('Reset Trip System') - - #--------------------------------------- - ## search for new setpoint, works only in control mmode 1 - def seekNewSetpoint(self, cab=-1): - self.sendCmd(self.EC_SET_MODE, cab, MODE_SEEK) - (cmdId, status, PL) = self.recvAck() - self.setInfo('Find newSetpoint cab %d' %(cab)) - #--------------------------------------- - ## set new setpoint, works only in manual mode - def setTemperature(self, cab=-1, temp=20.0): - temperature = int(temp * 100.) - self.sendCmd(self.EC_SET_TEMP, cab, temperature) - (cmdId, status, PL) = self.recvAck() - self.setInfo('SetTemperature cab %d to %4.2f' %(cab,temp)) - #--------------------------------------- - ## set new setpoint, works only in manual mode - def setFans(self, cab=-1, fans=0x0f): - self.sendCmd(self.EC_SET_FANS, cab, fans) - (cmdId, status, PL) = self.recvAck() - self.setInfo('SetFans cab %d to %X' %(cab,fans)) - #--------------------------------------- - ## set door control to on(1) or off(0) - def setDoorControl(self, cab=-1, state=1): - self.sendCmd(self.EC_SET_DOOR_CTRL, cab, state) - (cmdId, status, PL) = self.recvAck() - self.setinfo('SetDoorControl cab %d to %d' %(cab, state)) - #--------------------------------------- - ## set hum control to on(1) or off(0) - def setHumControl(self, cab=-1, state=1): - self.sendCmd(self.EC_SET_HUM_CTRL, cab, state) - (cmdId, status, PL) = self.recvAck() - self.setInfo('SetHumidityControl cab %d to %d' %(cab, state)) - #--------------------------------------- - def setHeater(self, mode=0): - self.sendCmd(self.EC_SET_HEATER, -1, mode) - (cmdId, status, payload) = self.recvAck() - - if (mode == self.MODE_ON): self.setInfo('heater is turned ON') - if (mode == self.MODE_OFF): self.setInfo('heater is turned OFF') - if (mode == self.MODE_AUTO): self.setInfo('heater set to AUTO') - #--------------------------------------- - def getVersion(self): - self.sendCmd(self.EC_VERSION) - (cmdId, status, PL) = self.recvAck() - - version = int((PL[0]*100)+(PL[1]*10)+PL[2]) - versionstr = 'V%d.%d.%d' %(PL) - self.version = version - self.versionstr = versionstr - self.setInfo('EC software version %d.%d.%d' %(PL)) - return version, versionstr - #--------------------------------------- - - def getStationInfo(self): - stationType = ('Unknown','NAA','Unknown','LOFAR NL','LOFAR IS','Unknown') - self.sendCmd(self.EC_STATION_INFO) - (cmdId, status, PL) = self.recvAck() - - type = int(PL[0]) - wxt520 = int(PL[1]) - self.stationtype = type - self.wxt520present = wxt520 - self.setInfo('station type=%s, wxt520=%d' %(stationType[type],wxt520)) - return type, wxt520 - #--------------------------------------- - def getStatus(self): - ec_mode = ('OFF','ON','AUTO','MANUAL','STARTUP','AUTO-SEEK','ABSENT') - fan = ('. . . .','. . . .','. 2 . .','1 2 . .',\ - '. . 3 .','. . . .','. 2 3 .','1 2 3 .',\ - '. . . .','. . . .','. . . .','. . . .',\ - '. . 3 4','. . . .','. 2 3 4','1 2 3 4') - - door = ('CLOSED','FRONT_OPEN','BACK_OPEN','ALL_OPEN') - fanstate = ('BAD | BAD ','GOOD| BAD ','BAD | GOOD','GOOD| GOOD') - fanestate= ('OFF | OFF ','ON | OFF ','OFF | ON ','ON | ON ') - onoff = ('OFF','ON') - badok = ('N.A.','OK') - - # get information from EC - self.sendCmd(self.EC_CTRL_TEMP) - (cmdId, status, PL1) = self.recvAck() - self.sendCmd(self.EC_STATUS) - (cmdId, status, PL2) = self.recvAck() - if len(PL1) == 0 or len(PL2) == 0: return - # fill lines with data - lines = [] - - if self.nCabs == 4: - lines.append('temperature cab3 = %5.2f' %(PL2[2]/100.)) - lines.append('humidity cab3 = %5.2f' %(PL2[3]/100.)) - lines.append('cabinet fans = all on') - lines.append('heater state = %s' %(onoff[PL2[(3*7)+6]])) - lines.append('power 48V 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)])) - - else: - lines.append(' |') - lines.append('mode |') - lines.append('status |') - lines.append('set point |') - lines.append('temperature |') - lines.append('humidity |') - lines.append('fans |') - lines.append('fane |') - lines.append('fans state |') - lines.append('doors |') - lines.append('heater |') - - for nCab in range(self.nCabs): - cab = self.cabs[nCab] - lines[0] += ' cabinet %1d |' %(cab) - lines[1] += '%11s |' %(ec_mode[PL2[(cab*7)]]) - lines[2] += ' %#06x |' %(PL2[(cab*7)+1]) - lines[3] += '%11.2f |' %(PL1[cab]/100.) - lines[4] += '%11.2f |' %(PL2[(cab*7)+2]/100.) - lines[5] += '%11.2f |' %(PL2[(cab*7)+3]/100.) - lines[6] += '%11s |' %(fan[(PL2[(cab*7)+4]&0x0f)]) - lines[7] += '%11s |' %(fanestate[(PL2[(cab*7)+4]>>4)&0x3]) - lines[8] += '%11s |' %(fanstate[(PL2[(cab*7)+4]>>6)&0x3]) - lines[9] += '%11s |' %(door[(PL2[(cab*7)+5]&0x03)]) - if (cab != 3): - lines[10] += '%11s |' %('none') - else: - lines[10] += '%11s |' %(onoff[PL2[(cab*7)+6]]) - - if self.nCabs == 1: i = 7 - else: i = 28 - lines.append('power 48V state = %s' %(onoff[(PL2[i] & 1)])) - lines.append('power LCU state = %s' %(onoff[(PL2[i] >> 1)])) - lines.append('lightning state = %s' %(badok[(PL2[i+1] & 1)])) - - # print lines to screen or file, see printInfo - info = 'status %s (%s) %s ' %(self.station, self.versionstr, time.asctime()) - self.setInfo('-' * len(info)) - self.addInfo(info) - self.addInfo('-' * len(info)) - for line in lines: - self.addInfo(line) - # print data to file if selected - if (self.printToFile == 1): - tm = time.gmtime() - filename = '%s_%d%02d%02d.dat' %(self.station,tm.tm_year, tm.tm_mon, tm.tm_mday) - df = open(filename, mode='a') - df.write('%f ' %(time.time())) - for cab in self.cabs: - # print cabnr, setpoint, temperature, humidity, fansstate, heaterstate - df.write('[%d] %3.2f %3.2f %3.2f %d %d ' %\ - ( cab, PL1[cab]/100., PL2[(cab*7)+2]/100., PL2[(cab*7)+3]/100., - PL2[(cab*7)+4], PL2[(cab*7)+6])) - df.write('\n') - df.close() - #--------------------------------------- - def getTripStatus(self): - # get information from EC - self.sendCmd(self.EC_STATUS) - (cmdId, status, PL) = self.recvAck() - state = False - if (PL[1] & 0x1000): - self.addInfo('trip in cabinet 0') - state = True - if (PL[8] & 0x1000): - self.addInfo('trip in cabinet 1') - state = True - if (PL[22] & 0x1000): - self.addInfo('trip in cabinet 3') - state = True - - if (PL[1] & 0x6000): - self.addInfo('warning in cabinet 0') - state = True - if (PL[8] & 0x6000): - self.addInfo('warning in cabinet 1') - state = True - if (PL[22] & 0x6000): - self.addInfo('warning in cabinet 3') - state = True - - if (state == False): - self.addInfo('NO trips available') - return(state) - - #--------------------------------------- - def getPowerStatus(self): - state = ('OFF','ON') - # get information from EC - self.sendCmd(self.EC_STATUS) - (cmdId, status, PL) = self.recvAck() - - self.addInfo('Power: 48V = %s, LCU = %s' %(state[(PL[28] & 1)], state[(PL[28] >> 1)])) - - #--------------------------------------- - def getControlTemp(self): - self.sendCmd(self.EC_CTRL_TEMP) - (cmdId, status, PL) = self.recvAck() - lines = [] - lines.append(' |') - lines.append('min control temp |') - - for cab in self.cabs: - lines[0] += ' cab-%1d |' %(cab) - lines[1] += '%9.2f |' %(PL[cab]/100.) - #--------------------------------------- - def getSettings(self): - self.sendCmd(self.EC_SETTINGS) - (cmdId, status, PL) = self.recvAck() - #self.info = len(PL)) - # fill lines with data - lines = [] - lines.append(' |') - lines.append('start side |') - lines.append('balance point |') - lines.append('max hour change |') - lines.append('seek time |') - lines.append('max seek change |') - lines.append('min control temp |') - lines.append('max control temp |') - lines.append('heater temp |') - lines.append('warn1 temp |') - lines.append('warn2 temp |') - lines.append('trip temp |') - lines.append('max humidity |') - lines.append('trip humidity |') - - - for nCab in range(self.nCabs): - cab = self.cabs[nCab] - lines[0] += ' cab-%1d |' %(cab) - lines[1] += '%9d |' %(PL[(cab*13)+10]) - lines[2] += '%9d |' %(PL[(cab*13)+9]) - lines[3] += '%9.2f |' %(PL[(cab*13)+8]/100.) - lines[4] += '%9d |' %(PL[(cab*13)+11]) - lines[5] += '%9.2f |' %(PL[(cab*13)+12]/100.) - lines[6] += '%9.2f |' %(PL[(cab*13)+0]/100.) - lines[7] += '%9.2f |' %(PL[(cab*13)+1]/100.) - lines[8] += '%9.2f |' %(PL[(cab*13)+2]/100.) - lines[9] += '%9.2f |' %(PL[(cab*13)+3]/100.) - lines[10] += '%9.2f |' %(PL[(cab*13)+4]/100.) - lines[11] += '%9.2f |' %(PL[(cab*13)+5]/100.) - lines[12] += '%9.2f |' %(PL[(cab*13)+6]/100.) - lines[13] += '%9.2f |' %(PL[(cab*13)+7]/100.) - - # print lines to screen or file, see printInfo - self.addInfo('=== Station settings ===') - for line in lines: - self.addInfo(line) - - #--------------------------------------- - def setSetting(self, cmd=0, cab=-1, val=0): - self.sendCmd(cmd, cab, val) - (cmdId, status, PL) = self.recvAck() - - #--------------------------------------- - def getSensorSettings(self): - self.sendCmd(self.SENSOR_SETTINGS) - (cmdId, status, PL) = self.recvAck() - #self.info = len(PL)) - # fill lines with data - lines = [] - lines.append(' |') - lines.append('temperature offset |') - lines.append('temperature multiply |') - lines.append('humidity offset |') - lines.append('humidity multiply |') - - for nCab in range(self.nCabs): - cab = self.cabs[nCab] - lines[0] += ' cab-%1d |' %(cab) - lines[1] += '%9.2f |' %(PL[(cab*4)+0]/100.) - lines[2] += '%9.2f |' %(PL[(cab*4)+1]/100.) - lines[3] += '%9.2f |' %(PL[(cab*4)+2]/100.) - lines[4] += '%9.2f |' %(PL[(cab*4)+3]/100.) - - # print lines to screen or file, see printInfo - self.addInfo('=== Station sensor settings ===') - for line in lines: - self.addInfo(line) - return(PL) - - #--------------------------------------- - def sendFlashEraseCmd(self): - try: - if (self.version < 141): - cmd = struct.pack('hHH', 200, 0, 0) - else: - cmd = struct.pack('hHH', self.FLASH_ERASE, 0, 0) - self.sck.send(cmd) - except socket.error: - self.setInfo("socket error, try to reconnect") - self.disconnectHost() - self.connectToHost() - return - #--------------------------------------- - def sendFlashWriteCmd(self, sector=0, offset=0, data=''): - try: - if (self.version < 141): - cmd = struct.pack('hHH', 201, sector, offset) - else: - cmd = struct.pack('hHH', self.FLASH_WRITE, sector, offset) - if (len(data) > 0): - if (len(data) < 1024): - data = data + ('\xFF' * (1024 - len(data))) - cmd = cmd + data - self.sck.send(cmd) - except socket.error: - self.setInfo("socket error, try to reconnect") - self.disconnectHost() - self.connectToHost() - return - #--------------------------------------- - def recvFlashAck(self): - socketError = False - try: - self.sck.settimeout(5.0) - data = self.sck.recv(4) - except socket.error: - socketError = True - self.setInfo("socket error, try to reconnect") - self.disconnectHost() - self.connectToHost() - if socketError: - return(0,-1) - - header = struct.unpack('hh', data) - cmdId = header[0] - status = header[1] - return (cmdId, status) - diff --git a/LCU/StationTest/test/envcontroltest/power.py b/LCU/StationTest/test/envcontroltest/power.py deleted file mode 100755 index d0b9da25332..00000000000 --- a/LCU/StationTest/test/envcontroltest/power.py +++ /dev/null @@ -1,139 +0,0 @@ -#!/usr/bin/python - -## LOFAR script -## for reset, turn on or off the power to 48V or LCU -## P.Donker (ASTRON) 20-10-2009 - - -## DO NOT CHANGE THINGS BELOW THIS LINE ## -## ------------------------------------ ## - -from stations import * -from eccontrol import * -#import socket -import time -import struct -import sys -import string - -VERSION = '1.0.1' # version of this script - -if len(sys.argv) < 3: - print '--------------------------------------------' - print 'Error: no arguments found' - print '--------------------------------------------' - print 'usage power.py host cmd' - print ' host = this (get IP based on LCU)' - print ' host = ip (set ip manualy)' - print ' cmd = status (show status)' - print ' cmd = resetTrip (reset temperature trip system)' - print ' cmd = reset48 (reset 48V power supply)' - print ' cmd = resetLCU (reset LCU power supply)' - print ' cmd = on48 (turn on 48V power supply)' - print ' cmd = off48 (turn off 48V power supply)' - print ' cmd = onLCU (turn on LCU power supply)' - print ' cmd = offLCU (turn off LCU power supply)' - print '*only 1 cmd per power supply can be given' - print '--------------------------------------------' - exit(0) - - -doResetTrip = 0 -# select only 1 -doReset48V = 0 -doPowerOn48V = 0 -doPowerOff48V = 0 -# select only 1 -doResetLCU = 0 -doPowerOnLCU = 0 -doPowerOffLCU = 0 - -Station = sys.argv[1] - -for arg in sys.argv[2:]: - cmd = str(arg) - if cmd == 'resetTrip': - doResetTrip = 1 - if cmd == 'reset48': - doReset48V = 1 - if cmd == 'resetLCU': - doResetLCU = 1 - if cmd == 'on48': - doPowerOn48V = 1 - if cmd == 'off48': - doPowerOff48V = 1 - if cmd == 'onLCU': - doPowerOnLCU = 1 - if cmd == 'offLCU': - doPowerOffLCU = 1 - -##======================================================================= -## start of main program -##======================================================================= -if __name__ == "__main__": - logfile = open('ecPowerActions.log','a') - - if doResetTrip or doReset48V or doResetLCU: - name = raw_input('Enter your personal name: ') - if doPowerOn48V or doPowerOff48V or doPowerOnLCU or doPowerOffLCU: - name = raw_input('Enter your personal name: ') - - stations = STATION() - - if ((doReset48V + doPowerOn48V + doPowerOff48V) > 1): - print 'error more than 1 48V cmd selected' - exit(-1) - if ((doResetLCU + doPowerOnLCU + doPowerOffLCU) > 1): - print 'error more than 1 LCU cmd selected' - exit(-1) - - for station in stations.ec(Station): - ec = EC(station) - try: - (hostname, aliaslist, ipaddrlist) = socket.gethostbyaddr(station) - hostname = hostname.split('.')[0] - except: - hostname = ' ??? ' - - if ec.connectToHost() == True: - ec.setSecond(int(time.gmtime()[5])) - ## do not change if statements - ec.printInfo(True) - ec.getPowerStatus() - if (doResetTrip == 1): - logfile.write('%sc, %s, ecResetTrip by %s\n' %(string.upper(hostname), time.asctime(), name)) - if ec.getTripStatus(): - ec.resetTrip() - if (doReset48V == 1): - logfile.write('%sc, %s, ecReset48 by %s\n' %(string.upper(hostname), time.asctime(), name)) - ec.resetPower(ec.P48) - if (doResetLCU == 1): - logfile.write('%sc, %s, ecResetLCU by %s\n' %(string.upper(hostname), time.asctime(), name)) - ec.resetPower(ec.LCU) - if (doPowerOn48V == 1): - logfile.write('%sc, %s, ec48On by %s\n' %(string.upper(hostname), time.asctime(), name)) - ec.setPower(48,ec.PWR_ON) - if (doPowerOff48V == 1): - logfile.write('%sc, %s, ec48Off by %s\n' %(string.upper(hostname), time.asctime(), name)) - ec.setPower(48,ec.PWR_OFF) - if (doPowerOnLCU == 1): - logfile.write('%sc, %s, ecLcuOn by %s\n' %(string.upper(hostname), time.asctime(), name)) - ec.setPower(ec.LCU,ec.PWR_ON) - if (doPowerOffLCU == 1): - logfile.write('%sc, %s, ecLcuOff by %s\n' %(string.upper(hostname), time.asctime(), name)) - ec.setPower(ec.LCU,ec.PWR_OFF) - - # print status again after 10 seconds if cmd is send - if (doResetTrip or doReset48V or doResetLCU or doPowerOn48V or doPowerOff48V or doPowerOnLCU or doPowerOffLCU): - print "waiting 10 seconds" - time.sleep(10.0) - ec.getPowerStatus() - - # print status again after 10 seconds if power reset cmd is send - if (doReset48V or doResetLCU): - print "waiting 10 seconds" - time.sleep(10.0) - ec.getPowerStatus() - - ec.printInfo(False) - ec.disconnectHost() diff --git a/LCU/StationTest/test/envcontroltest/stations.py b/LCU/StationTest/test/envcontroltest/stations.py deleted file mode 100755 index 6ea0f33f60d..00000000000 --- a/LCU/StationTest/test/envcontroltest/stations.py +++ /dev/null @@ -1,149 +0,0 @@ -#!/usr/bin/env python -# P.Donker ASTRON feb-2010 - -from string import upper -import socket - -# class STATION can be called with -# 'ALL' for all stations -# 'NL' for all NL stations -# 'IS' for all IS stations -# 'hostname' for specific station (CS001c) -# must start with 'CS' or 'RS' -# 'hostip' for specific station (10.151.1.1) -# must start with '10.151' or '10.209' -# -# example: -# import stations -# station = stations.STATION('ALL') -# -# after initiate the class can be called with the following functions -# host lcu(next=False) returns LCU IP | if next=True, | -# host ec(next=False) returns LCU IP | first the hostIP is build with | -# host psu(next=False) returns LCU IP | active station, after that | -# host ipmi(next=False) returns LCU IP | nextStation() is called | -# isnext nextStation() increments the Station counter, this function is -# also called by above functions if next = True -# isnext=True if next station is available otherwise False - -class STATION: - - nlStations = ['1','2','3','4','5','6','7', - '19','20','21','22','23', - '33','34','35','36','37','38','39', - '49','50','51','53','55', - '65','66','67','68', - '129','131','132','134','135', - '145','149','150','151','152','154', - '161','162','166','167','168','169','170','171', - '177','180','182','183','184','185','186','187','188','189', - '193','195','198','199','200','201'] - - #nlStations = [] - #for i in range(255): - # nlStations.append(str(i)) - - - isStations = ['1','2','3','4','5','6','7','8'] - - deviceIP = {'LCU':'1','EC':'3','PSU':'5','IPMI':'11','NAA':'53'} - - def help(self): - print "Unknown argument, usage:" - print "'ALL' for all stations" - print "'NL' for all NL stations" - print "'IS' for all IS stations" - print "'hostname' for specific station (CS001c)" - print " must start with 'CS' or 'RS'" - print "'hostip' for specific station (10.151.1.1)" - print " must start with '10.151' or '10.209'" - - - def isLCU(self): - # get ip-adres of LCU - local_host = socket.gethostbyname(socket.gethostname()) - ip = local_host.split('.') - if ip[2] in self.nlStations: - if ip[0] == '10': - if (ip[1] == '151') or (ip[1] == '209'): - return(local_host[:local_host.rfind('.')+1]) - return(None) - - def stations(self, station, device='LCU'): - if station == None: return () - station = upper(station) - dIP = self.deviceIP[upper(device)] - st = () - if station == 'TEST': - ip = '10.87.2.239' - st += ip, - return(st) - if station == 'ALL': - for s in self.nlStations: - ip = '10.151.%s.%s' %(s,dIP) - st += ip, - for s in self.isStations: - ip = '10.209.%s.%s' %(s,dIP) - st += ip, - return(st) - - if station == 'NL': - for s in self.nlStations: - ip = '10.151.%s.%s' %(s,dIP) - st += ip, - return(st) - - if station == 'IS': - for s in self.isStations: - ip = '10.209.%s.%s' %(s,dIP) - st += ip, - return(st) - - if station == 'THIS': - s = self.isLCU() - if s is None: - print 'Error: this script can only run on a LCU' - return(()) - st += s+dIP, - return(st) - - if station.count('.') == 3: - sts = station.split('.') - if sts[0] == '10': - if sts[1] == '151': - if sts[2] in self.nlStations: - st += station[:station.rfind('.')+1]+dIP, - return(st) - if sts[1] == '209': - if sts[2] in self.isStations: - st += station[:station.rfind('.')+1]+dIP, - return(st) - print 'Error: not a valid station IP' - return(()) - prefix = upper(station[:2]) - if prefix == 'CS' or prefix == 'RS' or prefix == 'DE' or prefix == 'FR' or prefix == 'SE' or prefix == 'UK': - try: - host = socket.gethostbyname(station[:5] + 'C') - if host.count('.') == 3: - st += host[:host.rfind('.')+1]+dIP, - return(st) - except: - print 'Error: %s not in NameTable' %(station) - return(()) - self.help() - - - def lcu(self, station=None): - return(self.stations(station,'LCU')) - - def ec(self, station=None): - return(self.stations(station,'EC')) - - def psu(self, station=None): - return(self.stations(station,'PSU')) - - def ipmi(self, station=None): - return(self.stations(station,'IPMI')) - - def naa(self, station=None): - return(self.stations(station,'NAA')) -- GitLab