From 73b16fccd06f141dbbc4404c428dd9cb4d7f26be Mon Sep 17 00:00:00 2001
From: Andrea Orlati <aorlati@users.noreply.github.com>
Date: Fri, 14 Mar 2025 09:58:01 +0100
Subject: [PATCH] Fix #902, added configuration for Noto (#903)

* fix issue #902: fixed an issue, related to the porting to python 3 for the Noto LocalOscillator component

* fix issue #902: changed totalpower, weather station configuration and IfDistributr python code (ported to python 3)

* fix issue #902: small fix as requested in Pull Request review

* fix issue #902: adjusted attenutaions in setup procedure for primary band recevier

---------

Co-authored-by: Andrea Orlati <a.orati@ira.inaf.it>
---
 .../RECEIVERS/NotoReceivers/NotoReceivers.xml  |  3 ++-
 .../BACKENDS/TotalPower/TotalPower.xml         |  1 +
 .../alma/BACKENDS/TotalPower/TotalPower.xml    |  2 +-
 .../alma/DataBlock/TotalPower/TotalPower.xml   |  2 +-
 .../StationProcedures/StationProcedures.xml    | 12 ++++++------
 .../WeatherStation/WeatherStation.xml          |  2 +-
 .../Servers/NotoPyIfDistributor/src/_ifdist.py |  6 +++---
 .../src/NotoLocalOscillatorImpl/CommandLine.py | 18 +++++++++++++-----
 .../NotoLocalOscillator.py                     | 10 +++-------
 9 files changed, 31 insertions(+), 25 deletions(-)

diff --git a/Noto/CDB/alma/RECEIVERS/NotoReceivers/NotoReceivers.xml b/Noto/CDB/alma/RECEIVERS/NotoReceivers/NotoReceivers.xml
index f8b91490f..e18478c1b 100644
--- a/Noto/CDB/alma/RECEIVERS/NotoReceivers/NotoReceivers.xml
+++ b/Noto/CDB/alma/RECEIVERS/NotoReceivers/NotoReceivers.xml
@@ -2,6 +2,7 @@
 <!--
    - History:
    - 17 - 11 -2016 created Andrea Orlati (a.orlati@ira.inaf.it)
+   LocalOscillatorInstance="RECEIVERS/LocalOscillator"
 -->
 
 <NotoReceivers xmlns="urn:schemas-cosylab-com:NotoReceivers:1.0" 
@@ -10,7 +11,7 @@
 				xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"   
 				HPIBIPAddress="192.167.187.201"
 				HPIBPort="1234"
-				LocalOscillatorInstance="RECEIVERS/LocalOscillator"
+				LocalOscillatorInstance=""
 				LocalOscillatorEnabledReceivers="KKC QQC CCC MMC"				
 				FocusSelectorInterface="IDL:alma/Backends/TotalPower:1.0"
 >
diff --git a/Noto/Configuration/CDB/MACI/Components/BACKENDS/TotalPower/TotalPower.xml b/Noto/Configuration/CDB/MACI/Components/BACKENDS/TotalPower/TotalPower.xml
index ba08992d6..36c714432 100644
--- a/Noto/Configuration/CDB/MACI/Components/BACKENDS/TotalPower/TotalPower.xml
+++ b/Noto/Configuration/CDB/MACI/Components/BACKENDS/TotalPower/TotalPower.xml
@@ -12,6 +12,7 @@
 	Code="TotalPowerImpl"
 	Type="IDL:alma/Backends/TotalPower:1.0"
 	Container="TotalPowerContainer"
+    Default="true"
 	KeepAliveTime="-1"
     ImplLang="cpp"
 />
