From 51c1a4d0aa82d0198732733a666bbc0c48dfe87f Mon Sep 17 00:00:00 2001
From: kruger <kruger@astron.nl>
Date: Wed, 26 May 2021 00:39:17 +0200
Subject: [PATCH] Comments added to variables

---
 VarTable.py         | 38 +++++++++++++++++++++++++++-----------
 config/APSCTTR.yaml | 14 +++++++-------
 config/APSPUTR.yaml |  4 +++-
 config/RECVTR.yaml  | 27 ++++++++++++++-------------
 config/UNB2TR.yaml  | 14 ++++++++++++--
 5 files changed, 63 insertions(+), 34 deletions(-)

diff --git a/VarTable.py b/VarTable.py
index 5d47950..7934ae8 100644
--- a/VarTable.py
+++ b/VarTable.py
@@ -1,35 +1,51 @@
 import yamlconfig as yc
 import sys
-RW={'ro':'_R','rw':'_R/_RW','variable':'_RW'}
-
+RW={'ro':'R','rw':'RW','variable':'RW'}
+Masked=True;
 Y=yc.yamlconfig(sys.argv[1])
 sep=','
 #Sort alphabetically
 names=[(v['name']).upper() for v in Y.getvars()]
 SI=sorted(range(len(names)), key=lambda k: names[k])
-print("Name                  "+sep+" Dim"+sep+"Type   "+sep+"R/W   "+sep+"Mask         "+sep+"Mon "+sep+"Description")
+if Masked:
+ print("Name                        "+sep+"Dim     "+sep+"Type   "+sep+"R/W   "+sep+"Mask            "+sep+"Mon  "+sep+"Description")
+else:
+ print("Name                   "+sep+"Type   "+sep+"R/W   "+sep+"Mon  "+sep+"Description")
 for i0 in SI:
     v=Y.getvar1(i0)
 #for v in Y.getvars():
     if v.get("debug",False): continue;
     if v.get("rw",False)=='hidden': continue;
-    S=('%-22s' % v['name'])+sep
-    S+=('%4i' % (v.get('dim',1)))+sep
+
+    dim=v.get('dim',1)
+    if dim>1:
+       dim2=v.get('dim2',None)
+       if not(dim2 is None):
+         dimS='[%i,%i]' % (dim2[0],dim2[1])
+       else: 
+         dimS='[%i]' % dim
+    else: dimS='[1]'
+
+    S=('%-28s' % v['name'])+sep
+    if Masked: S+=('%-8s' % dimS)+sep
     S+=('%-7s' % str(v['dtype']))+sep
     S+=('%-6s' % RW[v['rw']])+sep
-    S+=('%-13s' % v.get('mask',''))+sep
-    S+=('%-4s' % str(v.get('monitor','')))+sep
+    if Masked: S+=('%-16s' % v.get('mask',''))+sep
+    S+=('%-5s' % str(v.get('monitor','')))+sep
     S+=str(v.get('description',''))
     print(S)
 print()
-print("Name"+sep+"Mask"+sep+"Description")
+if Masked:
+  print(('%-23s'% "Name")+sep+('%-9s'% "Mask")+sep+"Description")
+else:
+  print(('%-23s'% "Name")+sep+"Description")
 for v in Y.conf['methods']:
     if v.get("debug",False): continue;
-    S=v['name']+sep
+    S=('%-23s' % v['name'])+sep
 #    S+=str(v['dim'])+sep
 #    S+=str(v['dtype'])+sep
 #    S+=RW[v['rw']]+sep
-    S+=v.get('mask','')+sep
+    if Masked: S+=('%-9s' % v.get('mask',''))+sep
 #    S+=str(v.get('monitor',''))+sep
-    S+=str(v.get('description',''))+sep
+    S+=str(v.get('description',''))
     print(S)
diff --git a/config/APSCTTR.yaml b/config/APSCTTR.yaml
index b55a56c..512d1ca 100644
--- a/config/APSCTTR.yaml
+++ b/config/APSCTTR.yaml
@@ -113,7 +113,7 @@ device_registers:
 
 variables:
   - name: APSCTTR_I2C_error
