Commit 4f86234b authored by Yuelong Yu's avatar Yuelong Yu
Browse files

working commit

added spectrum read out method.
parent c80c3ac0
......@@ -42,6 +42,7 @@ static const char *RcsId = "$Id: $";
#include <AGIPDMC.h>
#include <AGIPDMCClass.h>
#include "UpdateDataThread.h"
/*----- PROTECTED REGION END -----*/ // AGIPDMC.cpp
......@@ -125,6 +126,14 @@ void AGIPDMC::delete_device()
/*----- PROTECTED REGION ID(AGIPDMC::delete_device) ENABLED START -----*/
// Delete device allocated objects
{
omni_mutex_lock l(m_mtxData);
m_bSysExit = true;
}
int* nRet;
m_thData->join((void**)&nRet);
/*----- PROTECTED REGION END -----*/ // AGIPDMC::delete_device
delete[] attr_RawMatrix_read;
......@@ -154,7 +163,32 @@ void AGIPDMC::init_device()
/*----- PROTECTED REGION ID(AGIPDMC::init_device) ENABLED START -----*/
// Initialize device
std::fill(attr_RawMatrix_read,attr_RawMatrix_read+6000,0);
m_nDataLength = 6000;
m_bSysExit = false;
try
{
m_sptrDP = std::shared_ptr<Tango::DeviceProxy>(
new Tango::DeviceProxy(tTTGWDeviceName));
m_sptrDP->ping();
usleep(100);
cout<<"connects to "<<string(tTTGWDeviceName)<<endl;
}
catch(exception& e)
{
cout<<e.what()<<endl;
exit(0);
}
m_thData = new UpdateDataThread(this,m_sptrDP.get(),m_mtxData);
cout<<"start updating data..."<<endl;
set_state(Tango::MOVING);
/*----- PROTECTED REGION END -----*/ // AGIPDMC::init_device
}
......@@ -256,7 +290,7 @@ void AGIPDMC::read_RawMatrix(Tango::Attribute &attr)
DEBUG_STREAM << "AGIPDMC::read_RawMatrix(Tango::Attribute &attr) entering... " << endl;
/*----- PROTECTED REGION ID(AGIPDMC::read_RawMatrix) ENABLED START -----*/
// Set the attribute value
attr.set_value(attr_RawMatrix_read, 6000);
attr.set_value(attr_RawMatrix_read, m_nDataLength);
/*----- PROTECTED REGION END -----*/ // AGIPDMC::read_RawMatrix
}
......
......@@ -39,7 +39,7 @@
#define AGIPDMC_H
#include <tango.h>
#include <memory>
/*----- PROTECTED REGION END -----*/ // AGIPDMC.h
......@@ -65,7 +65,15 @@ class AGIPDMC : public TANGO_BASE_CLASS
/*----- PROTECTED REGION ID(AGIPDMC::Data Members) ENABLED START -----*/
// Add your own data members
private:
std::shared_ptr<Tango::DeviceProxy> m_sptrDP;
omni_thread* m_thData;
omni_mutex m_mtxData;
public:
bool m_bSysExit;
int m_nDataLength;
/*----- PROTECTED REGION END -----*/ // AGIPDMC::Data Members
// Device property data members
......@@ -194,6 +202,7 @@ public:
// Additional Method prototypes
/*----- PROTECTED REGION END -----*/ // AGIPDMC::Additional Method prototypes
};
......
......@@ -20,7 +20,7 @@
#=============================================================================
# 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
......@@ -91,7 +91,7 @@ LIB_DIR_USER=
#
# -DACE_HAS_EXCEPTIONS -D__ACE_INLINE__ for ACE
#
#CXXFLAGS_USR+= -Wall
CXXFLAGS_USR+= -w -g -std=c++0x
#=============================================================================
......@@ -119,7 +119,7 @@ include $(MAKE_ENV)/tango.opt
#=============================================================================
# SVC_OBJS is the list of all objects needed to make the output
#
SVC_INCL = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h
SVC_INCL = $(PACKAGE_NAME).h $(PACKAGE_NAME)Class.h UpdateDataThread.h
SVC_OBJS = \
......@@ -128,6 +128,7 @@ SVC_OBJS = \
$(OBJDIR)/$(PACKAGE_NAME)StateMachine.o \
$(OBJDIR)/ClassFactory.o \
$(OBJDIR)/main.o \
$(OBJDIR)/UpdateDataThread.o \
$(ADDITIONAL_OBJS)
SVC_INHERITANCE_OBJ = \
......
#include "UpdateDataThread.h"
namespace AGIPDMC_ns
{
UpdateDataThread::UpdateDataThread(AGIPDMC* _sptrAGIPDMC,
Tango::DeviceProxy* _sptrDP,
omni_mutex& _mtxData)
:omni_thread(),
Tango::LogAdapter(_sptrAGIPDMC),
m_sptrAGIPDMC(_sptrAGIPDMC),
m_sptrDP(_sptrDP),
m_mtxData(_mtxData)
{
start_undetached();
}
UpdateDataThread::~UpdateDataThread()
{
}
void* UpdateDataThread::run_undetached(void* ptr)
{
while(1)
{
//usleep(100);
sleep(2);
{
omni_mutex_lock l(m_mtxData);
if(m_sptrAGIPDMC->m_bSysExit)
break;
ReadOutSpectrum();
}
}
omni_thread::exit();
}
void UpdateDataThread::ReadOutSpectrum()
{
cout<<"Read out spectrum"<<endl;
}
}
#ifndef __UPDATE_DATA_THREAD__
#define __UPDATE_DATA_THREAD__
#include <tango.h>
#include "AGIPDMC.h"
namespace AGIPDMC_ns
{
class UpdateDataThread:public omni_thread,public Tango::LogAdapter
{
public:
UpdateDataThread(AGIPDMC* _sptrAGIPDMC,
Tango::DeviceProxy* _sptrDP,
omni_mutex& _mtxData);
~UpdateDataThread();
void *run_undetached(void*);
private:
void ReadOutSpectrum();
/// member variables
AGIPDMC* m_sptrAGIPDMC;
Tango::DeviceProxy* m_sptrDP;
omni_mutex& m_mtxData;
};
}
#endif
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment