Skip to content
This repository has been archived by the owner on Apr 7, 2022. It is now read-only.

Commit

Permalink
Issue 13 Pipe Events (#104)
Browse files Browse the repository at this point in the history
Add pipe events + examples
  • Loading branch information
grm84 authored and tiagocoutinho committed May 31, 2017
1 parent 1b0d524 commit a4dc9c5
Show file tree
Hide file tree
Showing 27 changed files with 2,276 additions and 9 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ $(OBJS_DIR)/group_reply_list.o \
$(OBJS_DIR)/locker_info.o \
$(OBJS_DIR)/locking_thread.o \
$(OBJS_DIR)/periodic_event_info.o \
$(OBJS_DIR)/pipe_event_data.o \
$(OBJS_DIR)/poll_device.o \
$(OBJS_DIR)/pytango.o \
$(OBJS_DIR)/pytgutils.o \
Expand Down
56 changes: 56 additions & 0 deletions examples/pipeEvents/ClassFactory.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*----- PROTECTED REGION ID(PipeServer::ClassFactory.cpp) ENABLED START -----*/
static const char *RcsId = "$Id: $";
//=============================================================================
//
// 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.
//
// project :
//
// This file is part of Tango device class.
//
// Tango is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Tango is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Tango. If not, see <http://www.gnu.org/licenses/>.
//
// $Author: $
//
// $Revision: $
// $Date: $
//
// $HeadURL: $
//
//=============================================================================
// This file is generated by POGO
// (Program Obviously used to Generate tango Object)
//=============================================================================

#include <tango.h>
#include <PipeServerClass.h>

// Add class header files if needed


/**
* Create PipeServer Class singleton and store it in DServer object.
*/

void Tango::DServer::class_factory()
{
// Add method class init if needed
add_class(PipeServer_ns::PipeServerClass::init("PipeServer"));
}
/*----- PROTECTED REGION END -----*/ // PipeServer::ClassFactory.cpp
147 changes: 147 additions & 0 deletions examples/pipeEvents/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,147 @@
#=============================================================================
#
# file : Makefile
#
# description : Makefile to generate a TANGO device server.
#
# project : PipeServer
#
# $Author: $
#
# $Revision: $
# $Date: $
#
#=============================================================================
# This file is generated by POGO
# (Program Obviously used to Generate tango Object)
#=============================================================================
#
#
#=============================================================================
# MAKE_ENV is the path to find common environment to buil project
#
MAKE_ENV = /usr/local/share/pogo/preferences

#=============================================================================
# PACKAGE_NAME is the name of the library/device/exe you want to build
#
PACKAGE_NAME = PipeServer
MAJOR_VERS = 1
MINOR_VERS = 0
RELEASE = Release_$(MAJOR_VERS)_$(MINOR_VERS)

# #=============================================================================
# # RELEASE_TYPE
# # - DEBUG : debug symbols - no optimization
# # - OPTIMIZED : no debug symbols - optimization level set to O2
# #-----------------------------------------------------------------------------
RELEASE_TYPE = DEBUG

#=============================================================================
# OUTPUT_TYPE can be one of the following :
# - 'STATIC_LIB' for a static library (.a)
# - 'SHARED_LIB' for a dynamic library (.so)
# - 'DEVICE' for a device server (will automatically include and link
# with Tango dependencies)
# - 'SIMPLE_EXE' for an executable with no dependency (for exemple the test tool
# of a library with no Tango dependencies)
#
OUTPUT_TYPE = DEVICE

#=============================================================================
# OUTPUT_DIR is the directory which contains the build result.
# if not set, the standard location is :
# - ./shlib if OUTPUT_TYPE is SHARED_LIB
# - ./lib if OUTPUT_TYPE is STATIC_LIB
# - ./bin for others
#
#OUTPUT_DIR =


#=============================================================================
# INC_DIR_USER is the list of all include path needed by your sources
# - for a device server, tango dependencies are automatically appended
# - '-I ../include' and '-I .' are automatically appended in all cases
#
INC_DIR_USER= -I .

#=============================================================================
# LIB_DIR_USER is the list of user library directories
# - for a device server, tango libraries directories are automatically appended
# - '-L ../lib' is automatically appended in all cases
#
#LIB_DIR_USER=

#=============================================================================
# LFLAGS_USR is the list of user link flags
# - for a device server, tango libraries directories are automatically appended
# - '-ldl -lpthread' is automatically appended in all cases
#
# !!! ATTENTION !!!
# Be aware that the order matters.
# For example if you must link with libA, and if libA depends itself on libB
# you must use '-lA -lB' in this order as link flags, otherwise you will get
# 'undefined reference' errors
#
#LFLAGS_USR+=


#=============================================================================
# CXXFLAGS_USR lists the compilation flags specific for your library/device/exe
# This is the place where to put your compile-time macros using '-Dmy_macro'
#
# -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__ for ACE
#
CXXFLAGS_USR+= -std=c++11


#=============================================================================
# TANGO_REQUIRED
# - TRUE : your project depends on TANGO
# - FALSE : your project does not depend on TANGO
#-----------------------------------------------------------------------------
# - NOTE : if PROJECT_TYPE is set to DEVICE, TANGO will be auto. added
#-----------------------------------------------------------------------------
TANGO_REQUIRED = TRUE



#=============================================================================
# include Standard TANGO compilation options
#
include $(MAKE_ENV)/tango.opt

#=============================================================================
# POST_PROCESSING: action to be done after normal make.
# e.g.: change executable file name, .....
#POST_PROCESSING = \
# mv bin/$(BIN_DIR)/$(PACKAGE_NAME) bin/$(BIN_DIR)/$(PACKAGE_NAME)_DS

#=============================================================================
# SVC_OBJS is the list of all objects needed to make the output
#
SVC_INCL = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h


SVC_OBJS = \
$(LIB_OBJS) \
$(OBJDIR)/ClassFactory.o \
$(OBJDIR)/main.o

LIB_OBJS = \
$(OBJDIR)/$(PACKAGE_NAME).o \
$(OBJDIR)/$(PACKAGE_NAME)Class.o \
$(OBJDIR)/$(PACKAGE_NAME)StateMachine.o \
$(ADDITIONAL_OBJS)

SVC_INHERITANCE_OBJ = \


#=============================================================================
# include common targets
#
include $(MAKE_ENV)/common_target.opt




51 changes: 51 additions & 0 deletions examples/pipeEvents/PipeEventClient.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
import time
import numpy

import tango
from tango import DevState


class EventManager():

def __init__(self, dp):
self._deviceProxy = dp
if dp is not None:
print "Subscribed to TestPipe"
self._event_id = dp.subscribe_event("TestPipe",
tango.EventType.PIPE_EVENT,
self)

def unsubscribe(self):
self._deviceProxy.unsubscribe_event(self._event_id)

def push_event(self, ev):
print "Event -----push_event-----------------"
print "Timestamp: ", ev.reception_date
print "Pipe name: ", ev.pipe_name
print "Event type: ", ev.event
print "Device server: ", ev.device
print "Event error: ", ev.err
if ev.err:
print "Caught pipe exception"
err = ev.errors[0]
print "Error desc: ", err.desc
print "Error origin: ", err.origin
print "Error reason: ", err.reason
print "Error severity: ", err.severity
else:
print "Nb data elts: ", ev.pipe_value.data_elt_nb
print "Event name: ", ev.pipe_value.name
print "Root blob name: ", ev.pipe_value.root_blob_name
print "Elements names: ", ev.pipe_value.data_elt_names
nb_elt = ev.pipe_value.data_elt_nb
for i in range(nb_elt):
print "Elements: ", ev.pipe_value.data[i]

def main():
dev=tango.DeviceProxy('pipeServer/tango/1')
print dev
em = EventManager(dev)
time.sleep(3000.0)

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

0 comments on commit a4dc9c5

Please sign in to comment.