-    description: When >0 indicates an I2C error
+    description: 0=good, >0 indicates an I2C communication error
     driver: I2C_CLK
     rw:  ro #server RW variable, not linked to IO
     dtype: uint8
@@ -124,7 +124,7 @@ variables:
     dtype: uint8
 
   - name: APSCTTR_translator_busy
-    description: False when idle
+    description: True when I2C line busy
     rw:  ro #server variable, not linked to IO
     dtype: boolean
     dim: 1
@@ -155,7 +155,7 @@ variables:
 
 
   - name: [APSCT_PWR_PLL_200MHz_on,APSCT_PWR_PLL_160MHz_on]
-    description: CLK power status. True=ON. Controlled by APSCT_ON and APSCT_OFF
+    description: CLK power status. Controlled by APSCT_xxxMHz_ON and APSCT_OFF
     rw:  ro
     dtype: boolean
     driver: I2C_CLK
@@ -164,7 +164,7 @@ variables:
     width: 1
 
   - name: APSCT_PWR_on
-    description: CLK power status. True=ON. Controlled by APSCT_ON and APSCT_OFF
+    description: CLK power status. Controlled by APSCT_xxxMHz_ON and APSCT_OFF
     rw:  ro
     dtype: boolean
     driver: I2C_CLK
@@ -191,7 +191,7 @@ variables:
 
 
   - name: [APSCT_PLL_200MHz_locked,APSCT_PLL_160MHz_locked]
-    description: First status pin give lock status
+#    description: First status pin give lock status
     rw:  ro
     dtype: boolean
     monitor: true
@@ -201,7 +201,7 @@ variables:
     width: 1
 
   - name: [APSCT_PLL_200MHz_error,APSCT_PLL_160MHz_error]
-    description: Second status pin give error
+#    description: Second status pin give error
     rw:  ro
     dtype: boolean
     monitor: true
@@ -253,7 +253,7 @@ variables:
     debug: True
 
   - name: APSCT_TEMP
-    description: Temperature sensor on RCU
+    description: Temperature sensor on PCB
     driver: I2C_CLK
     devreg:  VSENSE.Temp
     width: 23
diff --git a/config/APSPUTR.yaml b/config/APSPUTR.yaml
index 6224a1d..00ed6d0 100644
--- a/config/APSPUTR.yaml
+++ b/config/APSPUTR.yaml
@@ -43,6 +43,7 @@ device_registers:
 
 variables:
   - name: APSPUTR_I2C_error
+    description: 0=Good, >0 I2C communication error
     driver: I2C_PU
     rw:  ro #server RW variable, not linked to IO
     dtype: uint8
@@ -53,7 +54,7 @@ variables:
     dtype: uint8
 
   - name: APSPUTR_translator_busy
-    description: False when idle
+    description: True when I2C line busy
     rw:  ro #server variable, not linked to IO
     dtype: boolean
 
@@ -132,6 +133,7 @@ methods:
       - APSPU_PCB_number : Update
 
   - name: APSPU_FAN_monitor_on
+    description: Setup the FAN monitor to give RPM
     driver: I2C_PU
     instructions:   
       - MAX.GLOBAL : 0x02; #Run monitor
diff --git a/config/RECVTR.yaml b/config/RECVTR.yaml
index 267d7c0..69e87db 100644
--- a/config/RECVTR.yaml
+++ b/config/RECVTR.yaml
@@ -209,13 +209,13 @@ device_registers:
 
 variables:
    - name: RECVTR_monitor_rate
-     description: Monitor rate in seconds
+     description: Rate at which monitored points are polled (seconds)
      driver: I2C_RCU
      rw:  variable 
      dtype: uint8
 
    - name: ANT_mask
-     description: Only masked RF chains are updated
+     description: Only RF chains with a true mask is set
      driver: I2C_RCU
      rw:  variable #server RW variable, not linked to IO
      dtype: boolean
@@ -223,7 +223,7 @@ variables:
      dim2: [3,32]
 
    - name: RCU_mask
-     description: Only masked RCUs are updated
+     description: Only RCUs with a true mask is set
      driver: I2C_RCU
      rw:  variable #server RW variable, not linked to IO
      dtype: boolean
