Commit 9466d39c authored by Giuseppe Carboni's avatar Giuseppe Carboni Committed by GitHub
Browse files

Fix issues from 366 to 369. See changelog below. (#371)

* Fix issues from 366 to 369. See changelog below.

Fix #366, now the PyCalmux component is kept alive after it's initially instanced. This prevents setting the default configuration to the controlled device every time the component is referenced after it was previously released.
Fix #367, PyCalmux connection to its controlled device is now handled in a smarter way to prevent failing to open a new connection right after a previous one was closed.
Resolve #368, the PyCalmux setup method now can be called from the OperatorInput using the `calmux=<backend_name>` command.
Resolve #369, the Noto StationProcedures now execute the `calmux=TotalPower` command. It means that when a procedure command is issued (i.e.: `setupKKC`), the CalMux device sets the TotalPower backend as the source of the calibration noise mark by default.

* Fixed some indentation consistency in CHANGELOG.md

* Added PyCalmuxContainer to Noto discosStartup.xml
parent 6932e627
Loading
Loading
Loading
Loading
+17 −3
Original line number Diff line number Diff line
@@ -18,10 +18,19 @@ and this project adheres to [Semantic Versioning](http://semver.org/
	issue #323 - The metClient moved to common part as it is now the general cleint for weather stations. 
	Also the autopark wind threshld is now read from confiugration and not hardcoded.

  issue #324 - full support for CHC receiver at Medicina telescope now added.The receiver will be avaiable 
	issue #324 - full support for CHC receiver at Medicina telescope now added.The receiver will be available
	under two diffent configurations: 1.2 GHz and 150MHz bandwidth. The respective setup are achived by issueing
	the following procedures "SETUPCHC" and "SETUPCHCL".  

	issue #361 - written the PyCalMux component and integrated into the Noto line. Station procedures now execute
	the `calmux=<configuration>` script in order to commute to the TotalPower noise calibration channel.

	issue #368 - added a `calmux` command to the OperatorInput commands list. Internally it calls the `setup`
	method of the PyCalmux component.

	issue #369 - Now the Noto StationProcedures performs a default setup to the CalMux device letting it set the
	calibration noise mark coming from TotalPower as the default one.

### Changed

	issue #316 - several related commits. The operation releated to the Medicina K band receivers now relys on a
@@ -29,10 +38,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/
	servants.
	
	issue #301 - Noto Weather station has now Generic interface. in this way the MeteoClient can be used in Noto
	as wll as Medicina and SRT
	as wll as Medicina and SRT.

### Fixed 

## 
	issue #366 - Now the PyCalmux component is kept alive after it gets instanced for the first time in order to
	avoid setting the default values to the controlled device every time the component is retrieved from some
	outside code/program.

	issue #367 - The PyCalmux component now uses a smarter way to open a socket to the CalMux device in order to
	avoid raising unwanted socket errors.

## 
+2 −1
Original line number Diff line number Diff line
@@ -6,6 +6,7 @@
#ifndef __CAL_MUX_IDL__ 
#define __CAL_MUX_IDL__ 

#include <baci.idl>
#include <ComponentErrors.idl>
#include "CalDiodeController.idl"

@@ -14,7 +15,7 @@

module Backends {
 
    interface CalMux : CalDiodeController
    interface CalMux : CalDiodeController, ACS::CharacteristicComponent
    {
        /** Take the backend name and configurate the component
         *
+11 −4
Original line number Diff line number Diff line
@@ -33,13 +33,14 @@ class PyCalmuxImpl(CalMux, cc, services, lcycle):

        try:
            self.calOff()
        except ComponentErrorsImpl.SocketErrorExImpl, ex:
        except Exception:
            pass

    def cleanUp(self):
        pass

    def setup(self, backend_name):
        backend_name = backend_name.lower()
        try:
            channel, polarity = self.mapping[backend_name]
        except KeyError:
@@ -129,9 +130,14 @@ class PyCalmuxImpl(CalMux, cc, services, lcycle):
        :param command: the command to be sent to the device.
        """
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
        try:
            s.connect((self.attributes['IP'], self.attributes['PORT']))
        except socket.error:
        connected = 1
        t0 = time.time()
        while time.time() - t0 < 2:
            connected = s.connect_ex((self.attributes['IP'], self.attributes['PORT']))
            if connected == 0:
                break
            time.sleep(0.01)
        if connected:
            reason = 'Could not reach the device!'
            logger.logError(reason)
            exc = ComponentErrorsImpl.SocketErrorExImpl()
@@ -204,6 +210,7 @@ class PyCalmuxImpl(CalMux, cc, services, lcycle):
            children = ElementTree.fromstring(dao).getchildren()
            for child in children:
                backend, channel, polarity = [c.text.strip() for c in child]
                backend = backend.lower()
                value = (int(channel), int(polarity))
                if backend in self.mapping:
                    self.mapping[backend].update(value)
+2 −1
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@

CDB_SCHEMAS = PyCalmux

PY_SCRIPTS =
PY_SCRIPTS = _calmux
PY_MODULES =
PY_PACKAGES = Calmux

@@ -36,6 +36,7 @@ man : do_man
	@echo " . . . man page(s) done"

install : install_all
	@chmod 700 $(INTROOT)/bin/_calmux
	@echo " . . . installation done"

#___oOo___
+46 −0
Original line number Diff line number Diff line
#!/usr/bin/env python

# This is a python script that can be used to configure the noise calibration
# multiplexer
# who                                         when           what
# Giuseppe Carboni(giuseppe.carboni@inaf.it)  03/04/2019     Creation

from Acspy.Clients.SimpleClient import PySimpleClient
import ACSLog
import maciErrType
import maciErrTypeImpl
import ClientErrorsImpl
import ManagementErrorsImpl
import sys
import os
from IRAPy import logger, userLogger
from SimpleParserPy import add_user_message

def main():
    compName = 'BACKENDS/PyCalmux'

    simpleClient = PySimpleClient()

    try:
        component = simpleClient.getComponent(compName)
    except Exception as ex:
        newEx = ClientErrorsImpl.CouldntAccessComponentExImpl(exception=ex, create=1)
        newEx.setComponentName(compName)
        add_user_message(newEx, 'PyCalmux device not ready or not properly configured')
        userLogger.logException(newEx)
        simpleClient.disconnect()
        sys.exit(1)

    try:
        inputs = component.setup(sys.argv[1])
    except Exception as ex:
        newEx = ClientErrorsImpl.CouldntPerformActionExImpl(exception=ex, create=1)
        newEx.setReason('PyCalmux configuration')
        add_user_message(newEx, 'Unable to configure the PyCalmux device')
        userLogger.logException(newEx)
        simpleClient.disconnect()
        sys.exit(1)


if __name__ == "__main__":
    main()    
Loading