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 4141 additions and 42 deletions
/*
* update-thread.cpp
*
* $Author: claudio $
*
* $Revision: 1.2 $
*
* $Log: update-thread.cpp,v $
* Revision 1.2 2013-03-06 10:38:43 claudio
* commented out debug print statements
*
* Revision 1.1 2008-11-10 10:54:09 graziano
* thread for update of alarms with time threshold > 0
*
*
*
*
* copyleft: Sincrotrone Trieste S.C.p.A. di interesse nazionale
* Strada Statale 14 - km 163,5 in AREA Science Park
* 34012 Basovizza, Trieste ITALY
*/
#include "update-thread.h"
......@@ -26,9 +8,9 @@ static const char __FILE__rev[] = __FILE__ " $Revision: 1.2 $";
/*
* alarm_thread::alarm_thread()
*/
update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p)
update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p),Tango::LogAdapter(p)
{
//cout << __FILE__rev << endl;
//TANGO_LOG << __FILE__rev << endl;
}
/*
......@@ -36,6 +18,7 @@ update_thread::update_thread(AlarmHandler_ns::AlarmHandler *p) : p_Alarm(p)
*/
update_thread::~update_thread()
{
DEBUG_STREAM << __func__ << "update_thread::~update_thread(): entering!" << endl;
p_Alarm = NULL;
}
......@@ -44,6 +27,7 @@ update_thread::~update_thread()
*/
void update_thread::run(void *)
{
DEBUG_STREAM << __func__ << "update_thread::run(): entering!" << endl;
//printf("update_thread::run(): running...\n");
unsigned int pausasec, pausanano;
pausasec=1;
......@@ -52,14 +36,23 @@ void update_thread::run(void *)
while (!p_Alarm->abortflag) {
try
{
omni_thread::sleep(pausasec,pausanano);
p_Alarm->timer_update();
//omni_thread::sleep(pausasec,pausanano);
abort_sleep(pausasec+(double)pausanano/1000000000);
if(!p_Alarm->abortflag)
p_Alarm->timer_update();
//printf("update_thread::run(): TIMER!!\n");
}
catch(...)
{
printf("update_thread::run(): catched unknown exception!!\n");
INFO_STREAM << "update_thread::run(): catched unknown exception!!";
}
}
//cout << "update_thread::run(): exiting!" << endl;
DEBUG_STREAM << "update_thread::run(): exiting!" << endl;
} /* update_thread::run() */
void update_thread::abort_sleep(double time)
{
omni_mutex_lock sync(*this);
long time_millis = (long)(time*1000);
int res = wait(time_millis);
}
/*
* alarm-thread.h
*
* $Author: graziano $
*
* $Revision: 1.1 $
*
* $Log: update-thread.h,v $
* Revision 1.1 2008-11-10 10:54:09 graziano
* thread for update of alarms with time threshold > 0
*
*
*
*
* copyleft: Sincrotrone Trieste S.C.p.A. di interesse nazionale
* Strada Statale 14 - km 163,5 in AREA Science Park
* 34012 Basovizza, Trieste ITALY
* update-thread.h
*/
#ifndef UPDATE_THREAD_H
#define UPDATE_THREAD_H
#include <omnithread.h>
#include <tango.h>
#include <tango/tango.h>
#include <AlarmHandler.h>
class update_thread : public omni_thread {
class update_thread : public omni_thread, public Tango::TangoMonitor, public Tango::LogAdapter {
public:
update_thread(AlarmHandler_ns::AlarmHandler *p);
~update_thread();
protected:
void run(void *);
private:
void abort_sleep(double time);
AlarmHandler_ns::AlarmHandler *p_Alarm;
};
......
cmake_minimum_required(VERSION 3.2)
project(test NONE)
include(ExternalProject)
ExternalProject_Add(testdevice
SOURCE_DIR ${CMAKE_SOURCE_DIR}/test/testdevice
# PREFIX ${CMAKE_BINARY_DIR}
CMAKE_ARGS "-DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}"
# INSTALL_DIR ${CMAKE_BINARY_DIR}
# BINARY_DIR ${CMAKE_BINARY_DIR}
# STEP_TARGETS build
# EXCLUDE_FROM_ALL TRUE
)
ExternalProject_Get_property(testdevice SOURCE_DIR)
message("Source dir of testdevice = ${SOURCE_DIR}")
ExternalProject_Get_property(testdevice INSTALL_DIR)
message("Install dir of testdevice = ${INSTALL_DIR}")
ExternalProject_Get_property(testdevice BINARY_DIR)
message("Binary dir of testdevice = ${BINARY_DIR}")
ExternalProject_Get_property(testdevice CMAKE_ARGS)
message("CMqke args for testdevice = ${CMAKE_ARGS}")
#ExternalProject_Get_property(testdevice PREFIX)
#message("Prefix dir of testdevice = ${PREFIX}")
{
"_version": 1,
"_source": "ConfigInjectorDiag.xls",
"_title": "hdbpp mysql innodb test",
"_date": "2020-07-07 14:45:04",
"servers": {
"alarm-handler-srv/01": {
"AlarmHandler": {
"alarm/handler/01": {
"properties": {
},
"attribute_properties": {
}
}
}
},
"testdevice-srv/01": {
"TestDevice": {
"alarm/test/01": {
"properties": {
"Attr_config": [
"condition:bool:0:0.0"
]
},
"attribute_properties": {
}
}
}
}
},
"classes": {
"AlarmHandler": {
"properties": {
"GroupNames": ["gr_none","gr_test"],
"StatisticsTimeWindow": ["60"],
"SubscribeRetryPeriod": ["30"]
}
},
"TestDevice": {
"properties": {
}
}
}
}
#!/usr/bin/python
#
import sys,re
#import PyTango
from PyTango import *
import time
import string
if __name__ == "__main__":
Device = False
Conf = False
File = False
conflist = []
#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:
#print m.groups()
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:
#print m.groups()
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:
#print m.groups()
file_name = m.groups()[0]
File = True
tagchars = '([a-zA-Z0-9._-]*)'
tag=''
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:
m = re.compile("tag=" + tagchars + ";(.*)").match(alarm_rule)
if m is not None:
try:
tag = m.groups()[0]
conflist = dev.command_inout('SearchAlarm',tag)
except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
print (' ---> ERROR: ', e[0].desc)
sys.exit(1)
for co in conflist:
if co == alarm_rule:
print ('Found matching alarm: ', co)
sys.exit(0)
print ('Not found conf for alarm ', tag)
sys.exit(1)
elif File:
for line in open(file_name):
line = line[0:-1]
m = re.compile("tag=" + tagchars + ";(.*)").match(line)
conf_found = False
if m is not None:
try:
tag = m.groups()[0]
conflist = dev.command_inout('SearchAlarm',tag)
except (DevFailed,ConnectionFailed,EventSystemFailed) as e:
print (' ---> ERROR: ', e[0].desc)
sys.exit(1)
for co in conflist:
if co == alarm_rule:
conf_found = True
if not conf_found:
print ('Not found conf for alarm ', tag)
sys.exit(1)
sys.exit(0)
if len(sys.argv) < 3:
print ('Usage:', sys.argv[0], ' --device=alarm_device --conf=alarm_rule | --file=filename')
print ()
print ('Examples:')
print ('\tcheck 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 ('\tcheck alarm rules from filename in alarm/handler/01:', sys.argv[0], '--device=alarm/handler/01 --file=alarms.txt')
sys.exit(-1)
# EOF
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
NAME_SRV = testdevice-srv
CXXFLAGS =
LDFLAGS =
include ./Make-9.3.4.in
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
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)
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.