@@ -286,7 +286,7 @@ variables:
 
    - name: RCU_LED_red_on
      driver: I2C_RCU
-     description: LED 1
+     description: Red LED on front panel
      devreg:  IO2.GPIO2
      bitoffset: 6
      width: 1
@@ -298,7 +298,7 @@ variables:
 
    - name: RCU_LED_green_on
      driver: I2C_RCU
-     description: LED 2
+     description: Green LED on front panel
      devreg:  IO2.GPIO2
      bitoffset: 7
      width: 1
@@ -309,7 +309,7 @@ variables:
      mask: RCU_mask
 
    - name: RCU_TEMP
-     description: RCU Temperature (Celsius)
+     description: RCU PCB Temperature (Celsius)
      driver: I2C_RCU
      devreg:  AN.Temp
      width: 23
@@ -358,7 +358,7 @@ variables:
      mask: RECVTR_I2C_error
 
    - name: RCU_PWR_ANT_VOUT
-     description: RCU antenna voltage (V)
+     description: Voltage on antenna output of RCU (V). Controlled by ANT_PWR_ON.
      driver: I2C_RCU
      devreg:  [AN.V_Ant_O0,AN.V_Ant_O1,AN.V_Ant_O2]
      width: 23
@@ -371,7 +371,7 @@ variables:
      mask: RECVTR_I2C_error
 
    - name: RCU_PWR_ANT_VIN
-     description: Voltage on antenna output of RCU (V). Controlled by ANT_PWR_ON.
+     description: RCU antenna voltage before switch (V)
      driver: I2C_RCU
      devreg:  [AN.V_Ant_I0,AN.V_Ant_I1,AN.V_Ant_I2]
      width: 23
@@ -436,14 +436,15 @@ variables:
      devreg:  [IO3.GPIO1,IO3.GPIO1,IO3.GPIO2]
      width: 1
      bitoffset: [7,6,7]
-     rw:  ro
+     rw:  rw
      dtype: boolean
      dim: 96
      dim2: [3,32]
      mask: ANT_mask
+     debug: True
 
    - name: RCU_PWR_ANT_on
-     description: Antenna power output ON/OFF control. Monitored by Ant_V.
+     description: Antenna power output ON/OFF control. Monitored by Ant_VOUT.
      driver: I2C_RCU
      devreg:  [IO1.GPIO1,IO1.GPIO1,IO1.GPIO2]
      width: 1
@@ -454,7 +455,7 @@ variables:
      dim2: [3,32]
      mask: ANT_mask
 
-   - name: HBAT_beamformer_delays
+   - name: HBAT_BF_delays
      description: HBAT1 frontend delays (0.5ns steps)
      driver: I2C_HBAT
      devreg:  [HBAT1.XY,HBAT2.XY,HBAT3.XY]
@@ -511,7 +512,7 @@ variables:
      mask: RCU_mask
      
    - name: RCU_ADC_locked
-     description: RCU ADC lock status, 0x81=locked
+     description: RCU ADC lock status. May generated noise and polling disabled in future
      driver: I2C_RCU
      devreg:  [ADC1.PLL_stat,ADC2.PLL_stat,ADC3.PLL_stat]
      width: 1
@@ -552,7 +553,7 @@ variables:
      debug: true
 
    - name: RCU_DTH_freq
-     description: RCU Dither source frequency (Hz)
+     description: RCU Dither source frequency (Hz). Should be around 102MHz.
      driver: I2C_RCU
      devreg:  [DTH1.Freq,DTH2.Freq,DTH3.Freq]
      width: 32
diff --git a/config/UNB2TR.yaml b/config/UNB2TR.yaml
index f1a00b3..af2b56a 100644
--- a/config/UNB2TR.yaml
+++ b/config/UNB2TR.yaml
@@ -105,16 +105,19 @@ variables:
      rw:  ro
      dtype: uint8
      dim: 48
+     dim2: [2,24]
    - name: UNB2TR_I2C_bus_DDR4_error
      driver: switch_QSFP
      rw:  ro
      dtype: uint8
      dim: 8