diff --git a/Noto/Configuration/CDB/alma/BACKENDS/TotalPower/TotalPower.xml b/Noto/Configuration/CDB/alma/BACKENDS/TotalPower/TotalPower.xml
index 05b5037dc..67ceeff70 100644
--- a/Noto/Configuration/CDB/alma/BACKENDS/TotalPower/TotalPower.xml
+++ b/Noto/Configuration/CDB/alma/BACKENDS/TotalPower/TotalPower.xml
@@ -18,7 +18,7 @@
                RepetitionCacheTime="2000000"
                RepetitionExpireTime="5000000"
                DataPort="9001"
-               DataIPAddress="192.167.187.40"
+               DataIPAddress="192.167.187.17"
                DataLatency="3000000"
                SenderSleepTime="300000"
                SenderResponseTime="1000000"
diff --git a/Noto/Configuration/CDB/alma/DataBlock/TotalPower/TotalPower.xml b/Noto/Configuration/CDB/alma/DataBlock/TotalPower/TotalPower.xml
index bb03202f4..d0c6a31ee 100644
--- a/Noto/Configuration/CDB/alma/DataBlock/TotalPower/TotalPower.xml
+++ b/Noto/Configuration/CDB/alma/DataBlock/TotalPower/TotalPower.xml
@@ -80,7 +80,7 @@
 	<sections>2</sections>
 	<calSwitchingEnabled>FALSE</calSwitchingEnabled>
 	<inputPort>GREGORIAN</inputPort>
-	<inputPortDB>3</inputPortDB>
+	<inputPortDB>9</inputPortDB>
 	<inputPortBW>730</inputPortBW>
 	<beams>1</beams>
 	<section_boards>0 1</section_boards>
diff --git a/Noto/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml b/Noto/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml
index 95447e60d..239e801a7 100644
--- a/Noto/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml
+++ b/Noto/Configuration/CDB/alma/Procedures/StationProcedures/StationProcedures.xml
@@ -88,7 +88,7 @@
     ifdist=1,3,-1
     ifdist=2,3,-1
 	ifdist=1,-1,10
-	ifdist=2,-1,10
+	ifdist=2,-1,11
 </body>
 </Procedure>
 
@@ -121,8 +121,8 @@
     calOff
     ifdist=1,2,-1
     ifdist=2,2,-1
-	ifdist=1,-1,44
-	ifdist=2,-1,44
+	ifdist=1,-1,22
+	ifdist=2,-1,22
 </body>
 </Procedure>
 
@@ -138,8 +138,8 @@
     calOff
     ifdist=1,4,-1
     ifdist=2,4,-1
-	ifdist=1,-1,8
-	ifdist=2,-1,8
+	ifdist=1,-1,10
+	ifdist=2,-1,10
 </body>
 </Procedure>
 
@@ -155,7 +155,7 @@
     calOff
     ifdist=1,5,-1
     ifdist=2,3,-1
-	ifdist=1,-1,8
+	ifdist=1,-1,10
 	ifdist=2,-1,10
 </body>
 </Procedure>
diff --git a/Noto/Configuration/CDB/alma/WEATHERSTATION/WeatherStation/WeatherStation.xml b/Noto/Configuration/CDB/alma/WEATHERSTATION/WeatherStation/WeatherStation.xml
index 725206827..22b444117 100644
--- a/Noto/Configuration/CDB/alma/WEATHERSTATION/WeatherStation/WeatherStation.xml
+++ b/Noto/Configuration/CDB/alma/WEATHERSTATION/WeatherStation/WeatherStation.xml
@@ -6,7 +6,7 @@
                 xmlns:baci="urn:schemas-cosylab-com:BACI:1.0"
                 xmlns:cdb="urn:schemas-cosylab-com:CDB:1.0"
                 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-                IPAddress="192.167.187.103"
+                IPAddress="192.167.187.244"
                 port="22222"
                 UpdatingThreadTime="10000000">
 	
