Commit 86cc8cd8 authored by Elisabetta Giani's avatar Elisabetta Giani
Browse files

AT5-262: Multiclass server for MID CspMaster.

Added docker and docker-compose files to build the csp-lmc-mid image.
Added device simulator for PstMaster.
parent 3ca467d5
Loading
Loading
Loading
Loading
+109 −0
Original line number Diff line number Diff line
# -*- coding: utf-8 -*-
#
# This file is part of the PssMasterSimulator project
#
# INAF-SKA Telescope
#
# Distributed under the terms of the GPL license.
# See LICENSE.txt for more info.

""" PssMaster Class simulator

"""

from __future__ import absolute_import
import sys
from collections import defaultdict
import os
import time

file_path = os.path.dirname(os.path.abspath(__file__))
print(file_path)
module_path = os.path.abspath(os.path.join(file_path, os.pardir)) + "/../utils"
print(module_path)
sys.path.insert(0, module_path)

# Tango imports
import tango
from tango import DebugIt
from tango.server import run
from tango.server import Device, DeviceMeta
from tango.server import attribute, command
from tango.server import device_property
from tango import AttrQuality, DispLevel, DevState
from tango import AttrWriteType, PipeWriteType
# Additional import
# PROTECTED REGION ID(DeviceTestMaster.additionnal_import) ENABLED START #
from future.utils import with_metaclass
import threading
from csp_lmc_common.utils.cspcommons import HealthState, AdminMode
from DeviceTestMaster import DeviceTestMaster
# PROTECTED REGION END #    //  DeviceTestMaster.additionnal_import

__all__ = ["PstMasterSimulator", "main"]


class PssMasterSimulator(with_metaclass(DeviceMeta,DeviceTestMaster)):
    """

    **Properties:**

    - Device Property
    """
    # PROTECTED REGION ID(PssMasterSimulator.class_variable) ENABLED START #
    # PROTECTED REGION END #    //  PssMasterSimulator.class_variable

    # -----------------
    # Device Properties
    # -----------------

    # ----------
    # Attributes
    # ----------


    # ---------------
    # General methods
    # ---------------

    def init_device(self):
        """Initialises the attributes and properties of the PssMasterSimulator."""
        DeviceTestMaster.init_device(self)
        # PROTECTED REGION ID(PssMasterSimulator.init_device) ENABLED START #
        # PROTECTED REGION END #    //  PssMasterSimulator.init_device

    def always_executed_hook(self):
        """Method always executed before any TANGO command is executed."""
        # PROTECTED REGION ID(PssMasterSimulator.always_executed_hook) ENABLED START #
        # PROTECTED REGION END #    //  PssMasterSimulator.always_executed_hook

    def delete_device(self):
        """Hook to delete resources allocated in init_device.

        This method allows for any memory or other resources allocated in the
        init_device method to be released.  This method is called by the device
        destructor and by the device Init command.
        """
        # PROTECTED REGION ID(PssMasterSimulator.delete_device) ENABLED START #
        # PROTECTED REGION END #    //  PssMasterSimulator.delete_device
    # ------------------
    # Attributes methods
    # ------------------


    # --------
    # Commands
    # --------

# ----------
# Run server
# ----------


def main(args=None, **kwargs):
    # PROTECTED REGION ID(PssMasterSimulator.main) ENABLED START #
    return run((PssMasterSimulator,), args=args, **kwargs)
    # PROTECTED REGION END #    //  PssMasterSimulator.main

if __name__ == '__main__':
    main()

csp-lmc-mid/Pipfile

0 → 100644
+35 −0
Original line number Diff line number Diff line
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"

[packages]
# numpy and pytango versions must match those in the ska-python-builder image,
# otherwise pytango will be recompiled.
numpy = "==1.17.2"
pytango = "==9.3.1"
# itango is added to make it easier to exercise the device in a CLI session,
# but it's not mandatory. If you remove itango, you should also remove the
# 'RUN ipython profile create' line from Dockerfile.
itango = "*"
# If you want to debug devices running in containers, add pydevd to the dependencies
# pydevd = "*"

[dev-packages]
docutils = "*"
MarkupSafe = "*"
Pygments = "*"
pylint = "*"
pytest = "*"
pytest-cov = "*"
pytest-pylint = "*"
pytest-json-report = "*"
python-dotenv = ">=0.5.1"
ptvsd = "*"
Sphinx = "*"
sphinx_rtd_theme = "*"
sphinx-autobuild = "*"
sphinxcontrib-websupport = "*"

