Commit 07ea8a18 authored by Gino Tosti's avatar Gino Tosti
Browse files

fix minor bugs and added some more functions to the py scripts

parent 79a71661
......@@ -6,7 +6,7 @@
Name="ARCHIVE/TMCDB/MONITOR_BLOBBER"
Code="alma.acs.monitoring.blobber.BlobberHelper"
Type="IDL:alma/MonitorArchiver/Blobber:1.0"
Container="monColTestCont"
Container="frodoContainer"
Default="true"
ImplLang="java" />
......
......@@ -4,10 +4,10 @@
xmlns:baci="urn:schemas-cosylab-com:BACI:1.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<e Name="MONITOR_COLLECTOR_TEST"
Code="MonitorCollector"
Code="alma.TMCDB.MonitorCollectorImpl.MonitorCollectorComponentHelper"
Type="IDL:alma/TMCDB/MonitorCollector:1.0"
ImplLang="cpp"
Container="bilboContainer" />
ImplLang="java"
Container="frodoContainer" />
</Components>
......@@ -7,7 +7,7 @@
opc_url="$URL"
macAddress="00:00:00:00:00:00"
SerialNumber="${Assembly}01"
MonitoringCollectorName="TBD"
MonitoringCollectorName="MONITOR_COLLECTOR_TEST"
retries="3"
timeoutRxTx="2.0">
#silent L=[]
......@@ -19,21 +19,33 @@
#set $type=$x.GetSheet["OPC UA Data type"][$idx].upper()
#end if
<$x.GetSheet["Short name"][$idx] xmlns="urn:schemas-cosylab-com:${Assembly}Base:1.0"
#if $x.GetSheet["IsArchived"][$idx].upper() =="N"
archive_suppress="true"
#else
#if str($x.GetSheet["IsMonitored"][$idx]).upper() =="Y"
archive_priority="5"
archive_min_int="15"
archive_max_int="15"
#if $x.GetSheet["IsArchived"][$idx].upper() =="N"
archive_suppress="1"
#end if
#end if
#if str($x.GetSheet["Default value"][$idx]) !="" and str($x.GetSheet["Default value"][$idx]) !="NA"
#if $type[0]=="I" or $type[0]=="U"
#set $val=str($x.GetSheet["Default value"][$idx]).split(".")[0]
#if str($x.GetSheet["Default value"][$idx]) !="" and str($x.GetSheet["Default value"][$idx]) !="NA" and str($x.GetSheet["Default value"][$idx]) !="nan"
#if $type[0]=="B"
#set $val=str($x.GetSheet["Default value"][$idx]).split(".")[0]
#if $val =="1"
default_value="true"
#else
default_value="false"
#end if
#elif $type[0]=="I" or $type[0]=="U"
#set $val=str($x.GetSheet["Default value"][$idx]).split(".")[0]
default_value="$val"
#else
#set $val=str($x.GetSheet["Default value"][$idx]).lower()
#set $val=str($x.GetSheet["Default value"][$idx]).lower()
default_value="$val"
#end if
#end if
#end if
format="%$y[$type][1]"
description="$x.GetSheet["Description"][$idx]"
#if str($x.GetSheet["Unit"][$idx]) !="" and str($x.GetSheet["Unit"][$idx]) !="NA" and str($x.GetSheet["Unit"][$idx]) !="nan"
......@@ -41,7 +53,7 @@
#else
units="none"
#end if
#if str($x.GetSheet["Alarm high"][$idx]) !="nan" and str($x.GetSheet["Alarm high"][$idx]).strip() !="NA" and $y[$type][1] != "S"
#if str($x.GetSheet["Alarm high"][$idx]) !="nan" and str($x.GetSheet["Alarm high"][$idx]).strip() !="NA" and $y[$type][1] != "S" and $y[$type][1] != "B"
#if $type[0]=="I" or $type[0]=="U"
#set $val=str($x.GetSheet["Alarm high"][$idx]).split(".")[0]
alarm_high_on="$val"
......@@ -50,8 +62,8 @@
alarm_high_on="$x.GetSheet["Alarm high"][$idx]"
alarm_high_off="$x.GetSheet["Alarm high"][$idx]"
#end if
#end if
#if str($x.GetSheet["Alarm low"][$idx]).strip() !="nan" and str($x.GetSheet["Alarm low"][$idx]).strip() !="NA" and $y[$type][1] != "S"
#end if
#if str($x.GetSheet["Alarm low"][$idx]).strip() !="nan" and str($x.GetSheet["Alarm low"][$idx]).strip() !="NA" and $y[$type][1] != "S" and $y[$type][1] != "B"
#if $type[0]=="I" or $type[0]=="U"
#set $val=str($x.GetSheet["Alarm low"][$idx]).split(".")[0]
alarm_low_on="$val"
......@@ -65,7 +77,7 @@
#set $val=str($x.GetSheet["Sampling Interval (s)"][$idx])
min_timer_trig="1.0"
alarm_timer_trig="10.0"
#if $val!="NA"
#if $val!="NA" and $val!="nan"
default_timer_trig="$val"
#else
default_timer_trig="1.0"
......@@ -90,9 +102,17 @@
<$x.SetSheet["Short name"][$idx] xmlns="urn:schemas-cosylab-com:${Assembly}Base:1.0"
archive_min_int="0"
archive_max_int="0"
archive_suppress="1"
#if str($x.SetSheet["Default value"][$idx]) !="" and str($x.SetSheet["Default value"][$idx]) !="NA"
#if $type[0]=="I" or $type[0]=="U"
archive_suppress="true"
#if str($x.SetSheet["Default value"][$idx]) !="" and str($x.SetSheet["Default value"][$idx]) !="NA" and str($x.SetSheet["Default value"][$idx]) !="nan"
#if $type[0]=="B"
#set $val=str($x.SetSheet["Default value"][$idx]).split(".")[0]
#if $val =="1"
default_value="true"
#else
default_value="false"
#end if
#elif $type[0]=="I" or $type[0]=="U"
#set $val = str($x.SetSheet["Default value"][$idx]).split(".")[0]
default_value="$val"
#else
......@@ -112,7 +132,7 @@
min_delta_trig="0"
min_step="1"
#end if
default_timer_trig="1"
default_timer_trig="0"
resolution="1"/>
#end for
#for $idx in $range(0,$x.ModeSheet["NRows"])
......@@ -121,7 +141,7 @@
<$name xmlns="urn:schemas-cosylab-com:${Assembly}Base:1.0"
archive_min_int="0"
archive_max_int="0"
archive_suppress="1"
archive_suppress="true"
default_value="0"
format="%${y[$x.ModeSheet["OPC UA Data type"][$idx].upper()][1]}"
description="$x.ModeSheet["Description"][$idx]"
......@@ -135,7 +155,7 @@
min_delta_trig="0"
min_step="1"
#end if
default_timer_trig="1"
default_timer_trig="0"
resolution="1"/>
#silent L.append($name)
#end if
......@@ -146,7 +166,7 @@
<$name xmlns="urn:schemas-cosylab-com:${Assembly}Base:1.0"
archive_min_int="0"
archive_max_int="0"
archive_suppress="1"
archive_suppress="true"
default_value="0"
format="%%${y[$x.CmdSheet["OPC UA Data type"][$idx].upper()][1]}"
description="$x.CmdSheet["Description"][$idx]"
......@@ -160,7 +180,7 @@
min_delta_trig="0"
min_step="1"
#end if
default_timer_trig="1"
default_timer_trig="0"
resolution="1"/>
#silent L.append($name)
#end if
......
......@@ -22,10 +22,10 @@ import TCL.HardwareDevice
from TCL.Container import getComponent
from TCL.Container import getDynamicComponent
from TCL.logging import getLogger
telName="Dummy"
class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
def __init__(self, telescopeName = None, componentName = None, stickyFlag = False):
def __init__(self, telescopeName = None, componentName = "${Assembly}", stickyFlag = False):
"""
The constructor creates a ${Assembly} object or a group of ${Assembly}
objects.
......@@ -62,7 +62,7 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
self._devices = {}
## Group of telescopes or component names.
if ((isinstance(telescopeName, list) == True) or
"""if ((isinstance(telescopeName, list) == True) or
(isinstance(componentName, list) == True)):
## Telescopes names
if isinstance(telescopeName, list) == True:
......@@ -83,8 +83,8 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
if telescopeName != None:
self._devices["SCADA/" + telescopeName + "/"+"${Assembly}"] = ""
if componentName != None:
"""
if componentName != None:
self._devices[componentName] = ""
## Initialize the base class
......@@ -110,7 +110,7 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
"""
result = {}
for key, val in self._devices.items():
telName = key.rsplit("/")[1]
##telName = key.rsplit("/")[1]
result[telName] = self._devices[key].${x["Name of command"][$idx]}()
values = [*result.values()]
if len(self._devices) == 1:
......@@ -131,7 +131,7 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
"""
result = {}
for key, val in self._devices.items():
telName = key.rsplit("/")[1]
##telName = key.rsplit("/")[1]
result[telName] = self._devices[key].${y["Name of command"][$idx]}(arg)
values = [*result.values()]
if len(self._devices) == 1:
......@@ -140,6 +140,15 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
#end for
def callAllGet(self):
result=[]
for name in self.__dir__():
if "GET_" in name:
print("Calling {}".format(name))
res=self.__getattribute__(name)()
result.append({'value':res[0],'time':res[1]})
return result
\# ----------------- List of Monitor Points ------------------
def getMonitorList(self):
"""
......@@ -148,7 +157,7 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
"""
result = {}
for key, val in self._devices.items():
telName = key.rsplit("/")[1]
##telName = key.rsplit("/")[1]
monitorList = []
#for $idx in $range(0,$x["NRows"])
monitorList.append("$x["Short name"][$idx] --> xx.GET_${x["Short name"][$idx]}()")
......@@ -167,7 +176,7 @@ class ${Assembly}Base(TCL.HardwareDevice.HardwareDevice):
"""
result = {}
for key, val in self._devices.items():
telName = key.rsplit("/")[1]
##telName = key.rsplit("/")[1]
setList = []
#for $idx in $range(0,$y["NRows"])
setList.append("$y["Short name"][$idx] --> xx.SET_${y["Short name"][$idx]}(val)")
......
......@@ -88,9 +88,9 @@ def build(mygen):
def checkCDB(mygen):
pwd=os.getcwd()
#os.chdir(mygen._dirs['test'])
print ("Check CDB in", os.getcwd())
command="./setCDB.sh ; cdbChecker"
command= "source "+mygen._dirs['test']+"setCDB.sh ; cdbChecker"
print ("Executing:",command,'\n',"...Please wait....")
if execACSCommand(command):
print ("ERROR executing: ",command)
......
#! /usr/bin/env python
from Cheetah.Template import Template
from datetime import date
import sys,os
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment