Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • cs/ds/alarm-handler
  • francesco.tripaldi/alarm-handler
2 results
Show changes
Showing
with 4013 additions and 0 deletions
#!/usr/bin/python
#
import sys,re
#import PyTango
from PyTango import *
import time
import string
if __name__ == "__main__":
Device = False
Conf = False
File = False
#PrepareState = False
for arg in sys.argv:
word = '([a-z0-9._\-\*]*)'
wordpath = '([a-z0-9._\-\*/]*)'
m = re.compile("--device=" + word + "/{0,1}" + word + "/{0,1}" + word).match(arg.lower())
if m is not None:
domain = m.groups()[0]
family = m.groups()[1]
member = m.groups()[2]
if domain == '':
domain = '*'
if family == '':
family = '*'
if member == '':
member = '*'
Device = True
#formula = '([a-z0-9._,\*,\-,\|,\/,\",\s,\t]*)'
formula = '(.*)'
m = re.compile("--conf=" + formula).match(arg)
if m is not None:
alarm_rule = m.groups()[0]
Conf = True
#m = re.compile("--prepare_state").match(arg.lower())
#if m is not None:
# PrepareState = True
m = re.compile("--file=" + wordpath).match(arg)
if m is not None:
file_name = m.groups()[0]
File = True
if Device:
if Conf or File:
dev_name = domain + '/' + family + '/' + member
try:
dev = DeviceProxy(dev_name)
except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
print ('ERROR connecting proxy(',dev_name,'): ',e[0].desc)
sys.exit(-1)
if Conf:
print ('Loading: ', alarm_rule)
try:
dev.command_inout('Load',alarm_rule)
print ('.............OK!')
except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
print ('...........ERROR!')
print (' ---> ERROR: ', e[0].desc)
continue
sys.exit(0)
elif File:
for line in open(file_name):
line = line[0:-1]
try:
dev.command_inout('Load',line)
time.sleep(0.1)
except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
print (' ---> ERROR: ', e[0].desc)
time.sleep(2)
sys.exit(1)
sys.exit(0)
#dev = DeviceProxy("alarm/alarm/1")
#dev.command_inout('Load', sys.argv[1])
if len(sys.argv) < 3:
print ('Usage:', sys.argv[0], ' --device=alarm_device --conf=alarm_rule | --file=filename')
print ()
print ('Examples:')
print ('\tload one alarm_rule in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --conf=\"tag=test0;formula=(alarm/test/01/condition == 1);on_delay=0;off_delay=0;priority=high;shlvd_time=0;group=gr_test;message=Test alarm;url=;on_command=;off_command=;enabled=1\"')
print ('\tload alarm rules from filename in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --file=alarms.txt')
sys.exit(-1)
# EOF
# Functions and Pre-build -----------------------------------
# Stop messy in source builds
set(CMAKE_DISABLE_IN_SOURCE_BUILD ON)
set(CMAKE_DISABLE_SOURCE_CHANGES OFF)
if ( ${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_BINARY_DIR} )
message( FATAL_ERROR "In-source builds not allowed. Please make a new directory (called a build directory) and run CMake from there. You may need to remove CMakeCache.txt." )
endif()
# Start Build Config -----------------------------------
cmake_minimum_required(VERSION 3.8)
set(CMAKE_SKIP_RPATH true)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_COLOR_MAKEFILE ON)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# Output name for the final binary
set(DEV_NAME "testdevice-srv")
# Versioning
set(VERSION_MAJOR "1")
set(VERSION_MINOR "0")
set(VERSION_PATCH "0")
set(VERSION_METADATA "")
set(VERSION_STRING ${VERSION_MAJOR}.${VERSION_MINOR}.${VERSION_PATCH})
# Add any include paths from the command line
list(APPEND INCLUDE_PATHS ${CMAKE_INCLUDE_PATH})
list(APPEND INCLUDE_PATHS ${CMAKE_SOURCE_DIR})
list(APPEND LIBRARY_PATHS ${CMAKE_LIBRARY_PATH})
# Start the project
project(testdevice VERSION ${VERSION_STRING} LANGUAGES CXX)
# Build options
# arch install definitions
include(GNUInstallDirs)
message(STATUS "Searching for libraries...")
# Variable to contain a list of all the libs we depend on
set(AH_LIBRARIES)
# allow pkg-config to search the CMAKE_PREFIX_PATH
set(PKG_CONFIG_USE_CMAKE_PREFIX_PATH ON)
list(APPEND CMAKE_PREFIX_PATH "/usr")
# Find Dependencies -----------------------------------
# Find tango if it has not already been found. Returns an interface library
# called TangoInterfaceLibrary
set(CMAKE_MODULE_PATH "${CMAKE_MODULE_PATH};${CMAKE_CURRENT_SOURCE_DIR}/cmake")
find_package(Tango)
# Source -----------------------------------
add_subdirectory(src)
# Build Targets -----------------------------------
# Executable --------
add_executable(testdevice ${SRC_FILES})
target_link_libraries(testdevice
PRIVATE
TangoInterfaceLibrary
)
target_include_directories(testdevice
PRIVATE
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>
${INCLUDE_PATHS}
"${PROJECT_BINARY_DIR}"
)
if(NOT (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang"))
set_target_properties(testdevice
PROPERTIES
OUTPUT_NAME ${DEV_NAME}
LINK_FLAGS "-Wl,--no-undefined"
CXX_STANDARD 17)
else()
set_target_properties(testdevice
PROPERTIES
OUTPUT_NAME ${DEV_NAME}
LINK_FLAGS ""
CXX_STANDARD 17)
endif()
target_compile_options(testdevice
PRIVATE "$<$<CONFIG:DEBUG>:-g>")
# Install Config -----------------------------------
install(
TARGETS testdevice
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
message(STATUS "Configured testdevice project")
GNU LESSER GENERAL PUBLIC LICENSE
Version 3, 29 June 2007
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
This version of the GNU Lesser General Public License incorporates
the terms and conditions of version 3 of the GNU General Public
License, supplemented by the additional permissions listed below.
0. Additional Definitions.
As used herein, "this License" refers to version 3 of the GNU Lesser
General Public License, and the "GNU GPL" refers to version 3 of the GNU
General Public License.
"The Library" refers to a covered work governed by this License,
other than an Application or a Combined Work as defined below.
An "Application" is any work that makes use of an interface provided
by the Library, but which is not otherwise based on the Library.
Defining a subclass of a class defined by the Library is deemed a mode
of using an interface provided by the Library.
A "Combined Work" is a work produced by combining or linking an
Application with the Library. The particular version of the Library
with which the Combined Work was made is also called the "Linked
Version".
The "Minimal Corresponding Source" for a Combined Work means the
Corresponding Source for the Combined Work, excluding any source code
for portions of the Combined Work that, considered in isolation, are
based on the Application, and not on the Linked Version.
The "Corresponding Application Code" for a Combined Work means the
object code and/or source code for the Application, including any data
and utility programs needed for reproducing the Combined Work from the
Application, but excluding the System Libraries of the Combined Work.
1. Exception to Section 3 of the GNU GPL.
You may convey a covered work under sections 3 and 4 of this License
without being bound by section 3 of the GNU GPL.
2. Conveying Modified Versions.
If you modify a copy of the Library, and, in your modifications, a
facility refers to a function or data to be supplied by an Application
that uses the facility (other than as an argument passed when the
facility is invoked), then you may convey a copy of the modified
version:
a) under this License, provided that you make a good faith effort to
ensure that, in the event an Application does not supply the
function or data, the facility still operates, and performs
whatever part of its purpose remains meaningful, or
b) under the GNU GPL, with none of the additional permissions of
this License applicable to that copy.
3. Object Code Incorporating Material from Library Header Files.
The object code form of an Application may incorporate material from
a header file that is part of the Library. You may convey such object
code under terms of your choice, provided that, if the incorporated
material is not limited to numerical parameters, data structure
layouts and accessors, or small macros, inline functions and templates
(ten or fewer lines in length), you do both of the following:
a) Give prominent notice with each copy of the object code that the
Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the object code with a copy of the GNU GPL and this license
document.
4. Combined Works.
You may convey a Combined Work under terms of your choice that,
taken together, effectively do not restrict modification of the
portions of the Library contained in the Combined Work and reverse
engineering for debugging such modifications, if you also do each of
the following:
a) Give prominent notice with each copy of the Combined Work that
the Library is used in it and that the Library and its use are
covered by this License.
b) Accompany the Combined Work with a copy of the GNU GPL and this license
document.
c) For a Combined Work that displays copyright notices during
execution, include the copyright notice for the Library among
these notices, as well as a reference directing the user to the
copies of the GNU GPL and this license document.
d) Do one of the following:
0) Convey the Minimal Corresponding Source under the terms of this
License, and the Corresponding Application Code in a form
suitable for, and under terms that permit, the user to
recombine or relink the Application with a modified version of
the Linked Version to produce a modified Combined Work, in the
manner specified by section 6 of the GNU GPL for conveying
Corresponding Source.
1) Use a suitable shared library mechanism for linking with the
Library. A suitable mechanism is one that (a) uses at run time
a copy of the Library already present on the user's computer
system, and (b) will operate properly with a modified version
of the Library that is interface-compatible with the Linked
Version.
e) Provide Installation Information, but only if you would otherwise
be required to provide such information under section 6 of the
GNU GPL, and only to the extent that such information is
necessary to install and execute a modified version of the
Combined Work produced by recombining or relinking the
Application with a modified version of the Linked Version. (If
you use option 4d0, the Installation Information must accompany
the Minimal Corresponding Source and Corresponding Application
Code. If you use option 4d1, you must provide the Installation
Information in the manner specified by section 6 of the GNU GPL
for conveying Corresponding Source.)
5. Combined Libraries.
You may place library facilities that are a work based on the
Library side by side in a single library together with other library
facilities that are not Applications and are not covered by this
License, and convey such a combined library under terms of your
choice, if you do both of the following:
a) Accompany the combined library with a copy of the same work based
on the Library, uncombined with any other library facilities,
conveyed under the terms of this License.
b) Give prominent notice with the combined library that part of it
is a work based on the Library, and explaining where to find the
accompanying uncombined form of the same work.
6. Revised Versions of the GNU Lesser General Public License.
The Free Software Foundation may publish revised and/or new versions
of the GNU Lesser General Public License from time to time. Such new
versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the
Library as you received it specifies that a certain numbered version
of the GNU Lesser General Public License "or any later version"
applies to it, you have the option of following the terms and
conditions either of that published version or of any later version
published by the Free Software Foundation. If the Library as you
received it does not specify a version number of the GNU Lesser
General Public License, you may choose any version of the GNU Lesser
General Public License ever published by the Free Software Foundation.
If the Library as you received it specifies that a proxy can decide
whether future versions of the GNU Lesser General Public License shall
apply, that proxy's public statement of acceptance of any version is
permanent authorization for you to choose that version for the
Library.
GCCMAJOR := $(shell ${CXX} -dumpversion | cut -d"." -f1)
GCCMINOR := $(shell ${CXX} -dumpversion | cut -d"." -f2)
MACHINE := $(shell ${CXX} -dumpmachine)
TANGO_DIR := /usr/local/tango-9.3.4
OMNIORB_DIR := /usr/local/omniorb-4.2.3
ZMQ_DIR := /usr/local/zeromq-4.0.8
RUNTIME_DIR := /runtime
TANGO_INC := ${TANGO_DIR}/include/tango
LOG4TANGO_INC := ${TANGO_DIR}/include
OMNIORB_INC := ${OMNIORB_DIR}/include
ZMQ_INC := ${ZMQ_DIR}/include
RUNTIME_INC := ${RUNTIME_DIR}/include
TANGO_LIB = ${TANGO_DIR}/lib
OMNIORB_LIB = ${OMNIORB_DIR}/lib
ZMQ_LIB = ${ZMQ_DIR}/lib
RUNTIME_LIB = ${RUNTIME_DIR}/lib
ifeq ($(SDKTARGETSYSROOT),)
ifeq ($(GCCMAJOR),4)
ifeq ($(shell test $(GCCMINOR) -lt 4; echo $$?),0)
CXXFLAGS += -std=gnu++98
else
CXXFLAGS += -std=c++0x
endif
else
CXXFLAGS += -std=c++11
endif
INC_DIR = -I${TANGO_INC} -I${LOG4TANGO_INC} -I${OMNIORB_INC} -I${ZMQ_INC} -I${RUNTIME_INC}
LIB_DIR = -L${TANGO_LIB} -L${OMNIORB_LIB} -L${ZMQ_LIB} -L${RUNTIME_LIB} -L/usr/local/lib
else
CXXFLAGS += -std=gnu++11
INC_DIR = -I${SDKTARGETSYSROOT}/usr/include/tango
endif
#-----------------------------------------
# Default make entry
#-----------------------------------------
default: release
release debug: bin/$(NAME_SRV)
all: default
#-----------------------------------------
# Set CXXFLAGS and LDFLAGS
#-----------------------------------------
CXXFLAGS += -D__linux__ -D__OSVERSION__=2 -Wall -pedantic \
-Wno-non-virtual-dtor -Wno-long-long -DOMNI_UNLOADABLE_STUBS \
$(INC_DIR) -Isrc
ifeq ($(GCCMAJOR),4)
CXXFLAGS += -Wextra
endif
ifeq ($(GCCMAJOR),5)
CXXFLAGS += -Wextra
endif
LDFLAGS += $(LIB_DIR) -ltango -lomniORB4 -lomniDynamic4 \
-lCOS4 -lomnithread -lzmq
#-----------------------------------------
# Set dependencies
#-----------------------------------------
SRC_FILES += $(wildcard src/*.cpp)
OBJ_FILES += $(addprefix obj/,$(notdir $(SRC_FILES:.cpp=.o)))
obj/%.o: $(SRC_FILES:%.cpp)
$(CXX) $(CXXFLAGS) -c -o $@ $<
.nse_depinfo: $(SRC_FILES)
@$(CXX) $(CXXFLAGS) -M -MM $^ | sed 's/\(.*\)\.o/obj\/\1.o/g' > $@
-include .nse_depinfo
#-----------------------------------------
# Main make entries
#-----------------------------------------
bin/$(NAME_SRV): bin obj $(OBJ_FILES)
$(CXX) $(CXXFLAGS) $(OBJ_FILES) -o bin/$(NAME_SRV) $(LDFLAGS)
clean:
@rm -fr obj/ bin/ core* .nse_depinfo src/*~
bin obj:
@ test -d $@ || mkdir $@
#-----------------------------------------
# Target specific options
#-----------------------------------------
release: CXXFLAGS += -O2 -DNDEBUG
release: LDFLAGS += -s
debug: CXXFLAGS += -ggdb3
.PHONY: clean
NAME_SRV = testdevice-srv
CXXFLAGS =
LDFLAGS =
include ./Make-9.3.4.in
# Project Name
testdevice
## Description
Tango device server for storing and distributing a number of variables as device attributes.
## Installation
See your institue guidelines for deploying and configuring a Tango device server.
## Usage
The server is dynamically configured by means of dedicated Methods. The configuration and values are stored in the Tango Database and restored at server restart.
A typical usage is to store and distribute the results of measurments or simulations to a number of differet clients.
## History
## Credits
Elettra-Sincrotrone Trieste S.C.p.A. di interesse nazionale
Strada Statale 14 - km 163,5 in AREA Science Park
34149 Basovizza, Trieste ITALY
## License
GPL 3
include(CMakeParseArguments)
function(find_libraries)
# Parse the parameters
set(MULTIVALUEARGS LIBRARIES SEARCH_PATHS)
cmake_parse_arguments(FIND_LIBRARIES "" "" "${MULTIVALUEARGS}" ${ARGN})
# Clear the found libraries
unset(FOUND_LIBRARIES PARENT_SCOPE)
foreach(LIB ${FIND_LIBRARIES_LIBRARIES})
# try the user provided paths first
find_library(FOUND_LIB_${LIB} ${LIB} PATHS ${FIND_LIBRARIES_SEARCH_PATHS} NO_DEFAULT_PATH)
# if we could not find it, drop to the system paths
if(NOT FOUND_LIB_${LIB})
find_library(FOUND_LIB_${LIB} ${LIB})
endif(NOT FOUND_LIB_${LIB})
if(FOUND_LIB_${LIB})
message(STATUS "Found " ${LIB} " at: " ${FOUND_LIB_${LIB}})
list(APPEND FOUND_LIBRARIES ${FOUND_LIB_${LIB}})
else()
message(FATAL "Could not find " ${LIB})
endif(FOUND_LIB_${LIB})
endforeach(LIB ${LIBRARIES})
set(FOUND_LIBRARIES ${FOUND_LIBRARIES} PARENT_SCOPE)
endfunction(find_libraries)
\ No newline at end of file
if(NOT TARGET TangoInterfaceLibrary)
# Ensure pkg-config is installed
find_package(PkgConfig REQUIRED)
# Now search for the tango.pc file, this is a required dependency
message(STATUS "Search for TANGO package config...")
pkg_search_module(TANGO REQUIRED tango>=9.2.5)
message(STATUS "Found tango version ${TANGO_VERSION} at ${TANGO_PREFIX}")
include(FindLibraries)
find_libraries(LIBRARIES ${TANGO_LIBRARIES} SEARCH_PATHS ${TANGO_LIBRARY_DIRS})
# Create an interface library to represent the tango linkage
add_library(TangoInterfaceLibrary INTERFACE)
set_target_properties(TangoInterfaceLibrary
PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${TANGO_INCLUDE_DIRS}"
INTERFACE_LINK_LIBRARIES "${FOUND_LIBRARIES}"
INTERFACE_COMPILE_OPTIONS "${TANGO_CFLAGS}")
message(STATUS "Configured Tango Interface for TANGO version ${TANGO_VERSION}")
endif(NOT TARGET TangoInterfaceLibrary)
\ No newline at end of file
cmake_minimum_required(VERSION 3.2)
# source files
set(SRC_FILES ${SRC_FILES}
${CMAKE_CURRENT_SOURCE_DIR}/TestDevice.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestDeviceClass.cpp
${CMAKE_CURRENT_SOURCE_DIR}/TestDeviceStateMachine.cpp
${CMAKE_CURRENT_SOURCE_DIR}/ClassFactory.cpp
${CMAKE_CURRENT_SOURCE_DIR}/main.cpp
PARENT_SCOPE)
/*----- PROTECTED REGION ID(TestDevice::ClassFactory.cpp) ENABLED START -----*/
//=============================================================================
//
// file : ClassFactory.cpp
//
// description : C++ source for the class_factory method of the DServer
// device class. This method is responsible for the creation of
// all class singleton for a device server. It is called
// at device server startup.
//
// $Author: graziano $
//
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================
#include <tango/tango.h>
#include <TestDeviceClass.h>
// Add class header files if needed
/**
* Create TestDevice Class singleton and store it in DServer object.
*/
void Tango::DServer::class_factory()
{
// Add method class init if needed
add_class(TestDevice_ns::TestDeviceClass::init("TestDevice"));
}
/*----- PROTECTED REGION END -----*/
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.