Commit 6f77c0a4 authored by Fabio Vitello's avatar Fabio Vitello
Browse files

fix-issue #595 Noto IFDistributor

- Added Help command for if command
- Changed parser for ifdist to accept 4 parameters
- Send command to ifdistributor
parent 3ba60428
Loading
Loading
Loading
Loading
+27 −0
Original line number Diff line number Diff line
@@ -416,6 +416,33 @@ def help(command):
        print 'e.g. > help(setupCCB)'
        print 'help() (without argument) lists all the available commands'


def ifdist():
    """
    ifdist=input1,input2,att1,att2
    allowed values for input1:
    0 nessun ingresso selezionato
    1 ricevitore in vertex Right Pol
    2 ricevitore L Right Pol
    3 ricevitore X Right Pol
    4 ricevitore S Right Pol
    5 spare1
    6 spare2

    allowed values for input2:
    0 nessun ingresso selezionato
    1 ricevitore in vertex Left Pol
    2 ricevitore L Left Pol
    3 ricevitore X Left Pol
    4 ricevitore S Left Pol
    5 ricevitore S Right Pol (per oss. geo)
    6 spare1

    allowed values for att1 e att2:
    from 0 to 63, each step is 0.5 dB

    """

def initialize():
    """
    initialize=code 
+1 −1
Original line number Diff line number Diff line
@@ -141,7 +141,7 @@ void CCore::execute() throw(ComponentErrors::TimerErrorExImpl, ComponentErrors::
	// m_parser->add("ifd","_ifd",1,"SRT");
	m_parser->add("calmux", "_calmux", 1);
	m_parser->add("dmed", "_dmed", 1, "Medicina");
	m_parser->add("ifdist", "_ifdist", 1, "Noto");
	m_parser->add("ifdist", "_ifdist", 4, "Noto");

	m_parser->add("restFrequency", new function1<CCore, non_constant, void_type, I<doubleSeq_type> >(this, &CCore::_setRestFrequency), 1);
	m_parser->add("fTrack", new function1<CCore, non_constant, void_type, I<string_type> >(this, &CCore::_fTrack), 1);
+28 −12
Original line number Diff line number Diff line
@@ -52,6 +52,7 @@ import maciErrType
import cdbErrType
import maciErrTypeImpl
import ManagementErrorsImpl
import ComponentErrorsImpl
from IRAPy import logger,userLogger
from SimpleParserPy import add_user_message
import xml.etree.ElementTree as ET
@@ -61,6 +62,7 @@ import socket
import time
from collections import namedtuple


def send_command(ip, port, command):
	s=socket.socket(socket.AF_INET, socket.SOCK_STREAM)
	try:
@@ -76,8 +78,6 @@ def send_command(ip, port, command):

def cdb(xmlstr):
	root=ET.fromstring(xmlstr)
	print root.items()[0][1]
	print root.items()[1][1]
	return root.items()[0][1],root.items()[1][1]
	
def main(argv):
@@ -115,15 +115,31 @@ def main(argv):
		sys.exit(1)
	
	
	userLogger.logNotice("IFDist setup according to %s configuration"%(argv[0]))	
	parameters = ['input1','input2','att1','att2']
	for i in range(0,len(argv)):
		if argv[i] != '-1':
			commandstr = parameters[i]+","+argv[i]
			userLogger.logNotice("IFDist setup according to %s command"%(commandstr))
			answer=send_command(ip,port, commandstr)
			
	if not found:
		newEx = ComponentErrorsImpl.ValidationErrorExImpl()
		add_user_message(newEx,"The required IFDist configuration is not known")
			if answer=="Fail":
				newEx = ComponentErrorsImpl.SocketErrorExImpl()
				add_user_message(newEx,"Unable to communicate to IFDist")
				userLogger.logException(newEx)
				simpleClient.disconnect()
				sys.exit(1)

			elif answer[0]=="NAK":				 
				newEx = ComponentErrorsImpl.NakExImpl()
				add_user_message(newEx,"IFDist command error")
				userLogger.logException(newEx)
				simpleClient.disconnect()
				sys.exit(1)

			else:
				userLogger.logNotice( "Answer: %s"%(answer))


if __name__=="__main__":
   main(sys.argv[1:])  
	
 No newline at end of file