Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
NomadModules
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Packages
Packages
Container Registry
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Instrument Control
NomadModules
Compare Revisions
68fa5f6854a04be462406453458594ecc2189ebc...5dc8b217d9bc75961102ae8fecd6ce40e36f2dd2
Source
5dc8b217d9bc75961102ae8fecd6ce40e36f2dd2
Select Git revision
...
Target
68fa5f6854a04be462406453458594ecc2189ebc
Select Git revision
Compare
Commits (2)
first version
· b1a60a26
d11
authored
May 02, 2019
b1a60a26
Merge branch 'master' of
https://code.ill.fr/instrument-control/nomad-modules.git
· 5dc8b217
d11
authored
May 02, 2019
5dc8b217
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
3467 additions
and
0 deletions
+3467
-0
src/drivers/gigecam/photonics/BufferInformation.h
src/drivers/gigecam/photonics/BufferInformation.h
+35
-0
src/drivers/gigecam/photonics/CameraHandler.cpp
src/drivers/gigecam/photonics/CameraHandler.cpp
+583
-0
src/drivers/gigecam/photonics/CameraHandler.h
src/drivers/gigecam/photonics/CameraHandler.h
+195
-0
src/drivers/gigecam/photonics/DoubleBufferHandler.cpp
src/drivers/gigecam/photonics/DoubleBufferHandler.cpp
+75
-0
src/drivers/gigecam/photonics/DoubleBufferHandler.h
src/drivers/gigecam/photonics/DoubleBufferHandler.h
+27
-0
src/drivers/gigecam/photonics/Module.xml
src/drivers/gigecam/photonics/Module.xml
+8
-0
src/drivers/gigecam/photonics/PerfectPhotonicsDriver.cpp
src/drivers/gigecam/photonics/PerfectPhotonicsDriver.cpp
+159
-0
src/drivers/gigecam/photonics/PerfectPhotonicsDriver.h
src/drivers/gigecam/photonics/PerfectPhotonicsDriver.h
+111
-0
src/drivers/gigecam/photonics/PhotonicsDef.h
src/drivers/gigecam/photonics/PhotonicsDef.h
+194
-0
src/drivers/gigecam/photonics/PhotonicsDriver.cpp
src/drivers/gigecam/photonics/PhotonicsDriver.cpp
+243
-0
src/drivers/gigecam/photonics/PhotonicsDriver.h
src/drivers/gigecam/photonics/PhotonicsDriver.h
+137
-0
src/drivers/gigecam/photonics/PhotonicsState.h
src/drivers/gigecam/photonics/PhotonicsState.h
+110
-0
src/drivers/gigecam/photonics/RealPhotonicsDriver.cpp
src/drivers/gigecam/photonics/RealPhotonicsDriver.cpp
+860
-0
src/drivers/gigecam/photonics/RealPhotonicsDriver.h
src/drivers/gigecam/photonics/RealPhotonicsDriver.h
+250
-0
src/drivers/gigecam/photonics/SimulatedPhotonicsDriver.cpp
src/drivers/gigecam/photonics/SimulatedPhotonicsDriver.cpp
+177
-0
src/drivers/gigecam/photonics/SimulatedPhotonicsDriver.h
src/drivers/gigecam/photonics/SimulatedPhotonicsDriver.h
+111
-0
src/drivers/gigecam/photonics/gui/photonics.properties
src/drivers/gigecam/photonics/gui/photonics.properties
+130
-0
src/drivers/gigecam/photonics/gui/photonicsPlugin.xml
src/drivers/gigecam/photonics/gui/photonicsPlugin.xml
+7
-0
src/drivers/gigecam/photonics/gui/photonicsProperties.xml
src/drivers/gigecam/photonics/gui/photonicsProperties.xml
+30
-0
src/drivers/gigecam/photonics/gui/photonicsView.xml
src/drivers/gigecam/photonics/gui/photonicsView.xml
+25
-0
No files found.
src/drivers/gigecam/photonics/BufferInformation.h
0 → 100644
View file @
5dc8b217
#ifndef _BUFFER_INFORMATION_
#define _BUFFER_INFORMATION_
#include <thread>
#include <vector>
#include <mutex>
#include <list>
#define _GNULINUX
#include <bgapi2_genicam/bgapi2_genicam.hpp>
// structure which holds additional information
// transferred together with the camera buffer
// this structure should be adapted to needs of the application
struct
BufferInformation
{
BufferInformation
()
{
frameid
=
0
;
number_of_incomplete_images
=
0
;
resend_requests
=
0
;
resend_requests_single
=
0
;
resend_requests_range
=
0
;
}
// frame id of the camera buffer
bo_uint64
frameid
;
// statistic value, number of incomplete images
bo_uint64
number_of_incomplete_images
;
// statistic value, number of resend requests
bo_int64
resend_requests
;
// statistic value, number resend requests requesting a single data packet
bo_int64
resend_requests_single
;
// statistic value, number of resend requests requesting a bunch of data packet
bo_int64
resend_requests_range
;
};
#endif //_BUFFER_INFORMATION_
src/drivers/gigecam/photonics/CameraHandler.cpp
0 → 100644
View file @
5dc8b217
This diff is collapsed.
Click to expand it.
src/drivers/gigecam/photonics/CameraHandler.h
0 → 100644
View file @
5dc8b217
#pragma once
#include <thread>
#include <vector>
#include <mutex>
#include <list>
#define _GNULINUX
#include </usr/local/src/baumer/inc/bgapi2_genicam/bgapi2_genicam.hpp>
#include "DoubleBufferHandler.h"
// the class represents a BGAPI camera object and additional camera specific information
class
CCameraControl
{
public:
// this function activates the feature command
// the feature command use the ExposureTime feature of the camera
// the parameter passes the new exposure time to be written to the camera
void
StartFeatureCommandExposure
(
double
exposure_time
);
// this function activates the capture command
// the parameter passes the number of images to be captured
void
StartCaptureCommand
(
unsigned
int
images
);
// this function checks, if the capture command was activated
// in this case the capture command is automatically reset
bool
IsCommandCaptureActivated
();
// this function checks, if the feature command was activated
// in this case the feature command is automatically reset
bool
IsCommandExposureActivated
();
// this function writes the desired exposure time to the passed camera
bool
ExposureFeatureBGAPI
();
// this function makes all necessary preparations on the buffer management to be able to capture images with BGAPI
// it opens the data stream and creates the camera buffers
void
InitializeBGAPIBufferManagement
();
// this function clears the buffer management and
// deletes the camera buffers
void
DeinitializeBGAPIBufferManagement
();
// this function capture the desired number of images from the passed camera
// and store some additional information (BufferInformation struct)
bool
CaptureBGAPIImages
(
const
bool
*
abort_flag
,
unsigned
int
number_of_images
);
// this function starts the streaming for the passed camera
bool
StartStreamingBGAPI
();
// this function stops the streaming for the passed camera
void
StopStreamingBGAPI
();
// this function fill the BufferInformation struct
void
FillBufferInformation
(
BGAPI2
::
DataStream
*
datastream_pointer
,
BGAPI2
::
Buffer
*
buffer
);
// function to add a string with logging information to the logging string list
void
LoggingStringAdd
(
std
::
string
logging_message
);
// this function returns a logging string and remove this string from the logging string list
std
::
string
LoggingString
();
// function to check, if some logging information is available
bool
LoggingListEmpty
()
{
return
(
logging_list_
.
size
()
==
0
);
}
public:
// buffer exchange strategy (double buffer)
CDoubleBufferHandler
buffer_handler_
;
// BGAPI camera object
BGAPI2
::
Device
*
camera_pointer_
;
// a list to transfer massages, generated by the feature command
std
::
list
<
std
::
string
>
feature_command_message_list_
;
// a mutex to synchronize the access to feature_command_message_list_
std
::
mutex
feature_command_message_list_lock_
;
// a worker thread that captures images from BGAPI
std
::
thread
capture_thread_
;
// a worker thread that control camera features from BGAPI
std
::
thread
feature_thread_
;
// a flag which controls the capture command
bool
command_capture_
;
// a flag which shows if the capture command is active
bool
capture_active_
;
// number of images to capture
unsigned
int
number_of_images_
;
// number of currently captured images
unsigned
int
number_of_captured_images_
;
// number of incomplete images
unsigned
int
number_of_incomplete_images_
;
// a flag which controls the feature command
bool
command_feature_
;
// exposure time to be set
double
exposure_time_
;
private:
// mutex to synchronize the access to capture command flag of all cameras
std
::
mutex
capture_command_lock_
;
// mutex to synchronize the access to feature command flag of all cameras
std
::
mutex
feature_command_lock_
;
// a list which holds logging strings
std
::
list
<
std
::
string
>
logging_list_
;
// a mutex to synchronize the access to the logging list
std
::
mutex
logging_list_lock_
;
};
// the class encapsulate camera search, capture command and feature command
// it also implements the worker threads
class
CCameraHandler
{
// ----
// public functions which are used in the context of the main thread and application threads
// to control the main settings from the user application
// ----
public:
// construction / destruction
CCameraHandler
();
virtual
~
CCameraHandler
();
// this function starts the init thread to search for connected cameras
// it also passed the buffer handler
void
Start
(
CDoubleBufferHandler
buffer_handler
);
// close all connected cameras and frees all BGAPI resources
// this function doesn't run in a separate thread
void
Stop
();
// this function initialize the buffer management of all connected cameras
// it also creates the struct BufferInformation for every camera buffer
// all cameras use 10 buffers to store the image data
// the memory for the camera buffers will be allocated inside BGAPI
// the size of the memory to allocated will determined from the maximum image size
// this function also starts the worker threads
void
StartCameras
();
// this function stops the worker threads
// and deinitialize the BGAPI
void
StopCameras
();
// function to check for an initialisation error
bool
IsInitOK
();
// returns the number of connected cameras
size_t
NumberOfCameras
();
// this function returns the number of images taken by the camera that took the least number of images
unsigned
int
CapturedImages
();
// function to return the camera control vector
const
std
::
vector
<
CCameraControl
*>*
GetCameraControlVector
()
{
return
&
camera_control_
;
}
// this function returns a logging string and remove this string from the logging string list
std
::
string
LoggingString
();
// function to check, if some logging information is available
bool
LoggingListEmpty
()
{
return
(
logging_list_
.
size
()
==
0
);
}
// ----
// public functions which are partly used in the worker threads
// to handle and process the code regarding to main settings
// ----
public:
// this function initializes the Baumer GAPI SDK and
// searches for connected cameras
// all found cameras will be opened to work with
void
InitializeBGAPI
();
// this function deinitialises the Baumer GAPI SDK and
// close all connected cameras
void
DeinitializeBGAPI
();
// function to signal an initialisation error while start up
void
SetInitError
();
// function to add a string with logging information to the logging string list
void
LoggingStringAdd
(
std
::
string
logging_message
);
// this function adds a camera object to the camera control vector
void
AddCamera
(
BGAPI2
::
Device
*
camera_pointer
);
// this function set a flag to signal the worker thread to exit
const
bool
*
FinishWorkerThreads
()
{
return
&
finish_worker_threads_
;
}
private:
// pointer to the buffer handler
CDoubleBufferHandler
buffer_handler_
;
// flag to signal the worker threads to exit themselves
bool
finish_worker_threads_
;
// initialisation thread
std
::
thread
init_thread
;
// camera control vector holds information regarding synchronisation and
// the BGAPI camera object
std
::
vector
<
CCameraControl
*>
camera_control_
;
// flag is set for initialisation errors
bool
init_ok_
;
// a list which holds logging strings
std
::
list
<
std
::
string
>
logging_list_
;
// a mutex to synchronize the access to the logging list
std
::
mutex
logging_list_lock_
;
};
src/drivers/gigecam/photonics/DoubleBufferHandler.cpp
0 → 100644
View file @
5dc8b217
#include <iostream>
#include <sstream>
#include "DoubleBufferHandler.h"
#include "BufferInformation.h"
CDoubleBufferHandler
::
CDoubleBufferHandler
()
:
buffer_read_
(
nullptr
)
,
buffer_write_
(
nullptr
)
,
new_data
(
false
)
{
}
CDoubleBufferHandler
::~
CDoubleBufferHandler
()
{
}
void
CDoubleBufferHandler
::
PushBuffer
(
BGAPI2
::
Buffer
*
buffer
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
buffer_exchange_lock_
);
if
(
!
buffer_write_
)
{
buffer_write_
=
buffer
;
new_data
=
true
;
}
else
{
buffer
->
QueueBuffer
();
}
}
BGAPI2
::
Buffer
*
CDoubleBufferHandler
::
PullBuffer
()
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
buffer_exchange_lock_
);
if
(
buffer_write_
)
{
if
(
buffer_read_
)
{
buffer_read_
->
QueueBuffer
();
}
buffer_read_
=
buffer_write_
;
buffer_write_
=
nullptr
;
new_data
=
false
;
}
return
buffer_read_
;
}
void
CDoubleBufferHandler
::
FreeBuffer
(
BGAPI2
::
Buffer
*
buffer
)
{
std
::
lock_guard
<
std
::
mutex
>
lock
(
buffer_exchange_lock_
);
if
(
buffer_read_
&&
buffer_write_
)
{
buffer_read_
->
QueueBuffer
();
buffer_read_
=
nullptr
;
}
}
void
CDoubleBufferHandler
::
Init
()
{
if
(
buffer_write_
)
{
buffer_write_
->
QueueBuffer
();
buffer_write_
=
nullptr
;
}
if
(
buffer_read_
)
{
buffer_read_
->
QueueBuffer
();
buffer_read_
=
nullptr
;
}
new_data
=
false
;
}
bool
CDoubleBufferHandler
::
HasNewData
()
{
return
new_data
;
}
CDoubleBufferHandler
::
CDoubleBufferHandler
(
const
CDoubleBufferHandler
&
instance
)
{
buffer_read_
=
instance
.
buffer_read_
;
buffer_write_
=
instance
.
buffer_write_
;
}
CDoubleBufferHandler
&
CDoubleBufferHandler
::
operator
=
(
const
CDoubleBufferHandler
&
instance
)
{
buffer_read_
=
instance
.
buffer_read_
;
buffer_write_
=
instance
.
buffer_write_
;
return
*
this
;
}
src/drivers/gigecam/photonics/DoubleBufferHandler.h
0 → 100644
View file @
5dc8b217
#pragma once
#include <thread>
#include <vector>
#include <mutex>
#include <list>
#define _GNULINUX
#include </usr/local/src/baumer/inc/bgapi2_genicam/bgapi2_genicam.hpp>
class
CDoubleBufferHandler
{
public:
CDoubleBufferHandler
();
CDoubleBufferHandler
(
const
CDoubleBufferHandler
&
instance
);
virtual
~
CDoubleBufferHandler
();
virtual
void
PushBuffer
(
BGAPI2
::
Buffer
*
buffer
);
virtual
BGAPI2
::
Buffer
*
PullBuffer
();
virtual
void
FreeBuffer
(
BGAPI2
::
Buffer
*
buffer
);
virtual
void
Init
();
virtual
bool
HasNewData
();
CDoubleBufferHandler
&
operator
=
(
const
CDoubleBufferHandler
&
instance
);
private:
BGAPI2
::
Buffer
*
buffer_read_
;
BGAPI2
::
Buffer
*
buffer_write_
;
std
::
mutex
buffer_exchange_lock_
;
bool
new_data
;
};
src/drivers/gigecam/photonics/Module.xml
0 → 100644
View file @
5dc8b217
<module
name=
"photonics"
>
<driver
class=
"photonics::PhotonicsDriver"
/>
<link
path=
"/usr/local/lib/baumer"
lib=
"bgapi2_genicam"
/>
<link
lib=
"opencv_core"
/>
<link
lib=
"opencv_calib3d"
/>
<link
lib=
"opencv_highgui"
/>
<include
path=
"/usr/local/src/baumer/inc"
/>
</module>
src/drivers/gigecam/photonics/PerfectPhotonicsDriver.cpp
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "PhotonicsDef.h"
#include "PhotonicsDriver.h"
#include "PerfectPhotonicsDriver.h"
#include <stdlib.h>
namespace
photonics
{
/*
* Constructor
*/
PerfectPhotonicsDriver
::
PerfectPhotonicsDriver
(
PhotonicsDriver
*
owner
)
:
PhotonicsState
(
owner
)
{
/* Empty */
}
/*
* Destructor
*/
PerfectPhotonicsDriver
::~
PerfectPhotonicsDriver
()
{
/* Empty */
}
void
PerfectPhotonicsDriver
::
init
()
{
}
/*
* clearvme/daugther/Photonics
*/
void
PerfectPhotonicsDriver
::
clear
()
{
// Read command
owner
()
->
time
=
0
;
owner
()
->
counts
=
0
;
owner
()
->
counts2
=
0
;
owner
()
->
counts3
=
0
;
}
/*
* writeParam
*/
void
PerfectPhotonicsDriver
::
writeParam
()
{
}
/*
* synchroniseRead
*/
void
PerfectPhotonicsDriver
::
synchroniseRead
()
{
read
();
owner
()
->
m_SynchroniseReadTerminated
=
true
;
}
//
///*
// * regroup
// */
//void PerfectPhotonicsDriver::regroup() {
// std::cout << owner()->xSize() << std::endl;
// std::cout << owner()->ySize() << std::endl;
//}
/*
* read
*/
void
PerfectPhotonicsDriver
::
read
()
{
// Read command
int32
size
=
owner
()
->
dataSize
();
int32
*
tab
=
owner
()
->
data
();
int32
sum
=
0
;
// if (m_FirstRead) {
// for (uint32 i=0;i<size;i++) {
// tab[i] = i + 1;
// sum = sum + tab[i];
// }
// m_FirstRead = false;
// } else {
// for (uint32 i=0;i<size;i++) {
// tab[i] = tab[i] + 1;
// sum = sum + tab[i];
// }
// }
for
(
int32
i
=
0
;
i
<
size
;
i
++
)
{
tab
[
i
]
=
i
;
sum
=
sum
+
tab
[
i
];
}
owner
()
->
sum
=
sum
;
owner
()
->
data
.
sendEvent
();
}
/*
* pause
*/
void
PerfectPhotonicsDriver
::
pause
()
{
}
/*
* continue
*/
void
PerfectPhotonicsDriver
::
resume
()
{
}
/*
* start
*/
void
PerfectPhotonicsDriver
::
start
()
{
owner
()
->
time
=
owner
()
->
time
.
setpoint
();
}
/*
* stop
*/
void
PerfectPhotonicsDriver
::
stop
()
{
}
/*
* readStatus
*/
void
PerfectPhotonicsDriver
::
readStatus
()
{
owner
()
->
startActivated
=
false
;
// Status command
owner
()
->
computeGateStatus
(
photonics
::
READOUT_COMPLETE
);
owner
()
->
computeAcquisitionStatus
(
0
);
owner
()
->
computeDetectorStatus
(
0
);
if
(
owner
()
->
m_SynchroniseReadActivated
==
true
)
{
if
(
owner
()
->
m_SynchroniseReadTerminated
==
true
)
{
owner
()
->
m_SynchroniseReadActivated
=
false
;
owner
()
->
m_SynchroniseReadTerminated
=
false
;
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
else
{
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
/*
* readInfos
*/
void
PerfectPhotonicsDriver
::
readInfos
()
{
}
}
src/drivers/gigecam/photonics/PerfectPhotonicsDriver.h
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PERFECTPHOTONICSDRIVER_H
#define PERFECTPHOTONICSDRIVER_H
#include "PhotonicsState.h"
namespace
photonics
{
/*!
* \class PerfectPhotonicsDriver
* \brief Perfect implementation class for the Photonics device driver
*
* This class is a perfect implementation of Photonics device driver.
* On start command, all actual values become target's ones.
*/
class
PerfectPhotonicsDriver
:
public
PhotonicsState
{
public:
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
PerfectPhotonicsDriver
(
PhotonicsDriver
*
owner
);
/*!
* \brief Destructor
*/
virtual
~
PerfectPhotonicsDriver
();
/*!
* \brief Init command implementation
*/
virtual
void
init
();
/*!
* \brief Clear command implementation
*/
virtual
void
clear
();
/*!
* \brief Write Param command implementation
*/
virtual
void
writeParam
();
/*!
* \brief Read command implementation
*/
virtual
void
read
();
/*!
* \brief Synchronize Read command implementation
*/
virtual
void
synchroniseRead
();
/*!
* \brief Start command implementation
*/
virtual
void
start
();
/*!
* \brief Resume command implementation
*/
virtual
void
resume
();
/*!
* \brief Pause command implementation
*/
virtual
void
pause
();
/*!
* \brief Stop command implementation
*/
virtual
void
stop
();
/*!
* \brief Read Infos command implementation
*/
virtual
void
readStatus
();
/*!
* \brief Read Infos command implementation
*/
virtual
void
readInfos
();
/*!
* \brief Regroup command implementation
*/
// virtual void regroup();
};
}
#endif //PERFECTPHOTONICSDRIVER_H
src/drivers/gigecam/photonics/PhotonicsDef.h
0 → 100644
View file @
5dc8b217
This diff is collapsed.
Click to expand it.
src/drivers/gigecam/photonics/PhotonicsDriver.cpp
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "PhotonicsDef.h"
#include "PhotonicsDriver.h"
#include "PhotonicsState.h"
#include "PerfectPhotonicsDriver.h"
#include "RealPhotonicsDriver.h"
#include "SimulatedPhotonicsDriver.h"
#include <math.h>
using
namespace
std
;
namespace
photonics
{
const
std
::
string
PhotonicsDriver
::
TYPE
=
"photonics"
;
const
std
::
string
PhotonicsDriver
::
MODE
[
4
]
=
{
"Standard"
,
"Average"
,
"Summation"
,
"Accumulation"
};
/*
* Constructor
*/
PhotonicsDriver
::
PhotonicsDriver
(
const
string
&
name
)
:
acquisition
::
NoTofAcquisitionCommon
(
name
),
acquisition
::
KineticAcquisitionCommon
(
name
),
acquisition
::
TimeGateCommon
(
name
),
acquisition
::
DetectorCommon
(
name
)
{
registerStates
(
new
RealPhotonicsDriver
(
this
),
new
PerfectPhotonicsDriver
(
this
),
new
SimulatedPhotonicsDriver
(
this
));
driver
::
SocketTcp
::
init
(
name
);
nbCols
.
init
(
this
,
SAVE
,
"nbCols"
);
nbRows
.
init
(
this
,
SAVE
,
"nbRows"
);
height
.
init
(
this
,
SAVE
,
"height"
);
width
.
init
(
this
,
SAVE
,
"width"
);
acqmode
.
init
(
this
,
SAVE
,
"acqmode"
);
gain
.
init
(
this
,
SAVE
,
"gain"
);
nbFrame
.
init
(
this
,
SAVE
,
"nbFrame"
);
bpixel
.
init
(
this
,
SAVE
,
"bpixel"
);
fileSimu
.
init
(
this
,
SAVE
,
"file_simu"
);
indexSimu
.
init
(
this
,
SAVE
,
"index_simu"
);
fileDirectory
.
init
(
this
,
SAVE
,
"fileDirectory"
);
fileName
.
init
(
this
,
SAVE
,
"fileName"
);
numor
.
init
(
this
,
SAVE
,
"numor"
);
header
.
init
(
this
,
NOSAVE
,
"header"
);
aTimouOut
.
init
(
this
,
SAVE
,
"camtimeout"
);
initCommand
(
driver
::
INIT_COMMAND
);
initCommand
(
driver
::
READ_COMMAND
);
initCommand
(
driver
::
SYNCHRONIZE_READ_COMMAND
);
initCommand
(
driver
::
START_COMMAND
);
initCommand
(
driver
::
RESUME_COMMAND
);
initCommand
(
driver
::
PAUSE_COMMAND
);
initCommand
(
driver
::
STOP_COMMAND
);
initCommand
(
driver
::
STATUS_COMMAND
);
initCommand
(
driver
::
READ_INFOS_COMMAND
);
initCommand
(
DetectorCommon
::
CLEAR_COMMAND
);
initCommand
(
DetectorCommon
::
REGROUP_COMMAND
);
initCommand
(
AcquisitionCommon
::
WRITE_PARAMETERS_COMMAND
);
initCommand
(
driver
::
INIT_COMMAND
);
// Init functions
registerFunction
(
NONE_FUNCTION
);
deviceType
=
LEAF_DEVICE_TYPE_DEVICE_CONTAINER
;
m_DoSynchroniseRead
=
false
;
m_SynchroniseReadActivated
=
false
;
m_SynchroniseReadTerminated
=
false
;
m_DataShort
=
NULL
;
registerObserverCommand
(
COMMAND_STATUS_DEVICE_CONTAINER
,
50
);
}
/*
* Destructor
*/
PhotonicsDriver
::~
PhotonicsDriver
()
{
}
/*
* refreshDataSizeProperty
*/
void
PhotonicsDriver
::
refreshDataSizeProperty
(
int32
value
)
throw
(
CannotSetValue
)
{
if
(
m_DataShort
!=
NULL
)
{
delete
[]
m_DataShort
;
}
m_DataShort
=
new
uint16
[
value
];
if
(
m_DataShort
==
NULL
)
{
sendErrorEvent
(
NOTENOUGH_MEMORY_ERROR
,
"Can't create data table"
);
throw
CannotSetValue
();
}
DetectorCommon
::
refreshDataSizeProperty
(
value
);
}
/*
* refreshModeProperty
*/
void
PhotonicsDriver
::
refreshModeProperty
(
int32
value
)
throw
(
CannotSetValue
)
{
if
(
value
!=
acquisition
::
GateCommon
::
TIME_MODE
)
{
throw
CannotSetValue
();
}
}
/*
* execute
*/
void
PhotonicsDriver
::
execute
(
const
std
::
string
&
aCommand
)
{
if
((
aCommand
!=
driver
::
PAUSE_COMMAND
)
&&
(
aCommand
!=
driver
::
STOP_COMMAND
)
&&
(
aCommand
!=
driver
::
STATUS_COMMAND
)
&&
(
aCommand
!=
driver
::
READ_COMMAND
))
{
commandProgression
=
PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER
;
}
PhotonicsState
*
currentState
=
dynamic_cast
<
PhotonicsState
*>
(
getCurrentState
());
// Check command
if
(
aCommand
==
driver
::
INIT_COMMAND
)
{
// Init command
currentState
->
init
();
}
else
if
(
aCommand
==
driver
::
READ_COMMAND
)
{
// Read command
currentState
->
read
();
}
else
if
(
aCommand
==
driver
::
SYNCHRONIZE_READ_COMMAND
)
{
// Read command
if
(
m_DoSynchroniseRead
==
true
)
{
m_SynchroniseReadActivated
=
true
;
m_SynchroniseReadTerminated
=
false
;
currentState
->
synchroniseRead
();
m_DoSynchroniseRead
=
false
;
}
else
{
m_SynchroniseReadActivated
=
false
;
m_SynchroniseReadTerminated
=
false
;
}
}
else
if
(
aCommand
==
driver
::
START_COMMAND
)
{
// Start command
startActivated
=
true
;
m_DoSynchroniseRead
=
true
;
currentState
->
start
();
}
else
if
(
aCommand
==
driver
::
RESUME_COMMAND
)
{
// Continue command
currentState
->
resume
();
}
else
if
(
aCommand
==
driver
::
PAUSE_COMMAND
)
{
// Stop command
currentState
->
pause
();
}
else
if
(
aCommand
==
driver
::
STOP_COMMAND
)
{
// Stop command
currentState
->
stop
();
startActivated
=
false
;
}
else
if
(
aCommand
==
driver
::
STATUS_COMMAND
)
{
// Status command
currentState
->
readStatus
();
}
else
if
(
aCommand
==
driver
::
READ_INFOS_COMMAND
)
{
// Info command
currentState
->
readInfos
();
}
else
if
(
aCommand
==
DetectorCommon
::
CLEAR_COMMAND
)
{
// Move command
sum
=
0
;
currentState
->
clear
();
}
else
if
(
aCommand
==
DetectorCommon
::
REGROUP_COMMAND
)
{
// currentState->regroup();
}
else
if
(
aCommand
==
AcquisitionCommon
::
WRITE_PARAMETERS_COMMAND
)
{
// Write command
currentState
->
writeParam
();
}
else
{
//Error bad command
//Todo , normaly it will be detect it device action driver
}
}
/*
* calculateProgression
*/
void
PhotonicsDriver
::
calculateProgression
()
{
int32
progression
=
0
;
float64
setpoint
=
0.0
;
float64
actual
=
0.0
;
setpoint
=
time
.
setpoint
();
actual
=
time
();
if
(
setpoint
==
0.0
)
{
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
else
{
progression
=
(
int32
)
(
actual
/
setpoint
*
PROGRESSION_RATIO_DEVICE_CONTAINER
);
// Be sure that progression > 0%
if
(
progression
<
PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER
)
progression
=
0
;
// Be sure that only Phased status put 100%
if
(
progression
>=
PROGRESSION_END_DEVICE_CONTAINER
)
progression
=
PROGRESSION_END_DEVICE_CONTAINER
-
1
;
commandProgression
=
progression
;
}
}
/*
* PhotonicsDriver
*/
void
PhotonicsDriver
::
computeGateStatus
(
int32
value
)
{
int32
valueout
=
0
;
if
(
value
==
COUNTING
)
{
valueout
|=
GateCommon
::
RUNNING_STATUS
;
}
else
if
(
value
==
END
)
{
valueout
|=
GateCommon
::
END_STATUS
;
}
status
.
update
(
value
);
gateStatus
.
update
(
valueout
);
}
/*
* PhotonicsDriver
*/
void
PhotonicsDriver
::
computeDetectorStatus
(
int32
value
)
{
int32
valueout
=
0
;
detectorStatus
.
update
(
valueout
);
}
/*
* PhotonicsDriver
*/
void
PhotonicsDriver
::
computeAcquisitionStatus
(
int32
value
)
{
int32
valueout
=
0
;
acquisitionStatus
.
update
(
valueout
);
}
}
src/drivers/gigecam/photonics/PhotonicsDriver.h
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PHOTONICSDRIVER_H
#define PHOTONICSDRIVER_H
#include <Driver.h>
#include "controllers/common/acquisition/gate/TimeGateCommon.h"
#include "controllers/common/acquisition/mode/NoTofAcquisitionCommon.h"
#include "controllers/common/acquisition/mode/TofAcquisitionCommon.h"
#include "controllers/common/acquisition/mode/KineticAcquisitionCommon.h"
#include "controllers/common/acquisition/detector/DetectorCommon.h"
#include "drivers/global/sockettcp/SocketTcp.h"
#include "drivers/legacy/def/DriverErrorDef.h"
namespace
photonics
{
/**
* Global Implementation of the vme card called Psl made in Ill. It needs a board called Men A201.
*/
class
PhotonicsDriver
:
public
acquisition
::
NoTofAcquisitionCommon
,
public
acquisition
::
TimeGateCommon
,
public
acquisition
::
KineticAcquisitionCommon
,
public
acquisition
::
DetectorCommon
,
public
driver
::
SocketTcp
{
friend
class
RealPhotonicsDriver
;
friend
class
PerfectPhotonicsDriver
;
friend
class
SimulatedPhotonicsDriver
;
public:
static
const
std
::
string
MODE
[
4
];
//! Driver type value
static
const
std
::
string
TYPE
;
static
const
std
::
string
ON_COMMAND
;
static
const
std
::
string
OFF_COMMAND
;
/*!
* \brief Constructor
* \param[in] name the name of the device driver
*/
PhotonicsDriver
(
const
std
::
string
&
name
);
/*!
* \brief Destructor
*/
virtual
~
PhotonicsDriver
();
/*!
* \brief Method called for executing a command
*
* \param[in] command the command to apply on the controller
*/
virtual
void
execute
(
const
std
::
string
&
aCommand
);
/*!
* \brief Calculate the progression state.
*/
void
calculateProgression
();
Property
<
int32
>
nbCols
;
Property
<
int32
>
nbRows
;
Property
<
int32
>
height
;
Property
<
int32
>
width
;
Property
<
int32
>
acqmode
;
Property
<
int32
>
nbFrame
;
Property
<
int32
>
aTimouOut
;
Property
<
bool
>
bpixel
;
Property
<
int32
>
gain
;
Property
<
std
::
string
>
fileSimu
;
Property
<
int32
>
indexSimu
;
Property
<
std
::
string
>
fileDirectory
;
Property
<
std
::
string
>
fileName
;
Property
<
int32
>
numor
;
Property
<
std
::
string
>
header
;
private:
/*!
* \brief Method called before changing the data size property value
* \param[in] value the property value
* \throws CannotSetValue the value isn't corrected, or property couldn't be changed
*/
virtual
void
refreshDataSizeProperty
(
int32
value
)
throw
(
CannotSetValue
);
virtual
void
refreshModeProperty
(
int32
value
)
throw
(
CannotSetValue
);
/*!
* \brief compute global gate status
* \param[in] value the driver status
*/
virtual
void
computeGateStatus
(
int32
value
);
/*!
* \brief compute global acquisition status
* \param[in] value the driver status
*/
virtual
void
computeAcquisitionStatus
(
int32
value
);
/*!
* \brief compute global detector status
* \param[in] value the driver status
*/
virtual
void
computeDetectorStatus
(
int32
value
);
uint16
*
m_DataShort
;
/**
* flag for synchronise read
*/
bool
m_DoSynchroniseRead
;
bool
m_SynchroniseReadActivated
;
bool
m_SynchroniseReadTerminated
;
};
}
#endif //PSLDRIVER_H
src/drivers/gigecam/photonics/PhotonicsState.h
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef PHOTONICSSTATE_H
#define PHOTONICSSTATE_H
#include "PhotonicsDriver.h"
#include <Driver.h>
namespace
photonics
{
/*!
* \class PhotonicsState
* \brief Virtual class for implement State pattern
*
* Define all methods that perfect, simulated and real classes have to implement
*/
class
PhotonicsState
:
public
DriverState
<
PhotonicsDriver
>
{
public:
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
PhotonicsState
(
PhotonicsDriver
*
owner
)
:
DriverState
<
PhotonicsDriver
>
(
owner
)
{
}
/*!
* \brief Destructor
*/
virtual
~
PhotonicsState
()
{
}
/*!
* \brief Clear command implementation
*/
virtual
void
clear
()
=
0
;
/*!
* \brief Write Param command implementation
*/
virtual
void
writeParam
()
=
0
;
/*!
* \brief Read command implementation
*/
virtual
void
read
()
=
0
;
/*!
* \brief Synchronize Read command implementation
*/
virtual
void
synchroniseRead
()
=
0
;
/*!
* \brief Start command implementation
*/
virtual
void
start
()
=
0
;
/*!
* \brief Resume command implementation
*/
virtual
void
resume
()
=
0
;
/*!
* \brief Pause command implementation
*/
virtual
void
pause
()
=
0
;
/*!
* \brief Stop command implementation
*/
virtual
void
stop
()
=
0
;
/*!
* \brief Read Infos command implementation
*/
virtual
void
readStatus
()
=
0
;
/*!
* \brief Read Infos command implementation
*/
virtual
void
readInfos
()
=
0
;
//
// /*!
// * \brief Regroup command implementation
// */
// virtual void regroup() = 0;
};
}
#endif //PHOTONICSSTATE_H
src/drivers/gigecam/photonics/RealPhotonicsDriver.cpp
0 → 100644
View file @
5dc8b217
This diff is collapsed.
Click to expand it.
src/drivers/gigecam/photonics/RealPhotonicsDriver.h
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef REALPHOTONICSDRIVER_H
#define REALPHOTONICSDRIVER_H
#include "PhotonicsDef.h"
#include "PhotonicsState.h"
#include <string>
#include <vector>
#include "Utilities/Counter.h"
#include "CameraHandler.h"
#include "DoubleBufferHandler.h"
#include "BufferInformation.h"
#include </usr/local/src/baumer/inc/bgapi2_genicam/bgapi2_genicam.hpp>
namespace
photonics
{
/*!
* \class RealPhotonicsDriver
* \brief Real implementation class for the Psl device driver
*
* This class is a real implementation of Psl device driver.
*/
class
RealPhotonicsDriver
:
public
PhotonicsState
{
public:
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
RealPhotonicsDriver
(
PhotonicsDriver
*
owner
);
/*!
* \brief Destructor
*/
virtual
~
RealPhotonicsDriver
();
/*!
* \brief Init command implementation
*/
virtual
void
init
();
/*!
* \brief Clear command implementation
*/
virtual
void
clear
();
/*!
* \brief Write Param command implementation
*/
virtual
void
writeParam
();
/*!
* \brief Read command implementation
*/
virtual
void
read
();
/*!
* \brief Synchronize Read command implementation
*/
virtual
void
synchroniseRead
();
/*!
* \brief Start command implementation
*/
virtual
void
start
();
/*!
* \brief Resume command implementation
*/
virtual
void
resume
();
/*!
* \brief Pause command implementation
*/
virtual
void
pause
();
/*!
* \brief Stop command implementation
*/
virtual
void
stop
();
/*!
* \brief Read Infos command implementation
*/
virtual
void
readStatus
();
/*!
* \brief Read Infos command implementation
*/
virtual
void
readInfos
();
/*!
* \brief Regroup command implementation
*/
// virtual void regroup();
// int32 GetAvailablePhotonicseras();
// std::string getConfigFile(BGAPI2::Device* device);
private:
// a flag which controls the status command
std
::
atomic
<
bool
>
command_status
;
// a flag which controls the calculation command
std
::
atomic
<
bool
>
command_calculation
;
// this function activates the feature command on all connected cameras
// the feature command use the ExposureTime feature of the camera
// the parameter passes the new exposure time to be written to the cameras
void
StartFeatureCommandExposure
(
CCameraHandler
*
camera_handler
,
double
exposure_time
);
// this function activates the capture command on all connected cameras
// the parameter passes the number of images to be captured
void
StartCaptureCommand
(
CCameraHandler
*
camera_handler
,
unsigned
int
images
);
// -------------
// thread control, finish flag and thread functions
// -------------
// a flag which is used to stop all the used threads at once
bool
finish_console_threads
=
false
;
// the thread routine of the status command is used to print status information about the current buffer,
// exposure time, logging information and calculation results
// prints the status information to the console
void
StatusThreadRoutine
(
CCameraHandler
*
camera_handler
);
// the thread routine of the calculation command is used to make a image calculation
// prints the calculation result to the console
void
CalculationThreadRoutine
(
CCameraHandler
*
camera_handler
);
// -------------
// declaration of synchronisation functions needed for synchronized buffer access between the application threads
// -------------
// this function is used to check if new data is available
bool
HasDoubleBufferHandlerNewData
(
CDoubleBufferHandler
*
buffer_handler
);
// this function is used within the thread functions to receive a new buffer
BGAPI2
::
Buffer
*
PullBufferFromDoubleBufferHandler
(
CDoubleBufferHandler
*
buffer_handler
);
// this function is used within the thread functions to return a buffer
void
FreeBufferToDoubleBufferHandler
(
CDoubleBufferHandler
*
buffer_handler
,
BGAPI2
::
Buffer
*
buffer
);
// structure with the buffer object and a reference counter
// the reference counter is incremented with every call to PullBufferFromBufferModule
// and decremented with every call to FreeBufferToBufferModule
// if the reference counter reaches 0 the buffer will return to BGAPI
// the new data flag is available for all application threads
// this flags makes sure that one application thread of one camera process a camera buffer only once
struct
CameraBuffer
{
CameraBuffer
()
{
buffer_
=
nullptr
;
ref_counter_
=
0
;
}
std
::
mutex
lock_
;
BGAPI2
::
Buffer
*
buffer_
;
std
::
atomic
<
int
>
ref_counter_
;
std
::
map
<
std
::
thread
::
id
,
std
::
atomic
<
bool
>>
new_data
;
};
// this map manages all reference counter and buffer objects for each camera
std
::
map
<
CDoubleBufferHandler
*
,
CameraBuffer
>
current_buffer
;
// result of calculation thread stored in a simple map of string
std
::
map
<
CDoubleBufferHandler
*
,
std
::
string
>
calculation_result
;
// mutex to synchronize the access to the calculation result
std
::
mutex
calculation_result_lock
;
// ---------------
// helper function, used to reduce the length of some functions
// ---------------
// initialize buffer structure, which is used for buffer and data exchange between
// the main and application threads
void
InitCurrentBufferStruct
(
CCameraHandler
*
camera_handler
,
std
::
list
<
std
::
thread
::
id
>
thread_id_list
);
// waits until all connected cameras are streaming
// prints the streaming status, camera name and serial number to console
void
WaitUntilStreamingIsActive
(
CCameraHandler
*
camera_handler
);
// function used in automatic mode to wait for all camera buffer
int
WaitOfImages
(
CCameraHandler
*
camera_handler
,
unsigned
int
number_of_images
);
// ---------------
// example application functions used by the application threads
// ---------------
// perform a camera depended the logging output used by the status thread
void
PrintLoggingInformation
(
CCameraControl
*
camera_control
);
// perform the status output used by the status thread
void
PrintCameraStatus
(
CCameraControl
*
camera_control
);
// print calculation results used by status thread
void
PrintCalculationStatus
(
CCameraControl
*
camera_control
);
// perform a mean value calculation used by the calculation thread
void
DoCalculation
(
CCameraControl
*
camera_control
);
// instantiate the camera handler
CCameraHandler
m_camera_handler
;
// instantiate the buffer handler
CDoubleBufferHandler
m_double_buffer
;
// structure with the buffer object and a reference counter
// the reference counter is incremented with every call to PullBufferFromBufferModule
// and decremented with every call to FreeBufferToBufferModule
// if the reference counter reaches 0 the buffer will return to BGAPI
// the new data flag is available for all application threads
// this map manages all reference counter and buffer objects for each camera
std
::
map
<
CDoubleBufferHandler
*
,
CameraBuffer
>
m_current_buffer
;
bool
m_finish_console_threads
;
// a flag which controls the status command
std
::
atomic
<
bool
>
m_command_status
;
int32
m_return_code
;
Counter
m_TimeCounter
;
};
}
#endif //REALPSLDRIVER_H
src/drivers/gigecam/photonics/SimulatedPhotonicsDriver.cpp
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "PhotonicsDef.h"
#include "PhotonicsDriver.h"
#include "SimulatedPhotonicsDriver.h"
#include <stdlib.h>
#include "tiffio.h"
namespace
photonics
{
/*
* Constructor
*/
SimulatedPhotonicsDriver
::
SimulatedPhotonicsDriver
(
PhotonicsDriver
*
owner
)
:
PhotonicsState
(
owner
)
{
/* Empty */
}
/*
* Destructor
*/
SimulatedPhotonicsDriver
::~
SimulatedPhotonicsDriver
()
{
/* Empty */
}
void
SimulatedPhotonicsDriver
::
init
()
{
}
/*
* clearvme/daugther/Photonics
*/
void
SimulatedPhotonicsDriver
::
clear
()
{
// Read command
owner
()
->
time
=
0
;
owner
()
->
counts
=
0
;
owner
()
->
counts2
=
0
;
owner
()
->
counts3
=
0
;
}
/*
* writeParam
*/
void
SimulatedPhotonicsDriver
::
writeParam
()
{
}
//
///*
// * regroup
// */
//void SimulatedPhotonicsDriver::regroup() {
//}
/*
* synchroniseRead
*/
void
SimulatedPhotonicsDriver
::
synchroniseRead
()
{
read
();
owner
()
->
m_SynchroniseReadTerminated
=
true
;
}
/*
* read
*/
void
SimulatedPhotonicsDriver
::
read
()
{
int32
size
=
owner
()
->
dataSize
();
int32
*
tab
=
owner
()
->
data
();
float64
sum
=
0
;
boost
::
filesystem
::
path
file
=
owner
()
->
fileSimu
();
TIFF
*
tif
=
TIFFOpen
(
file
.
string
().
c_str
(),
"r"
);
if
(
tif
)
{
int32
dircount
=
0
;
while
(
dircount
<
owner
()
->
indexSimu
())
{
if
(
TIFFReadDirectory
(
tif
)
<=
0
)
break
;
++
dircount
;
};
uint32
w
,
h
;
int32
npixels
;
tdata_t
buf
;
TIFFGetField
(
tif
,
TIFFTAG_IMAGEWIDTH
,
&
w
);
TIFFGetField
(
tif
,
TIFFTAG_IMAGELENGTH
,
&
h
);
npixels
=
w
*
h
;
if
(
npixels
==
size
)
{
tmsize_t
scanlinesize
=
TIFFScanlineSize
(
tif
);
buf
=
_TIFFmalloc
(
scanlinesize
);
if
(
buf
!=
NULL
)
{
uint16
*
data
;
for
(
uint32
row
=
0
;
row
<
h
;
row
++
)
{
TIFFReadScanline
(
tif
,
buf
,
row
,
0
);
data
=
(
uint16
*
)
buf
;
for
(
uint32
i
=
0
;
i
<
w
;
++
i
)
{
tab
[
row
+
i
*
h
]
=
data
[
i
];
sum
=
sum
+
data
[
i
];
}
}
owner
()
->
sum
=
sum
;
owner
()
->
data
.
sendEvent
();
_TIFFfree
(
buf
);
}
}
TIFFClose
(
tif
);
}
// Read command
// for (int32 i = 0; i < size; i++) {
// tab[i] = i;
// sum = sum + tab[i];
// }
}
/*
* pause
*/
void
SimulatedPhotonicsDriver
::
pause
()
{
}
/*
* continue
*/
void
SimulatedPhotonicsDriver
::
resume
()
{
}
/*
* start
*/
void
SimulatedPhotonicsDriver
::
start
()
{
owner
()
->
time
=
owner
()
->
time
.
setpoint
();
}
/*
* stop
*/
void
SimulatedPhotonicsDriver
::
stop
()
{
}
/*
* readStatus
*/
void
SimulatedPhotonicsDriver
::
readStatus
()
{
owner
()
->
startActivated
=
false
;
// Status command
owner
()
->
computeGateStatus
(
photonics
::
READOUT_COMPLETE
);
owner
()
->
computeAcquisitionStatus
(
0
);
owner
()
->
computeDetectorStatus
(
0
);
if
(
owner
()
->
m_SynchroniseReadActivated
==
true
)
{
if
(
owner
()
->
m_SynchroniseReadTerminated
==
true
)
{
owner
()
->
m_SynchroniseReadActivated
=
false
;
owner
()
->
m_SynchroniseReadTerminated
=
false
;
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
else
{
owner
()
->
commandProgression
=
PROGRESSION_END_DEVICE_CONTAINER
;
}
}
/*
* readInfos
*/
void
SimulatedPhotonicsDriver
::
readInfos
()
{
}
}
src/drivers/gigecam/photonics/SimulatedPhotonicsDriver.h
0 → 100644
View file @
5dc8b217
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef SIMULATEDPHOTONICSDRIVER_H
#define SIMULATEDPHOTONICSDRIVER_H
#include "PhotonicsState.h"
namespace
photonics
{
/*!
* \class SimulatedPhotonicsDriver
* \brief Simulated implementation class for the Photonics device driver
*
* This class is a perfect implementation of Photonics device driver.
* On start command, all actual values become target's ones.
*/
class
SimulatedPhotonicsDriver
:
public
PhotonicsState
{
public:
/*!
* \brief Constructor
* \param[in] owner The device driver main class link
*/
SimulatedPhotonicsDriver
(
PhotonicsDriver
*
owner
);
/*!
* \brief Destructor
*/
virtual
~
SimulatedPhotonicsDriver
();
/*!
* \brief Init command implementation
*/
virtual
void
init
();
/*!
* \brief Clear command implementation
*/
virtual
void
clear
();
/*!
* \brief Write Param command implementation
*/
virtual
void
writeParam
();
/*!
* \brief Read command implementation
*/
virtual
void
read
();
/*!
* \brief Synchronize Read command implementation
*/
virtual
void
synchroniseRead
();
/*!
* \brief Start command implementation
*/
virtual
void
start
();
/*!
* \brief Resume command implementation
*/
virtual
void
resume
();
/*!
* \brief Pause command implementation
*/
virtual
void
pause
();
/*!
* \brief Stop command implementation
*/
virtual
void
stop
();
/*!
* \brief Read Infos command implementation
*/
virtual
void
readStatus
();
/*!
* \brief Read Infos command implementation
*/
virtual
void
readInfos
();
/*!
* \brief Regroup command implementation
*/
// virtual void regroup();
};
}
#endif //SIMULATEDPSLDRIVER_H
src/drivers/gigecam/photonics/gui/photonics.properties
0 → 100644
View file @
5dc8b217
photonics.setup
=
Setup
photonics.actual
=
Actual
photonics.divisors
=
Divisors
photonics.wanted_time
=
Time
photonics.actual_time
=
Time
photonics.mode
=
Master
photonics.modeTimeCheckedValue
=
1
photonics.modeTimeUncheckedValue
=
0
photonics.bindPrefix
=
Binning
photonics.nbFramePrefix
=
NB Frame
photonics.timeoutPrefix
=
Time Out
photonics.bPixelPrefix
=
BitPixel
# Mode combo
photonics.2048Label
=
2048*2048
photonics.2048Value
=
1
photonics.1024Label
=
1024*1024
photonics.1024Value
=
2
photonics.512Label
=
512*512
photonics.512Value
=
4
photonics.hsspeedPrefix
=
HSSpeed
# Mode combo
photonics.5mLabel
=
5MHz
photonics.5mValue
=
0
photonics.3mLabel
=
3MHz
photonics.3mValue
=
1
photonics.1mLabel
=
1MHz
photonics.1mValue
=
2
photonics.005mLabel
=
0.05MHz
photonics.005mValue
=
3
photonics.gainPrefix
=
Pre-Amp Gain
# Mode combo
photonics.x1Label
=
X1
photonics.x1Value
=
0
photonics.x2Label
=
X2
photonics.x2Value
=
1
photonics.x4Label
=
X4
photonics.x4Value
=
2
#Labels Commands
photonics.on
=
ON
photonics.off
=
OFF
photonics.cooler
=
Cooler