diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7378f8d0c6d68cc59ff1d8b916427ca3c999a711..46d29fe4d27e1cff7c99aa7904a0c40ced90e718 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -101,6 +101,7 @@ docker_build_image_all: - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-observation latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-observation-control latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-psoc latest + - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-pcon latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-recv latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-sdp latest - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-bst latest @@ -267,6 +268,17 @@ docker_build_image_device_psoc: script: # Do not remove 'bash' or statement will be ignored by primitive docker shell - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-psoc $tag +docker_build_image_device_pcon: + extends: .base_docker_images_except + only: + refs: + - merge_requests + changes: + - docker-compose/device-pcon.yml + - docker-compose/lofar-device-base/* + script: +# Do not remove 'bash' or statement will be ignored by primitive docker shell + - bash $CI_PROJECT_DIR/sbin/tag_and_push_docker_image.sh device-pcon $tag docker_build_image_device_tilebeam: extends: .base_docker_images_except only: diff --git a/CDB/LOFAR_ConfigDb.json b/CDB/LOFAR_ConfigDb.json index 70c85e9bd31a97e84758a08bebae82106b702a87..508f4d3e3f2c96eb04cda4b2fea757a16d061124 100644 --- a/CDB/LOFAR_ConfigDb.json +++ b/CDB/LOFAR_ConfigDb.json @@ -46,9 +46,9 @@ "PSOC": { "STAT/PSOC/1": { "properties": { - "SNMP_host": ["10.87.2.145"], + "SNMP_host": ["127.0.0.1"], "SNMP_community": ["public"], - "SNMP_mib_dir": ["devices/psoc_mib/PowerNet-MIB.mib"], + "SNMP_mib_dir": ["devices/mibs/PowerNet-MIB.mib"], "SNMP_timeout": ["10.0"], "SNMP_version": ["1"], "PSOC_sockets": [ @@ -66,6 +66,21 @@ } } }, + "PCON": { + "STAT": { + "PCON": { + "STAT/PCON/1": { + "properties": { + "SNMP_host": ["127.0.0.1"], + "SNMP_community": ["public"], + "SNMP_mib_dir": ["devices/mibs/ACC-MIB.mib"], + "SNMP_timeout": ["10.0"], + "SNMP_version": ["1"] + } + } + } + } + }, "TemperatureManager": { "STAT": { "TemperatureManager": { diff --git a/CDB/stations/DTS_Outside_ConfigDb.json b/CDB/stations/DTS_Outside_ConfigDb.json index fab3e930cfb239c74d0d59e9d0a6a4a401504d70..dbff3fda62b2b76e5714a81c12f94d4b75502eea 100644 --- a/CDB/stations/DTS_Outside_ConfigDb.json +++ b/CDB/stations/DTS_Outside_ConfigDb.json @@ -526,6 +526,38 @@ } } }, + "PSOC": { + "STAT": { + "PSOC": { + "STAT/PSOC/1": { + "properties": { + "SNMP_host": ["10.87.2.145"], + "PSOC_sockets": [ + "socket_1", + "socket_2", + "socket_3", + "socket_4", + "socket_5", + "socket_6", + "socket_7", + "socket_8" + ] + } + } + } + } + }, + "PCON": { + "STAT": { + "PCON": { + "STAT/PCON/1": { + "properties": { + "SNMP_host": ["10.151.225.5"] + } + } + } + } + }, "UNB2": { "STAT": { "UNB2": { diff --git a/docker-compose/device-pcon.yml b/docker-compose/device-pcon.yml new file mode 100644 index 0000000000000000000000000000000000000000..aa20c1498c3e135accd543800d9a50e41a3ea092 --- /dev/null +++ b/docker-compose/device-pcon.yml @@ -0,0 +1,42 @@ +# +# Requires: +# - lofar-device-base.yml +# +version: '2.1' + +volumes: + iers-data: {} + +services: + device-pcon: + image: device-pcon + # build explicitly, as docker-compose does not understand a local image + # being shared among services. + build: + context: .. + dockerfile: docker-compose/lofar-device-base/Dockerfile + args: + SOURCE_IMAGE: ${DOCKER_REGISTRY_HOST}/${DOCKER_REGISTRY_USER}-tango-itango:${TANGO_ITANGO_VERSION} + container_name: ${CONTAINER_NAME_PREFIX}device-pcon + logging: + driver: "json-file" + options: + max-size: "100m" + max-file: "10" + networks: + - control + ports: + - "5719:5719" # unique port for this DS + extra_hosts: + - "host.docker.internal:host-gateway" + volumes: + - ..:/opt/lofar/tango:rw + environment: + - TANGO_HOST=${TANGO_HOST} + working_dir: /opt/lofar/tango + entrypoint: + - bin/start-ds.sh + # configure CORBA to _listen_ on 0:port, but tell others we're _reachable_ through ${HOSTNAME}:port, since CORBA + # can't know about our Docker port forwarding + - l2ss-pcon pcon STAT -v -ORBendPoint giop:tcp:device-pcon:5719 -ORBendPointPublish giop:tcp:${HOSTNAME}:5719 + restart: unless-stopped diff --git a/docker-compose/tango-prometheus-exporter/lofar2-policy.json b/docker-compose/tango-prometheus-exporter/lofar2-policy.json index 06a1febb3267dcff2234597900a19d3ca858178d..994d9dd1877b87ab7ccecbcfe325c97333dd7f92 100644 --- a/docker-compose/tango-prometheus-exporter/lofar2-policy.json +++ b/docker-compose/tango-prometheus-exporter/lofar2-policy.json @@ -35,6 +35,8 @@ }, "STAT/PSOC/1": { }, + "STAT/PCON/1": { + }, "STAT/RECV/1": { "include": [ "ANT_mask_RW", diff --git a/sbin/run_integration_test.sh b/sbin/run_integration_test.sh index f879e8d9ddb97a62bd9bac15b893621a3d8739f0..30df5c7cf02be8a26b86c506299d64e0acfa45ef 100755 --- a/sbin/run_integration_test.sh +++ b/sbin/run_integration_test.sh @@ -69,7 +69,8 @@ sleep 1 # dsconfig container must be up and running... # shellcheck disable=SC2016 echo '/usr/local/bin/wait-for-it.sh ${TANGO_HOST} --strict --timeout=300 -- true' | make run dsconfig bash - -DEVICES="device-boot device-apsct device-apspu device-sdp device-recv device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-antennafield device-temperature-manager device-observation device-observation-control" +DEVICES="device-boot device-apsct device-apspu device-sdp device-recv device-bst device-sst device-unb2 device-xst device-beamlet device-digitalbeam device-tilebeam device-psoc device-pcon device-antennafield device-temperature-manager device-observation device-observation-control" + SIMULATORS="sdptr-sim recv-sim unb2-sim apsct-sim apspu-sim" # Build only the required images, please do not build everything that makes CI diff --git a/tangostationcontrol/setup.cfg b/tangostationcontrol/setup.cfg index cd64d07bf69914aae880fa881b995333942881b3..82d6efb049aa4dae8f7842518c20aea2f4ae1ba1 100644 --- a/tangostationcontrol/setup.cfg +++ b/tangostationcontrol/setup.cfg @@ -37,6 +37,7 @@ console_scripts = l2ss-apsct = tangostationcontrol.devices.apsct:main l2ss-apspu = tangostationcontrol.devices.apspu:main l2ss-psoc = tangostationcontrol.devices.psoc:main + l2ss-pcon = tangostationcontrol.devices.pcon:main l2ss-tilebeam = tangostationcontrol.devices.tilebeam:main l2ss-beamlet = tangostationcontrol.devices.sdp.beamlet:main l2ss-digitalbeam = tangostationcontrol.devices.sdp.digitalbeam:main diff --git a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py index f75b6bcf4c4f8a7fd26fd85b6d0a4973a4d8d0dc..b161d9b42281b6ef981eee31ebfec6473cb701a9 100644 --- a/tangostationcontrol/tangostationcontrol/clients/snmp_client.py +++ b/tangostationcontrol/tangostationcontrol/clients/snmp_client.py @@ -83,7 +83,10 @@ class SNMP_client(CommClient): # SNMP has tables that require an index number to access them. regular non-table variable have an index of 0 idx = annotation.get('index', 0) - return mib, name, idx + # SNMP values like to use weird units like tenths of amps because its all integers. We added a scaling factor to correct for that. + scaling_factor = annotation.get('scaling_factor', 1) + + return mib, name, idx, scaling_factor except KeyError: raise ValueError(f"SNMP attribute annotation requires a dict argument with both a 'name' and 'mib' key. Instead got: {annotation}") @@ -108,11 +111,11 @@ class SNMP_client(CommClient): """ # process the annotation - mib, name, idx = self._process_annotation(annotation) + mib, name, idx, scaling_factor = self._process_annotation(annotation) # get all the necessary data to set up the read/write functions from the attribute_wrapper dim_x, dim_y, dtype = self.setup_value_conversion(attribute) - snmp_attr = snmp_attribute(self.SNMP_comm, mib, name, idx, dtype, dim_x, dim_y) + snmp_attr = snmp_attribute(self.SNMP_comm, mib, name, idx, dtype, dim_x, dim_y, scaling_factor) # return the read/write functions def read_function(): @@ -125,13 +128,14 @@ class SNMP_client(CommClient): class snmp_attribute: - def __init__(self, comm: SNMP_comm, mib, name, idx, dtype, dim_x, dim_y): + def __init__(self, comm: SNMP_comm, mib, name, idx, dtype, dim_x, dim_y, scaling_factor=1): self.comm = comm self.mib = mib self.name = name self.idx = idx self.dtype = dtype + self.scaling_factor = scaling_factor self.len = self.get_len(dim_x, dim_y) self.is_scalar = self.len == 1 @@ -203,7 +207,7 @@ class snmp_attribute: # IpAddress values get printed as their raw value but in hex (7F 20 20 01 for 127.0.0.1 for example) vals.append(varBind[1].prettyPrint()) - elif snmp_type is hlapi.Integer32 or snmp_type is hlapi.Integer and self.dtype == str: + elif (snmp_type is hlapi.Integer32 or snmp_type is hlapi.Integer) and self.dtype == str: # Integers can have 'named values', Where a value can be translated to a specific name. A dict basically # Example: {1: "other", 2: "invalid", 3: "dynamic", 4: "static",} @@ -215,7 +219,10 @@ class snmp_attribute: vals.append(varBind[1].prettyPrint()) else: # convert from the funky pysnmp types to numpy types and then append - vals.append(snmp_to_numpy_dict[snmp_type](varBind[1])) + value = snmp_to_numpy_dict[snmp_type](varBind[1]) + + # scale the value correctly and append. + vals.append(value * self.scaling_factor) if self.is_scalar: vals = vals[0] @@ -235,7 +242,5 @@ class mib_loader: logger.debug(f"mib sources: {self.mibBuilder.getMibSources()}") def load_pymib(self, mib_name): - logger.debug(f"test {self.mibBuilder.getMibSources()}") - logger.debug(f"test {mib_name}") self.mibBuilder.loadModules(mib_name) diff --git a/tangostationcontrol/tangostationcontrol/devices/boot.py b/tangostationcontrol/tangostationcontrol/devices/boot.py index 8a7c08403d9c3c7a634d8151baef8bcd8fd501c2..cb172c34d3b4249691518609f18bd5a7ceced613 100644 --- a/tangostationcontrol/tangostationcontrol/devices/boot.py +++ b/tangostationcontrol/tangostationcontrol/devices/boot.py @@ -235,6 +235,7 @@ class Boot(lofar_device): mandatory=False, default_value=["STAT/Docker/1", # Docker controls the device containers, so it goes before anything else "STAT/PSOC/1", # PSOC boot early to detect power delivery failure as fast as possible + "STAT/PCON/1", # PCON boot early because it is responsible for power delivery. "STAT/APSPU/1", # APS Power Units control other hardware we want to initialise "STAT/APSCT/1", "STAT/RECV/1", # RCUs are input for SDP, so initialise them first diff --git a/tangostationcontrol/tangostationcontrol/devices/mibs/ACC.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/ACC.mib new file mode 100644 index 0000000000000000000000000000000000000000..82cc818f37aa03bf335d58302b7f5c22bda9252a --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/devices/mibs/ACC.mib @@ -0,0 +1,1092 @@ +-- ACC Mib v. 1.00 + +-- powecMIB MODULE-IDENTITY +-- LAST-UPDATED "0705111430Z" +-- ORGANIZATION "Power-One, Powec" +-- CONTACT-INFO "Arild Sageboe, arild.sageboe@power-one.com" +-- DESCRIPTION "System Information, ACC Power Systems" +-- ::= { enterprises 5961 } + +ACC-MIB DEFINITIONS ::= BEGIN + + IMPORTS + + enterprises, IpAddress FROM RFC1155-SMI + DisplayString FROM RFC1213-MIB + OBJECT-TYPE FROM RFC-1212 + TRAP-TYPE FROM RFC-1215; + + + + powecMIB OBJECT IDENTIFIER ::= { enterprises 5961 } + accPowerSystem OBJECT IDENTIFIER ::= { powecMIB 4 } + + systemInfo OBJECT IDENTIFIER ::= { accPowerSystem 1 } + powerSystem OBJECT IDENTIFIER ::= { accPowerSystem 2 } + alarmInfo OBJECT IDENTIFIER ::= { accPowerSystem 3 } + systemParameters OBJECT IDENTIFIER ::= { accPowerSystem 4 } + powecTrap OBJECT IDENTIFIER ::= { accPowerSystem 99 } + +-- SYSTEM INFO variables + +systemName OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-write + STATUS mandatory + DESCRIPTION + "System Type String for the DC System Site" + ::= { systemInfo 1 } + +powerSystemType OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "String containing the type of power supply control module (ACC)" + ::= { systemInfo 2 } + +powerSystemSoftVer OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "String containing the software version of the control module" + ::= { systemInfo 3 } + +powerSystemSerialNo OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Serial Number of the control module" + ::= { systemInfo 4 } + +outputData OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-write + STATUS mandatory + DESCRIPTION + "String containing a description of the DC Output" + ::= { systemInfo 5 } + +batteryDescript OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-write + STATUS mandatory + DESCRIPTION + "String containing a description of the Battery" + ::= { systemInfo 6 } + +batteryCapacity OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "An integer containing battery capacity in Ah" + + ::= { systemInfo 7 } + +-- POWER SYSTEM variables + +systemVoltage OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing the system DC voltage (voltage * 100)" + ::= { powerSystem 1 } + +loadCurrent OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing the system load current (current * 10)" + ::= { powerSystem 2 } + +batteryCurrent OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing the battery current (current * 10)" + ::= { powerSystem 3 } + + +rectifierCurrent OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing the rectifier current (current * 10)" + ::= { powerSystem 4 } + +battTemperature OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing the battery temperature(Degree C)" + ::= { powerSystem 5 } + +acPhase1Voltage OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing AC input voltage for phase 1 (Volt), (-1) means measurement not available" + ::= { powerSystem 6 } + +acPhase2Voltage OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing AC input voltage for phase 2 (Volt), (-1) means measurement not available" + ::= { powerSystem 7 } + +acPhase3Voltage OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing AC input voltage for phase 3 (Volt), (-1) means measurement not available" + ::= { powerSystem 8 } + +remainBatteryTime OBJECT-TYPE + SYNTAX INTEGER + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A variable containing the remaining battery time in (minutes)" + ::= { powerSystem 9 } + +-- ALARM INFO variables (Alarm and Status Information) +-- The alarmData, extraAlarmData and statusData +-- are integers from 0-255 containing the byte value received +-- from the controlmodule. + +numbOfAlarms OBJECT-TYPE + SYNTAX INTEGER(0..100) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Variable containing the number of active alarms at the moment, when sent with a trap 1 indicate active, 0 indicate clear" + ::= { alarmInfo 1 } + +alarmData1 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing alarm data 1" + ::= { alarmInfo 2 } + +alarmData2 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing alarm data 2" + ::= { alarmInfo 3 } + +alarmData3 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing alarm data 3" + ::= { alarmInfo 4 } + +extraAlarmData1 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing extra alarm data 1" + ::= { alarmInfo 5 } + +extraAlarmData2 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing extra alarm data 2" + ::= { alarmInfo 6 } + +statusData1 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing status data 1" + ::= { alarmInfo 7 } + +statusData2 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing status data 2" + ::= { alarmInfo 8 } + +statusData3 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing status data 3" + ::= { alarmInfo 9 } + +statusData4 OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-only + STATUS mandatory + DESCRIPTION + "A byte containing status data 4" + ::= { alarmInfo 10 } + +extAlarm1Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 1 name" + ::= { alarmInfo 11 } + +extAlarm2Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 2 name" + ::= { alarmInfo 12 } + +extAlarm3Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 3 name" + ::= { alarmInfo 13 } + +extAlarm4Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 4 name" + ::= { alarmInfo 14 } + +extAlarm5Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 5 name" + ::= { alarmInfo 15 } + +extAlarm6Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 6 name" + ::= { alarmInfo 16 } + +extAlarm7Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 7 name" + ::= { alarmInfo 17 } + +extAlarm8Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 8 name" + ::= { alarmInfo 18 } + +extAlarm9Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 9 name" + ::= { alarmInfo 19 } + +extAlarm10Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 10 name" + ::= { alarmInfo 20 } + +extAlarm11Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 11 name" + ::= { alarmInfo 21 } + +extAlarm12Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 12 name" + ::= { alarmInfo 22 } + +extAlarm13Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 13 name" + ::= { alarmInfo 23 } + +extAlarm14Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 14 name" + ::= { alarmInfo 24 } + +extAlarm15Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 15 name" + ::= { alarmInfo 25 } + +extAlarm16Name OBJECT-TYPE + SYNTAX DisplayString + ACCESS read-only + STATUS mandatory + DESCRIPTION + "Ext.alarm 16 name" + ::= { alarmInfo 26 } + +-- SYSTEM PARAMETERS + +uFlag OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the operation mode Flag (normal, boost charge, test, spare)" + ::= { systemParameters 1 } + +u1NormalRef OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing U1 (Normal) Reference Voltage (Volt*10)" + ::= { systemParameters 2 } + +u2BoostRef OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing U2 (Boost) Reference Voltage (Volt*10)" + ::= { systemParameters 3 } + +u3TestRef OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing U3 (Test) Reference Voltage (Volt*10)" + ::= { systemParameters 4 } + +u4SpareRef OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing U4 (Spare) Reference Voltage (Volt*10)" + ::= { systemParameters 5 } + + +lowVoltLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Low Voltage Limit (Volt*10)" + ::= { systemParameters 6 } + + +lowVoltDisconVoltLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Low Voltage Disconnect Limit (Volt*10)" + ::= { systemParameters 7 } + +lowVoltReconLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Low Voltage Reconnect Limit (Volt*10)" + ::= { systemParameters 8 } + +partLoadDiscon1Limit OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Partial Load Disconnection Limit. The limit will be in (V*10), or + in (minutes) depending on the configuration of the ACC" + ::= { systemParameters 9 } + +partLoadDiscon2Limit OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Partial Load Disconnection Limit. The limit will be in (V*10), or + in (minutes) depending on the configuration of the ACC" + ::= { systemParameters 10 } + +partLoadDiscon3Limit OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Partial Load Disconnection Limit. The limit will be in (V*10), or + in (minutes) depending on the configuration of the ACC" + ::= { systemParameters 11 } + +highVoltLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the High Voltage Limit (Volt*10)" + ::= { systemParameters 12 } + +highVoltDisconLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the High Voltage Shutdown Limit (Volt*10)" + ::= { systemParameters 13 } + +autoBoostFlag OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Auto Boost Flag(1 for auto boost enabled, 0 disabled)." + ::= { systemParameters 14 } + +boostTime OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Boost Time value (hour*10)" + ::= { systemParameters 15 } + +boostInterval OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Boost Interval value (weeks*10)" + ::= { systemParameters 16 } + +boostTimeFactor OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Boost Time Factor" + ::= { systemParameters 17 } + +boostLimit1 OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Boost Limit1 value (Volt*10)" + ::= { systemParameters 18 } + +boostLimit2 OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Boost Limit2 value (Volt*10)" + ::= { systemParameters 19 } + + +noOfBatteries OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Number of Batteries" + ::= { systemParameters 20 } + +batType OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Type Of Battery" + ::= { systemParameters 21 } + +symLimit OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Symmetry Limit (Volt*10)" + ::= { systemParameters 22 } + +autoTestFlag OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the number of automatic battery tests performed per year." + ::= { systemParameters 23 } + +startHForTest OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Start Hour for Automatic Test" + ::= { systemParameters 24 } + +voltLimForTest OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Voltage Limit for Battery Test (Volt*10)" + ::= { systemParameters 25 } + +timeLimForTest OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Time Limit For Test (minutes)" + ::= { systemParameters 26 } + +ampLimForTest OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Amphour Limit For Test (Ah)" + ::= { systemParameters 27 } + +year OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Year" + ::= { systemParameters 28 } + +month OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Month" + ::= { systemParameters 29 } + +day OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Day" + ::= { systemParameters 30 } + +hour OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Hour" + ::= { systemParameters 31 } + +minute OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Minute" + ::= { systemParameters 32 } + +tempCompFlag OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Temperature Compensation Flag" + ::= { systemParameters 33 } + +tempCompFactor OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Temperature Compensation Factor (Volt*10/10C)" + ::= { systemParameters 34 } + +highTempLimit OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the High Temperature Limit (C)" + ::= { systemParameters 35 } + +lowTempLimit OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Low Temperature Limit (C)" + ::= { systemParameters 36 } + +highLoadLimit OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the High Load Limit (% of full capacity)" + ::= { systemParameters 37 } + +signals OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS write-only + STATUS mandatory + DESCRIPTION + "A variable containing the Signal byte + Bit 0 - Reset Alarms + Bit 1 - Reconfigure System" + ::= { systemParameters 38 } + +shuntA OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Shunt Current Rating (A)" + ::= { systemParameters 39 } + +shuntmV OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Shunt mV Rating (mV)" + ::= { systemParameters 40 } + +batCurrLimEnabled OBJECT-TYPE + SYNTAX INTEGER(0..255) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "Battery Current Limit Enabled + " + ::= { systemParameters 41 } + +currLimRef OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the battery Current Limit reference (Amp*10)" + ::= { systemParameters 42 } + +highACVoltLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the High AC Voltage Limit (Volt)" + ::= { systemParameters 43 } + +lowACVoltLim OBJECT-TYPE + SYNTAX INTEGER(0..30000) + ACCESS read-write + STATUS mandatory + DESCRIPTION + "A variable containing the Low AC Voltage Limit (Volt)" + ::= { systemParameters 44 } + + +-- Traps + +lowVoltTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Low DC Voltage Alarm " + ::= 1 + + +highVoltTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "High DC Voltage Alarm" + ::= 2 + +loadBattDisconTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Load/Battery Disconnected" + ::= 3 +mainsFailTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Mains Failure Alarm" + ::= 4 +distrFuseTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Distribution Fuse Failure" + ::= 5 +lowACTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Low AC input voltage" + ::= 6 +battFailTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Battery Test Failure" + ::= 7 +rectifierFailTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Module Alarm" + ::= 8 + +battTempTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "High Battery Temperature Alarm" + ::= 9 +symmFailTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Battery Symmetry Alarm" + ::= 10 +battFuseTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Battery Fuse Failure" + ::= 11 +highLoadTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "High Load" + ::= 12 +highACTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "High AC input voltage" + ::= 13 +urgentModFailTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Urgent Module Alarm" + ::= 14 +comFailTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Communication Failure" + ::= 15 +partLoadDiscon1Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Partial Load Disconnect 1 Alarm" + ::= 16 +tempProbeTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Temperature probe fault" + ::= 17 +dischargingTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Battery on Discharge" + ::= 18 +ovShutdownTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Overvoltage Shutdown alarm" + ::= 19 +lowBattTempTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Low Battery Temperature" + ::= 20 +partLoadDiscon2Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Partial Load Disconnect 2 Alarm" + ::= 21 +partLoadDiscon3Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Partial Load Disconnect 3 Alarm" + ::= 22 +alarmsBlockedTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Alarms Blocked" + ::= 23 +extAlarm0Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 0" + ::= 24 +extAlarm1Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 1" + ::= 25 +extAlarm2Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 2" + ::= 26 +extAlarm3Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 3" + ::= 27 +extAlarm4Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 4" + ::= 28 +extAlarm5Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 5" + ::= 29 +extAlarm6Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 6" + ::= 30 +extAlarm7Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 7" + ::= 31 +extAlarm8Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 8" + ::= 32 +extAlarm9Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 9" + ::= 33 +extAlarm10Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 10" + ::= 34 +extAlarm11Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 11" + ::= 35 +extAlarm12Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 12" + ::= 36 +extAlarm13Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 13" + ::= 37 +extAlarm14Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 14" + ::= 38 +extAlarm15Trap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "Ext.alarm 15" + ::= 39 +u1NormalTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "System output reference changed to Normal" + ::= 40 +u2BoostTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "System output reference changed to Boost" + ::= 41 +u3TestTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "System output reference changed to Test" + ::= 42 +u4SpareTrap TRAP-TYPE + ENTERPRISE powecTrap + VARIABLES { + numbOfAlarms + } + DESCRIPTION + "System output reference changed to Spare" + ::= 43 + +END diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/PowerNet-MIB.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/PowerNet-MIB.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/PowerNet-MIB.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/PowerNet-MIB.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC-1212.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/RFC-1212.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC-1212.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/RFC-1212.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC-1215.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/RFC-1215.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC-1215.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/RFC-1215.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC1155-SMI.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/RFC1155-SMI.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC1155-SMI.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/RFC1155-SMI.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC1158-MIB.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/RFC1158-MIB.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC1158-MIB.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/RFC1158-MIB.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC1213-MIB.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/RFC1213-MIB.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/RFC1213-MIB.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/RFC1213-MIB.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-CONF.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-CONF.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-CONF.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-CONF.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-MIB.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-MIB.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-MIB.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-MIB.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-SMI.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-SMI.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-SMI.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-SMI.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-TC.mib b/tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-TC.mib similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/SNMPv2-TC.mib rename to tangostationcontrol/tangostationcontrol/devices/mibs/SNMPv2-TC.mib diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc_mib/__init__.py b/tangostationcontrol/tangostationcontrol/devices/mibs/__init__.py similarity index 100% rename from tangostationcontrol/tangostationcontrol/devices/psoc_mib/__init__.py rename to tangostationcontrol/tangostationcontrol/devices/mibs/__init__.py diff --git a/tangostationcontrol/tangostationcontrol/devices/pcon.py b/tangostationcontrol/tangostationcontrol/devices/pcon.py new file mode 100644 index 0000000000000000000000000000000000000000..02bf7d9d70f33a5ac6a52ca4fa966fa9b20cde42 --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/devices/pcon.py @@ -0,0 +1,49 @@ +# -*- coding: utf-8 -*- +# +# Distributed under the terms of the APACHE license. +# See LICENSE.txt for more info. + +""" PCON Device Server for LOFAR2.0 + +""" + +# Additional import +from tangostationcontrol.common.entrypoint import entry +from tangostationcontrol.common.lofar_logging import device_logging_to_python + +import logging +from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper +from tangostationcontrol.devices.snmp_device import snmp_device + +import numpy + +from pysmi import debug + +debug.setLogger(debug.Debug('searcher', "compiler", "borrower", "reader")) + +logger = logging.getLogger() + +__all__ = ["PCON", "main"] + + +@device_logging_to_python() +class PCON(snmp_device): + + # ---------- + # Attributes + # ---------- + systemVoltage_R = attribute_wrapper(comms_annotation={"mib": "ACC-MIB", "name": "systemVoltage", "scaling_factor": 0.01}, datatype=numpy.double) + + rectifierCurrent_R = attribute_wrapper(comms_annotation={"mib": "ACC-MIB", "name": "rectifierCurrent", "scaling_factor": 0.1}, datatype=numpy.double) + loadCurrent_R = attribute_wrapper(comms_annotation={"mib": "ACC-MIB", "name": "loadCurrent", "scaling_factor": 0.1}, datatype=numpy.double) + batteryCurrent_R = attribute_wrapper(comms_annotation={"mib": "ACC-MIB", "name": "batteryCurrent", "scaling_factor": 0.1}, datatype=numpy.double) + + battTemperature_R = attribute_wrapper(comms_annotation={"mib": "ACC-MIB", "name": "battTemperature"}, datatype=numpy.double) + + +# ---------- +# Run server +# ---------- +def main(**kwargs): + """Main function of the PCON module.""" + return entry(PCON, **kwargs) diff --git a/tangostationcontrol/tangostationcontrol/devices/psoc.py b/tangostationcontrol/tangostationcontrol/devices/psoc.py index 643617cfba8853168cef0ac59911fc744571c2e9..0c83360c78b570f27da96fcb3e8316f0cdd72334 100644 --- a/tangostationcontrol/tangostationcontrol/devices/psoc.py +++ b/tangostationcontrol/tangostationcontrol/devices/psoc.py @@ -9,18 +9,16 @@ # Additional import from tangostationcontrol.common.entrypoint import entry -from tangostationcontrol.devices.lofar_device import lofar_device from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions from tango.server import device_property, command -import os import logging from tangostationcontrol.clients.attribute_wrapper import attribute_wrapper -from tangostationcontrol.clients.snmp_client import SNMP_client, mib_loader, snmp_attribute +from tangostationcontrol.clients.snmp_client import snmp_attribute +from tangostationcontrol.devices.snmp_device import snmp_device import numpy -import pkg_resources from datetime import timedelta from pysmi import debug @@ -33,35 +31,10 @@ __all__ = ["PSOC", "main"] @device_logging_to_python() -class PSOC(lofar_device): +class PSOC(snmp_device): # ----------------- # Device Properties # ----------------- - SNMP_community = device_property( - dtype='DevString', - mandatory=True - ) - - SNMP_host = device_property( - dtype='DevString', - mandatory=True - ) - - SNMP_mib_dir = device_property( - dtype='DevString', - mandatory=True - ) - - SNMP_timeout = device_property( - dtype='DevDouble', - mandatory=True - ) - - SNMP_version = device_property( - dtype='DevULong', - mandatory=True - ) - PSOC_sockets = device_property( dtype=[str], mandatory=True @@ -70,9 +43,9 @@ class PSOC(lofar_device): # ---------- # Attributes # ---------- - sockets_state_R = attribute_wrapper(comms_annotation={"mib": "PowerNet-MIB", "name": "sPSOCOutletCtl", "index": 1}, dims=(8,), datatype=str) - master_state_R = attribute_wrapper(comms_annotation={"mib": "PowerNet-MIB", "name": "sPSOCMasterState"}, datatype=str) - current_load_R = attribute_wrapper(comms_annotation={"mib": "PowerNet-MIB", "name": "rPSOCLoadStatusLoad", "index": 1}, datatype=numpy.int64) + sockets_state_R = attribute_wrapper(comms_annotation={"mib": "PowerNet-MIB", "name": "sPDUOutletCtl", "index": 1}, dims=(8,), datatype=str) + master_state_R = attribute_wrapper(comms_annotation={"mib": "PowerNet-MIB", "name": "sPDUMasterState"}, datatype=str) + current_load_R = attribute_wrapper(comms_annotation={"mib": "PowerNet-MIB", "name": "rPDULoadStatusLoad", "index": 1}, datatype=numpy.int64) uptime_R = attribute_wrapper(comms_annotation={"mib": "SNMPv2-MIB", "name": "sysUpTime"}, datatype=numpy.int64) # -------- @@ -94,26 +67,11 @@ class PSOC(lofar_device): self.socket_dict = {self.PSOC_sockets[f]: f + 1 for f in range(len(self.PSOC_sockets))} logger.debug(f"Configured PSOC with the following socket names: {self.PSOC_sockets}") - # set up the SNMP ua client - self.snmp_manager = SNMP_client(self.SNMP_community, self.SNMP_host, self.SNMP_timeout, self.SNMP_version, self.Fault, self) - - # map an access helper class - for i in self.attr_list(): - try: - i.set_comm_client(self, self.snmp_manager) - except Exception as e: - # use the pass function instead of setting read/write fails - i.set_pass_func(self) - logger.warning("error while setting the SNMP attribute {} read/write function. {}".format(i, e)) - - self.snmp_manager.start() - + super().configure_for_initialise() # prepares this object for the readable_uptime command self.uptime_attr = snmp_attribute(self.snmp_manager.SNMP_comm, "SNMPv2-MIB", name="sysUpTime", idx=0, dtype=numpy.int64, dim_x=1, dim_y=0) - super().configure_for_initialise() - def _toggle_socket(self, socket_name, on: bool): """ This function is tailored to the "APS switched rack PSOC", changing the psoc will require some changes to this function @@ -131,7 +89,7 @@ class PSOC(lofar_device): socket_set = "outletOff" # create the snmp_attribute for the correct socket - attr = snmp_attribute(self.snmp_manager.SNMP_comm, "PowerNet-MIB", name="sPSOCOutletCtl", idx=socket_nr, dtype=str, dim_x=1, dim_y=0) + attr = snmp_attribute(self.snmp_manager.SNMP_comm, "PowerNet-MIB", name="sPDUOutletCtl", idx=socket_nr, dtype=str, dim_x=1, dim_y=0) # write the correct value attr.write_function([socket_set]) @@ -155,36 +113,6 @@ class PSOC(lofar_device): # for whatever reason, the uptime is given in hundredts of a second return str(timedelta(seconds=self.uptime_attr.read_function()/100)) - - @log_exceptions() - def configure_for_on(self): - super().configure_for_on() - - @log_exceptions() - def configure_for_off(self): - super().configure_for_off() - - def get_mib_dir(self): - mib_filename_path = pkg_resources.resource_filename('tangostationcontrol', self.SNMP_mib_dir) - mib_path = os.path.dirname(mib_filename_path) - - return mib_path - - def init_device(self): - super().init_device() - - # create the mib_loader and set the mib path - self.loader = mib_loader(self.get_mib_dir()) - - for i in self.attr_list(): - try: - # for all of the attributes attempt to load the pre-compiled MIB. Skips already loaded ones - self.loader.load_pymib(i.comms_annotation["mib"]) - except Exception as e: - raise Exception( - f"Failed to load MIB file: {i.comms_annotation.get('mib')} for attribute {i.name} in directory {self.get_mib_dir()} ") from e - - # ---------- # Run server # ---------- diff --git a/tangostationcontrol/tangostationcontrol/devices/snmp_device.py b/tangostationcontrol/tangostationcontrol/devices/snmp_device.py new file mode 100644 index 0000000000000000000000000000000000000000..15dbf2d24691f8b97e1d51cfe8c827ade4532930 --- /dev/null +++ b/tangostationcontrol/tangostationcontrol/devices/snmp_device.py @@ -0,0 +1,106 @@ +# -*- coding: utf-8 -*- +# +# Distributed under the terms of the APACHE license. +# See LICENSE.txt for more info. + +""" SNMP Device Server for LOFAR2.0 + +""" + +# Additional import +from tangostationcontrol.devices.lofar_device import lofar_device +from tangostationcontrol.common.lofar_logging import device_logging_to_python, log_exceptions + +from tango.server import device_property +import os + +import logging +from tangostationcontrol.clients.snmp_client import SNMP_client, mib_loader + +import pkg_resources + +from pysmi import debug + +debug.setLogger(debug.Debug('searcher', "compiler", "borrower", "reader")) + +logger = logging.getLogger() + +__all__ = ["snmp_device"] + + +@device_logging_to_python() +class snmp_device(lofar_device): + # ----------------- + # Device Properties + # ----------------- + SNMP_community = device_property( + dtype='DevString', + mandatory=True + ) + + SNMP_host = device_property( + dtype='DevString', + mandatory=True + ) + + SNMP_mib_dir = device_property( + dtype='DevString', + mandatory=True + ) + + SNMP_timeout = device_property( + dtype='DevDouble', + mandatory=True + ) + + SNMP_version = device_property( + dtype='DevULong', + mandatory=True + ) + + @log_exceptions() + def configure_for_initialise(self): + + # set up the SNMP client + self.snmp_manager = SNMP_client(self.SNMP_community, self.SNMP_host, self.SNMP_timeout, self.SNMP_version, self.Fault, self) + + # map an access helper class + for i in self.attr_list(): + try: + i.set_comm_client(self, self.snmp_manager) + except Exception as e: + # use the pass function instead of setting read/write fails + i.set_pass_func(self) + logger.warning("error while setting the SNMP attribute {} read/write function. {}".format(i, e)) + + self.snmp_manager.start() + + super().configure_for_initialise() + + @log_exceptions() + def configure_for_on(self): + super().configure_for_on() + + @log_exceptions() + def configure_for_off(self): + super().configure_for_off() + + def get_mib_dir(self): + mib_filename_path = pkg_resources.resource_filename('tangostationcontrol', self.SNMP_mib_dir) + mib_path = os.path.dirname(mib_filename_path) + + return mib_path + + def init_device(self): + super().init_device() + + # create the mib_loader and set the mib path + self.loader = mib_loader(self.get_mib_dir()) + + for i in self.attr_list(): + try: + # for all of the attributes attempt to load the pre-compiled MIB. Skips already loaded ones + self.loader.load_pymib(i.comms_annotation["mib"]) + except Exception as e: + raise Exception( + f"Failed to load MIB file: {i.comms_annotation.get('mib')} for attribute {i.name} in directory {self.get_mib_dir()} ") from e