+     dim2: [2,4]
    - name: UNB2TR_I2C_bus_FPGA_PS_error
      driver: switch_FPGA_PS
      rw:  ro
      dtype: uint8
      dim: 8
+     dim2: [2,4]
    - name: UNB2TR_I2C_bus_PS_error
      driver: switch_PS
      rw:  ro
@@ -248,7 +251,6 @@ variables:
 
 ##Local MP per FPGA node
    - name: UNB2_FPGA_DDR4_SLOT_TEMP
-     description: Signed I2C!
      driver: switch_DDR4
      devreg:  [0x18.0x5,0x19.0x5]
      width: 13
@@ -256,6 +258,7 @@ variables:
      dtype: double
      scale: 0.0625 
      dim: 16
+     dim2: [2,8]
      monitor: true
 
    - name: UNB2_FPGA_DDR4_SLOT_PART_NUMBER
@@ -265,6 +268,7 @@ variables:
      rw:  hidden #ro
      dtype: string
      dim: 16
+     dim2: [2,8]
 #     monitor: true
 
    - name: [UNB2_FPGA_POL_CORE_IOUT,UNB2_FPGA_POL_ERAM_IOUT,UNB2_FPGA_POL_RXGXB_IOUT,UNB2_FPGA_POL_TXGXB_IOUT,UNB2_FPGA_POL_HGXB_IOUT,UNB2_FPGA_POL_PGM_IOUT]
@@ -275,6 +279,7 @@ variables:
      dtype: double
      scale: smbus_2bytes_to_float
      dim: 8
+     dim2: [2,4]
      monitor: true
 
    - name: [UNB2_FPGA_POL_CORE_TEMP,UNB2_FPGA_POL_ERAM_TEMP,UNB2_FPGA_POL_RXGXB_TEMP,UNB2_FPGA_POL_TXGXB_TEMP,UNB2_FPGA_POL_HGXB_TEMP,UNB2_FPGA_POL_PGM_TEMP]
@@ -285,6 +290,7 @@ variables:
      dtype: double
      scale: smbus_2bytes_to_float
      dim: 8
+     dim2: [2,4]
      monitor: true
 
    - name: [UNB2_FPGA_POL_CORE_VOUT]
@@ -296,6 +302,7 @@ variables:
      endian: "<"
      scale: 1.220703125e-4 #2^-13
      dim: 8
+     dim2: [2,4]
      monitor: true
 
    - name: [UNB2_FPGA_POL_ERAM_VOUT,UNB2_FPGA_POL_RXGXB_VOUT,UNB2_FPGA_POL_TXGXB_VOUT,UNB2_FPGA_POL_HGXB_VOUT,UNB2_FPGA_POL_PGM_VOUT]
@@ -307,6 +314,7 @@ variables:
      endian: "<"
      scale: 2.44140625e-4 #2^-12
      dim: 8
+     dim2: [2,4]
      monitor: true
 
    - name: [UNB2_FPGA_POL_CORE_VOUT_MODE,UNB2_FPGA_POL_ERAM_VOUT_MODE,UNB2_FPGA_POL_RXGXB_VOUT_MODE,UNB2_FPGA_POL_TXGXB_VOUT_MODE,UNB2_FPGA_POL_HGXB_VOUT_MODE,UNB2_FPGA_POL_PGM_VOUT_MODE]
@@ -316,13 +324,13 @@ variables:
      rw:  ro
      dtype: uint8
      dim: 8
+     dim2: [2,4]
      debug: true
      monitor: true
 
 
 ##Local MP per FPGA node, QSFP cage
    - name: UNB2_FPGA_QSFP_CAGE_TEMP
-     description: Signed I2C!
      driver: switch_QSFP
      devreg:  0x50.0x16
      width: 16
@@ -331,6 +339,7 @@ variables:
      scale: 3.90625e-3 #1/256
      convert_unit: temp_check
      dim: 48
+     dim2: [2,24]
      monitor: true
 
    - name: UNB2_FPGA_QSFP_CAGE_LOS
@@ -341,6 +350,7 @@ variables:
      rw:  ro
      dtype: uint8
      dim: 48
+     dim2: [2,24]
      monitor: true
 
 methods:
-- 
GitLab