[requires]
python_version = "3"
+16 −0
Original line number Diff line number Diff line
from tango.server import run
import os
import sys
#file_path = os.path.dirname(os.path.abspath(__file__))
#pkg_path = os.path.abspath(os.path.join(file_path, "./"))
#sys.path.insert(0, pkg_path)

from MidCspMasterBase import MidCspMasterBase
from csp_lmc_common.CspCapabilityMonitor import CspCapabilityMonitor

def main(args=None, **kwargs):
    return run(classes=(MidCspMasterBase, CspCapabilityMonitor), args=args, **kwargs)


if __name__ == '__main__':
    main()
+0 −1
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ class MidCspMasterBase(with_metaclass(DeviceMeta, CspMaster)):
    - Device Property
    
    """
    __metaclass__ = DeviceMeta
    # PROTECTED REGION ID(MidCspMasterBase.class_variable) ENABLED START #
    # PROTECTED REGION END #    //  MidCspMasterBase.class_variable

+106 −0
Original line number Diff line number Diff line
#!/bin/bash
#
#   Copyright 2015  Xebia Nederland B.V.
#   Modifications copyright 2019 SKA Organisation
#
#   Licensed under the Apache License, Version 2.0 (the "License");
#   you may not use this file except in compliance with the License.
#   You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#   Unless required by applicable law or agreed to in writing, software
#   distributed under the License is distributed on an "AS IS" BASIS,
#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
#   See the License for the specific language governing permissions and
#   limitations under the License.
#
function hasChanges() {
	test -n "$(git status -s .)"
}

function getRelease() {
	awk -F= '/^release=/{print $2}' .release
}

function getBaseTag() {
		sed -n -e "s/^tag=\(.*\)$(getRelease)\$/\1/p" .release
}

function getTag() {
	if [ -z "$1" ] ; then
		awk -F= '/^tag/{print $2}' .release
	else
		echo "$(getBaseTag)$1"
	fi
}

function setRelease() {
	if [ -n "$1" ] ; then
		sed -i.x -e "s/^tag=.*/tag=$(getTag $1)/" .release
		sed -i.x -e "s/^release=.*/release=$1/g" .release
		rm -f .release.x
		runPreTagCommand "$1"
	else
		echo "ERROR: missing release version parameter " >&2
		return 1
	fi
}

function runPreTagCommand() {
	if [ -n "$1" ] ; then
		COMMAND=$(sed -n -e "s/@@RELEASE@@/$1/g" -e 's/^pre_tag_command=\(.*\)/\1/p' .release)
		if [ -n "$COMMAND" ] ; then
			if ! OUTPUT=$(bash -c "$COMMAND" 2>&1) ; then echo $OUTPUT >&2 && exit 1 ; fi
		fi
	else
		echo "ERROR: missing release version parameter " >&2
		return 1
	fi
}

function tagExists() {
	tag=${1:-$(getTag)}
	test -n "$tag" && test -n "$(git tag | grep "^$tag\$")"
}

function differsFromRelease() {
	tag=$(getTag)
	! tagExists $tag || test -n "$(git diff --shortstat -r $tag .)"
}

function getVersion() {
	result=$(getRelease)

	if differsFromRelease; then
		result="$result-$(git log -n 1 --format=%h .)"
	fi

	if hasChanges ; then
		result="$result-dirty"
	fi
	echo $result
}

function nextPatchLevel() {
	version=${1:-$(getRelease)}
	major_and_minor=$(echo $version | cut -d. -f1,2)
	patch=$(echo $version | cut -d. -f3)
	version=$(printf "%s.%d" $major_and_minor $(($patch + 1)))
	echo $version
}

function nextMinorLevel() {
	version=${1:-$(getRelease)}
	major=$(echo $version | cut -d. -f1);
	minor=$(echo $version | cut -d. -f2);
	version=$(printf "%d.%d.0" $major $(($minor + 1))) ;
	echo $version
}

function nextMajorLevel() {
	version=${1:-$(getRelease)}
	major=$(echo $version | cut -d. -f1);
	version=$(printf "%d.0.0" $(($major + 1)))
	echo $version
}
Loading