Commit 421ef57a authored by Yuelong Yu's avatar Yuelong Yu
Browse files

multi module testing

parent 6d49d260
......@@ -271,8 +271,8 @@ void AGIPD::init_device()
,uDPSrcIP,uDPSrcMAC);
m_objSys->GetImageFormat(m_nSizeX,m_nSizeY,m_shDepth);
m_thAcq = new AcquisitionThread(this,m_objSys,m_mtxAcq);
if(isMaster==0)
m_thAcq = new AcquisitionThread(this,m_objSys,m_mtxAcq);
//RefreshDetector();
set_state(Tango::OFF);
}
......@@ -325,6 +325,7 @@ void AGIPD::get_device_property()
dev_prop.push_back(Tango::DbDatum("TCPPort"));
dev_prop.push_back(Tango::DbDatum("UDPSrcIP"));
dev_prop.push_back(Tango::DbDatum("UDPSrcMAC"));
dev_prop.push_back(Tango::DbDatum("IsMaster"));
// is there at least one property to be read ?
if (dev_prop.size()>0)
......@@ -449,6 +450,17 @@ void AGIPD::get_device_property()
// And try to extract UDPSrcMAC value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> uDPSrcMAC;
// Try to initialize IsMaster from class property
cl_prop = ds_class->get_class_property(dev_prop[++i].name);
if (cl_prop.is_empty()==false) cl_prop >> isMaster;
else {
// Try to initialize IsMaster from default device value
def_prop = ds_class->get_default_device_property(dev_prop[i].name);
if (def_prop.is_empty()==false) def_prop >> isMaster;
}
// And try to extract IsMaster value from database
if (dev_prop[i].is_empty()==false) dev_prop[i] >> isMaster;
}
/*----- PROTECTED REGION ID(AGIPD::get_device_property_after) ENABLED START -----*/
......@@ -1708,12 +1720,18 @@ void AGIPD::start_acq()
// Add your own code
//m_objSys->StartImaging();
if(isMaster == 0)
{
omni_mutex_lock l(m_mtxAcq);
omni_mutex_lock l1(m_mtxSimu);
m_bStartAcq = true;
//m_bStopAcq = false;
}
else
{
SetState(Tango::MOVING);
m_objSys->StartImaging();
}
/*----- PROTECTED REGION END -----*/ // AGIPD::start_acq
......@@ -1735,12 +1753,19 @@ void AGIPD::stop_acq()
// Add your own code
// m_objSys->StopImaging();
if(isMaster == 0)
{
omni_mutex_lock l(m_mtxAcq);
omni_mutex_lock l1(m_mtxSimu);
m_bStopAcq = true;
//m_bStartAcq = false;
}
else
{
m_objSys->StopImaging();
SetState(Tango::ON);
}
......
......@@ -108,6 +108,8 @@ public: // SimulationMode:
string uDPSrcIP;
// UDPSrcMAC:
string uDPSrcMAC;
// IsMaster:
Tango::DevUShort isMaster;
// Attribute data members
......
<?xml version="1.0" encoding="ASCII"?>
<pogoDsl:PogoSystem xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:pogoDsl="http://www.esrf.fr/tango/pogo/PogoDsl">
<classes name="AGIPD">
<description description="AGIPD tango server" title="AGIPD" sourcePath="/home/yuelong/src/gitrepo/detsoftware/tango/agipd" language="Cpp" filestogenerate="XMI file,Code files,html Pages" hasAbstractCommand="false" hasAbstractAttribute="false">
<description description="AGIPD tango server" title="AGIPD" sourcePath="/home/yuelong/gitrepo/detsoftware/tango/agipd" language="Cpp" filestogenerate="XMI file,Code files,html Pages" hasAbstractCommand="false" hasAbstractAttribute="false">
<inheritances classname="Device_Impl" sourcePath=""/>
<identification contact="at desy.de - yuelong.yu" author="yuelong.yu" emailDomain="desy.de" classFamily="Acquisition" siteSpecific="" platform="Unix Like" bus="Ethernet" manufacturer="DESY(FS-DS)" reference=""/>
<comments commandsTable="//================================================================&#xA;//&#xA;// The following table gives the correspondence&#xA;// between command and method names.&#xA;//&#xA;// Command name | Method name&#xA;//----------------------------------------------------------------&#xA;// State | dev_state&#xA;// Status | dev_status&#xA;// LoadPattern | load_pattern&#xA;// StartAcq | start_acq&#xA;// StopAcq | stop_acq&#xA;// Reset | reset&#xA;//================================================================"/>
......@@ -51,6 +51,11 @@
<type xsi:type="pogoDsl:StringType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</deviceProperties>
<deviceProperties name="IsMaster" description="">
<type xsi:type="pogoDsl:UShortType"/>
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
<DefaultPropValue>0</DefaultPropValue>
</deviceProperties>
<commands name="State" description="This command gets the device state (stored in its device_state data member) and returns it to the caller." execMethod="dev_state" displayLevel="OPERATOR">
<argin description="none">
<type xsi:type="pogoDsl:VoidType"/>
......@@ -377,6 +382,6 @@
<states name="FAULT" description="">
<status abstract="false" inherited="false" concrete="true" concreteHere="true"/>
</states>
<preferences docHome="./doc_html" makefileHome="/usr/share/pogo/preferences"/>
<preferences docHome="./doc_html" makefileHome="/usr/local/share/pogo/preferences"/>
</classes>
</pogoDsl:PogoSystem>
......@@ -462,6 +462,21 @@ void AGIPDClass::set_default_property()
}
else
add_wiz_dev_prop(prop_name, prop_desc);
prop_name = "IsMaster";
prop_desc = "";
prop_def = "0\n";
vect_data.clear();
vect_data.push_back("0");
if (prop_def.length()>0)
{
Tango::DbDatum data(prop_name);
data << vect_data ;
dev_def_prop.push_back(data);
add_wiz_dev_prop(prop_name, prop_desc, prop_def);
}
else
add_wiz_dev_prop(prop_name, prop_desc);
}
......
......@@ -108,7 +108,7 @@
<Table Border=2 Cellpadding=3 CELLSPACING=0>
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<Td COLSPAN=4> <Font Size=+1> <Center><b>
10 Device Properties
11 Device Properties
</b></Font></Center></td>
<TR BGCOLOR="#CCCCFF" CLASS="TableHeadingColor">
<Td><Center><b>
......@@ -212,6 +212,15 @@
<Td>
.....
</Td>
</td>
</Tr>
<Tr>
<Td> IsMaster </Td>
<Td> </Td>
<Td> unsigned short </Td>
<Td>
0
</Td>
</td>
</Tr>
</table>
......
......@@ -231,8 +231,14 @@ void AGIPDMaster::init_device()
m_stateDetLatest = Tango::UNKNOWN;
//connect to sub devices
for(auto strDP : subDevices)
{
// for(auto strDP : subDevices)
// {
for(int i=0;i<subDevices.size();i++)
{
auto strDP = subDevices[i];
cout<<strDP<<endl;
try
......@@ -824,10 +830,12 @@ void AGIPDMaster::read_LatestImageNumber(Tango::Attribute &attr)
/*----- PROTECTED REGION ID(AGIPDMaster::read_LatestImageNumber) ENABLED START -----*/
Tango::DevLong lVal = this->ReadAttrT<Tango::DevLong>(string("LatestImageNumber"));
Tango::DevLong lVal = this->ReadAttrT<Tango::DevULong>(string("LatestImageNumber"));
if(lVal!=-2)
*attr_LatestImageNumber_read = lVal;
if(*attr_LatestImageNumber_read == *attr_FrameNumbers_read)
this->stop_acq();
// Set the attribute value
attr.set_value(attr_LatestImageNumber_read);
......@@ -1313,7 +1321,7 @@ void AGIPDMaster::read_TotalLossFrames(Tango::Attribute &attr)
DEBUG_STREAM << "AGIPDMaster::read_TotalLossFrames(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(AGIPDMaster::read_TotalLossFrames) ENABLED START -----*/
Tango::DevLong lVal = this->ReadAttrT<Tango::DevLong>(string("TotalLossFrames"));
Tango::DevLong lVal = this->ReadAttrT<Tango::DevULong>(string("TotalLossFrames"));
if(lVal!=-2)
*attr_TotalLossFrames_read = lVal;
......@@ -1545,36 +1553,39 @@ Tango::DevState AGIPDMaster::dev_state()
m_strMsg=string("");
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
int n = objDP->state();
switch(n)
{
case Tango::ON:
m_strMsg+="module "+to_string(nModule)+":ON;";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":ON;";
break;
case Tango::OFF:
m_strMsg+="module "+to_string(nModule)+":OFF;";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":OFF;";
break;
case Tango::UNKNOWN:
m_strMsg+="module "+to_string(nModule)+":UNKNOWN;";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":UNKNOWN;";
break;
case Tango::FAULT:
m_strMsg+="module "+to_string(nModule)+":FAULT;";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":FAULT;";
break;
case Tango::DISABLE:
m_strMsg+="module "+to_string(nModule)+":DISABLE;";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":DISABLE;";
break;
case Tango::MOVING:
m_strMsg+="module "+to_string(nModule)+":MOVING;";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":MOVING;";
break;
case Tango::RUNNING:
m_strMsg+="module "+to_string(nModule)+":RUNNING";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":RUNNING";
break;
default:
m_strMsg+="module "+to_string(nModule)+":NONE";
m_strMsg+="module "+std::to_string(static_cast<long long int>(nModule))+":NONE";
break;
}
......@@ -1651,8 +1662,12 @@ void AGIPDMaster::load_pattern()
/*----- PROTECTED REGION ID(AGIPDMaster::load_pattern) ENABLED START -----*/
// Add your own code
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
//before send stop acquisition command, check server status
//if submodule is already on ON state, don't send stopacq command
// int n = objDP->state();
......@@ -1679,9 +1694,13 @@ void AGIPDMaster::start_acq()
/*----- PROTECTED REGION ID(AGIPDMaster::start_acq) ENABLED START -----*/
// Add your own code
for(auto objDP : m_vobjDP)
//for(auto objDP : m_vobjDP)
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
objDP->command_inout("StartAcq");
}
/*----- PROTECTED REGION END -----*/ // AGIPDMaster::start_acq
}
......@@ -1702,8 +1721,12 @@ void AGIPDMaster::stop_acq()
// Add your own code
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
//before send stop acquisition command, check server status
//if submodule is already on ON state, don't send stopacq command
int n = objDP->state();
......@@ -1730,8 +1753,13 @@ void AGIPDMaster::reset()
/*----- PROTECTED REGION ID(AGIPDMaster::reset) ENABLED START -----*/
// Add your own code
for(auto objDP : m_vobjDP)
//for(auto objDP : m_vobjDP)
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
objDP->command_inout("Reset");
}
/*----- PROTECTED REGION END -----*/ // AGIPDMaster::reset
......@@ -1745,8 +1773,11 @@ void AGIPDMaster::reset()
template<typename T>
void AGIPDMaster::WriteAttr(string strAttr, T tVal)
{
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
Tango::DeviceAttribute objAttr(strAttr,tVal);
......@@ -1764,8 +1795,11 @@ void AGIPDMaster::WriteAttr(string strAttr, T tVal)
void AGIPDMaster:: WriteAttr(string strAttr,bool bVal)
{
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
......@@ -1787,13 +1821,16 @@ void AGIPDMaster::WriteAttr(string strAttr,string strVal)
//cout<<strAttr<<":Write";
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
string strTmp;
if(strAttr == string("FilePrefix"))
strTmp = string("m")+to_string(nIdx)+string("_")+strVal;
strTmp = string("m")+to_string(static_cast<long long int>(nIdx))+string("_")+strVal;
else
strTmp = strVal;
......@@ -1822,8 +1859,11 @@ T AGIPDMaster::ReadAttrT(string strAttr)
long lMin = LONG_MAX;
long lMax = LONG_MIN;
//cout<<strAttr<<":";
for(auto objDP : m_vobjDP)
//for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
Tango::DeviceAttribute objAttr = objDP->read_attribute(strAttr);
......@@ -1831,12 +1871,17 @@ T AGIPDMaster::ReadAttrT(string strAttr)
(objAttr)>>tVal;
if(strAttr==string("LatestImageNumber"))
{
if(tVal<lMin)
if(i!=0)
{
sVal.clear();
lMin = tVal;
sVal.insert(lMin);
if(tVal<lMin)
{
sVal.clear();
lMin = tVal;
sVal.insert(lMin);
}
}
}
else if (strAttr==string("TotalLossFrames"))
{
......@@ -1847,6 +1892,13 @@ T AGIPDMaster::ReadAttrT(string strAttr)
sVal.insert(lMax);
}
}
else if(strAttr==string("FileStartNum"))
{
if(i!=0)
{
sVal.insert(tVal);
}
}
else
sVal.insert(tVal);
// cout<<tVal<<"\t";
......@@ -1874,8 +1926,11 @@ bool AGIPDMaster::ReadAttrBool(string strAttr)
{
set<bool> sVal;
//cout<<strAttr<<":";
for(auto objDP : m_vobjDP)
//for(auto objDP : m_vobjDP)
//{
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
Tango::DeviceAttribute objAttr = objDP->read_attribute(strAttr);
......@@ -1907,8 +1962,11 @@ string AGIPDMaster::ReadAttrStr(string strAttr)
// cout<<strAttr<<":";
if(strAttr != string("ConfigFilePath"))
{
for(auto objDP : m_vobjDP)
// for(auto objDP : m_vobjDP)
// {
for(int i=0;i<m_vobjDP.size();i++)
{
Tango::DeviceProxy* objDP = m_vobjDP[i];
try
{
Tango::DeviceAttribute objAttr = objDP->read_attribute(strAttr);
......
#PROTECTED REGION ID(AGIPDMaster::Makefile) ENABLED START#
#=============================================================================
#
# file : Makefile
#
# description : Makefile to generate a TANGO device server.
#
# project : AGIPD
#
# $Author: $
#
# $Revision: $
#
# $Log: $
#
#=============================================================================
# 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/share/pogo/preferences
MAKE_ENV = $(TANGO_DIR)/Libraries/cppserver/common
#=============================================================================
# PACKAGE_NAME is the name of the library/device/exe you want to build
#
PACKAGE_NAME = AGIPDMaster
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
#===============================================================================
RELEASE_TYPE = -g
#=============================================================================
# OUTPUT_TYPE can be one of the following :
......@@ -49,101 +16,93 @@ RELEASE_TYPE = DEBUG
# - 'SIMPLE_EXE' for an executable with no dependency (for exemple the test tool
# of a library with no Tango dependencies)
#
OUTPUT_TYPE = DEVICE
#OUTPUT_TYPE = DEVICE
#=============================================================================
# OUTPUT_DIR is the directory which contains the build result.
# if not set, the standard location is :
# - $HOME/DeviceServers if OUTPUT_TYPE is DEVICE
# - ../bin for others
#
OUTPUT_DIR = ./bin/$(BIN_DIR)
#OUTPUT_DIR = ./bin/$(PACKAGE_NAME)
#OBJS_DIR = obj
BUILD = build
OBJS_DIR = ./$(BUILD)
BIN_DIR = ./bin
LIB_PNIIO_CONFIG = $(shell pkg-config --libs pniio)
#=============================================================================
# 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 .
CPPFLAGS_PNIIO_CONFIG = $(shell pkg-config --cflags pniio)
ifndef _ARCH
_ARCH = $(shell uname -m)
endif
ifeq ($(_ARCH), x86_64)
libdir=lib64
else
libdir=lib
endif
#=============================================================================
# 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=
#check os
OS=$(shell lsb_release -i|sed 's/.*://'|sed 's/[[:space:]]//g')
#=============================================================================
# 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+=
ifeq ("$(OS)","Debian")
INC_DIR_USER= -I/usr/include/tango \
-I/usr/include \
-I.
LIB_DIR_USER= -L /usr/lib -L../../bin/usr/lib
else
INC_DIR_USER= -I/usr/local/include/tango \
-I/usr/local/include \
-I.
LIB_DIR_USER= -L /usr/local/$(libdir) -L../../bin/usr/lib
endif
#=============================================================================
# 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+= -O2 -std=c++0x
#=============================================================================
# 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
LFLAGS_USR= $(RELEASE_TYPE) -Wall $(LIB_DIR_USER) \
$(LIB_PNIIO_CONFIG) \
-ltango \
-llog4tango \
-lCOS4\
-lomniORB4 \
-lomniDynamic4 \
-lomnithread \
-ldl \
-lpthread \
-lstdc++
#=============================================================================
# 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
#used for time measurement during compression mode
#CXXFLAGS_USR =-O2 -DTIMEMEASUREMENT -std=c++0x $(RELEASE_TYPE) -D_REENTRANT \
$(CPPFLAGS_PNIIO_CONFIG) $(INC_DIR_USER)
CXXFLAGS_USR =-O3 -std=c++0x $(RELEASE_TYPE) -D_REENTRANT $(INC_DIR_USER)
SVC_OBJS = \
$(OBJDIR)/$(PACKAGE_NAME).o \
$(OBJDIR)/$(PACKAGE_NAME)Class.o \
$(OBJDIR)/$(PACKAGE_NAME)StateMachine.o \
$(OBJDIR)/ClassFactory.o \
$(OBJDIR)/main.o \
$(ADDITIONAL_OBJS)
SVC_INC = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h
#------------ Object files for additional files ------------
ADDITIONAL_OBJS =
SVC_OBJS = $(OBJS_DIR)/main.o \
$(OBJS_DIR)/ClassFactory.o \
$(OBJS_DIR)/$(PACKAGE_NAME)StateMachine.o \
$(OBJS_DIR)/$(PACKAGE_NAME)Class.o \
$(OBJS_DIR)/$(PACKAGE_NAME).o
#=============================================================================
# include common targets
#
include $(MAKE_ENV)/common_target.opt
$(OBJS_DIR)/%.o: %.cpp $(SVC_INC)
$(CXX) $(CXXFLAGS_USR) -c $< -o $(OBJS_DIR)/$*.o
all:$(PACKAGE_NAME)