diff --git a/Noto/Servers/NotoPyIfDistributor/src/_ifdist.py b/Noto/Servers/NotoPyIfDistributor/src/_ifdist.py
index 0cf6da920..72d40a4b2 100644
--- a/Noto/Servers/NotoPyIfDistributor/src/_ifdist.py
+++ b/Noto/Servers/NotoPyIfDistributor/src/_ifdist.py
@@ -31,12 +31,12 @@ def send_command(ip, port, command):
 		s.connect((ip,int(port)))
 	except socket.error:
 		return "Fail"
-	s.sendall(command)
+	s.sendall(command.encode())
 	time.sleep(0.1)
 	response=s.recv(1024)
 	s.close()
-	response=response.strip().split('\n')
-	return response
+	res=response.decode().strip().split('\n')
+	return res
 
 def cdb(xmlstr):
 	root=ET.fromstring(xmlstr)
diff --git a/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/CommandLine.py b/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/CommandLine.py
index b9b658198..e534a5614 100644
--- a/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/CommandLine.py
+++ b/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/CommandLine.py
@@ -32,7 +32,7 @@ class CommandLine:
    
 	def initialize(self):
 		#raises an error.....
-		self.create()   
+		return self.create()   
    
 	def configure(self,ip,port):
 		'''
@@ -42,7 +42,7 @@ class CommandLine:
 		self.ip=ip
 		self.port=port
 		#raises an error.....
-		self.connect() 
+		return self.connect() 
 			
 	def create(self):
 		try:
@@ -63,10 +63,17 @@ class CommandLine:
 	def connect(self):
 		try:
 			if self.connected==False:
+				#print ("PRovo la connessione")
 				self.sock.connect((self.ip,self.port))
+				#print ("Conessione ok")
 				self.connected=True
-				self.sock.sendall('*CLS\n;SYST:ERR?\n++read\n')
+				cmd="*CLS\n;SYST:ERR?\n++read\n"
+				#print ("mando stringa di inizializzazione")
+				self.sock.sendall(cmd.encode())
+				#print ("mandata")
 				msg=self.sock.recv(1024)
+				#print ("ricevuta risposta :")
+				#print (msg)
 		except socket.error as msg:
 			self.close()
 			return False
@@ -169,7 +176,7 @@ class CommandLine:
 		msg=""
 		if self.check():			
 			try:
-				self.sock.sendall(cmd)
+				self.sock.sendall(cmd.encode())
 			except socket.error as msg:
 				self.close()
 				return False,msg
@@ -181,7 +188,8 @@ class CommandLine:
 		msg=""
 		if self.check():			
 			try:
-				self.sock.sendall(cmd+'\n++read\n')
+				buff=cmd+'\n++read\n'
+				self.sock.sendall(cmd.encode())
 			except socket.error as msg:
 				self.close()
 				return False,msg
diff --git a/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/NotoLocalOscillator.py b/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/NotoLocalOscillator.py
index 1770e98cc..f2126f17b 100644
--- a/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/NotoLocalOscillator.py
+++ b/Noto/Servers/NotoPyLocalOscillator/src/NotoLocalOscillatorImpl/NotoLocalOscillator.py
@@ -99,16 +99,12 @@ class NotoLocalOscillator(Receivers__POA.LocalOscillator, CharacteristicComponen
 		except Exception:
 			exc=ComponentErrorsImpl.CDBAccessExImpl()
 			raise exc
-		try:
-			self.cl.initialize()
-		except CommandLineError as ex:
+		if not self.cl.initialize():
 			exc=ComponentErrorsImpl.SocketErrorExImpl()
 			exc.setData('Reason',ex.__str__)
 			raise exc
-		try:
-			self.cl.configure(IP,PORT)
-		except CommandLineError as ex:
-			msg="cannot connect to synthesiser, IP %s, error message is %s" %(IP,ex.__str__)
+		if not self.cl.configure(IP,PORT):
+			msg="cannot connect to synthesiser, IP %s, PORT %s" %(IP,PORT)
 			exc=ComponentErrorsImpl.SocketErrorExImpl()
 			exc.setData('Reason',msg)
 			raise exc	
-- 
GitLab