16 #ifndef TRANSREC_BASE_DRIVER_H 17 #define TRANSREC_BASE_DRIVER_H 23 #include <epicsEvent.h> 24 #include <epicsMutex.h> 25 #include <epicsTime.h> 26 #include <epicsMemory.h> 28 #include <asynPortDriver.h> 36 #include "TRNonCopyable.h" 37 #include "TRTimeArrayDriver.h" 58 template <
typename,
typename>
94 template <
typename ValueType,
typename EffectiveValueType>
96 char const *base_name, EffectiveValueType invalid_value = EffectiveValueType())
98 param.init(
this, base_name, invalid_value,
false);
116 template <
typename ValueType,
typename EffectiveValueType>
118 char const *base_name, EffectiveValueType invalid_value = EffectiveValueType())
120 param.init(
this, base_name, invalid_value,
true);
145 return *m_channels_driver;
254 return m_param_requested_sample_rate.
getSnapshot();
269 return m_param_achievable_sample_rate.
getSnapshot();
545 virtual bool checkOverflow (
bool *had_overflow,
int *num_buffer_bursts);
666 virtual asynStatus
writeInt32 (asynUser *pasynUser, epicsInt32 value);
677 virtual asynStatus
writeFloat64 (asynUser *pasynUser, epicsFloat64 value);
685 EFFECTIVE_SAMPLE_RATE,
700 ArmStatePrePostTrigger,
710 bool m_supports_pre_samples;
714 bool m_update_arrays;
717 bool m_init_completed;
720 bool m_allowing_data;
723 int m_max_ad_buffers;
724 size_t m_max_ad_memory;
727 int m_num_config_params;
730 int m_asyn_params[NUM_BASE_ASYN_PARAMS];
733 std::vector<TRConfigParamBase *> m_config_params;
736 std::vector<int> m_protected_params;
748 static int const NumBaseConfigParams = 5;
751 ArmState m_arm_state;
757 ArmState m_requested_arm_state;
760 bool m_disarm_requested;
765 ArmState m_requested_rearm_state;
772 double m_rate_for_display;
776 epicsEvent m_start_arming_event;
782 epicsEvent m_disarm_requested_event;
785 epics_auto_ptr<TRChannelsDriver> m_channels_driver;
788 TRTimeArrayDriver m_time_array_driver;
792 void addProtectedParam (
int param);
795 bool checkProtectedParamWrite (
int param);
798 asynStatus handleArmRequest (
int armRequest);
801 void startArming (ArmState requested_arm_state);
804 void requestDisarming (ArmState requested_rearm_state);
807 void waitUntilDisarming ();
810 static void readThreadTrampoline (
void *obj);
814 void readThreadIteration ();
817 void setEffectiveParams ();
820 void clearEffectiveParams ();
823 void processConfigParams (
void (TRConfigParamBase::*func) ());
826 void setArmState (ArmState armState);
829 bool checkDisarmRequestedUnlocked ();
832 bool checkBasicSettings ();
835 bool checkArmInfo (
TRArmInfo const &arm_info);
838 void setupTimeArray (
TRArmInfo const &arm_info);
Defines the TRChannelDataSubmit class, used for submitting burst data to the framework.
void setAchievableSampleRate(double value)
Sets the achievable sample rate corresponding to the requested sample rate.
double getRequestedSampleRateSnapshot()
Returns the snapshot value of the requested sample rate.
Definition: TRBaseDriver.h:252
virtual void requestedSampleRateChanged()
Reports that the requested sample rate has changed.
void maybeSleepForTesting()
Possibly sleep for testing if enabled.
Class for submitting burst data.
Definition: TRChannelDataSubmit.h:38
double getRequestedSampleRate()
Returns the requested sample rate.
Defines the TRChannelsDriver class, used for submitting data into AreaDetector.
Information provided by the driver to the framework at the start of arming.
Definition: TRArmInfo.h:31
void initConfigParam(TRConfigParam< ValueType, EffectiveValueType > ¶m, char const *base_name, EffectiveValueType invalid_value=EffectiveValueType())
Initialize a configuration parameter.
Definition: TRBaseDriver.h:95
void initInternalParam(TRConfigParam< ValueType, EffectiveValueType > ¶m, char const *base_name, EffectiveValueType invalid_value=EffectiveValueType())
Initialize an internal configration parameter.
Definition: TRBaseDriver.h:117
TRChannelsDriver & getChannelsDriver()
Return a reference to the channels driver.
Definition: TRBaseDriver.h:143
int getNumPostSamplesSnapshot()
Returns the snapshot value of the number of post-trigger samples per event.
Definition: TRBaseDriver.h:220
int getNumBurstsSnapshot()
Returns the snapshot value of the number of bursts to capture.
Definition: TRBaseDriver.h:203
void completeInit()
Complete initialization of the class.
void publishBurstMetaInfo(TRBurstMetaInfo const &info)
Publish meta-information about a burst.
Central class of the Transient Recorder framework for transient recorders (digitizers).
Definition: TRBaseDriver.h:55
virtual bool startAcquisition(bool overflow)=0
Configure the hardware to start acquisition.
An asynNDArrayDriver-based class though which burst data is submitted into the AreaDetector framework...
Definition: TRChannelsDriver.h:114
void requestDisarmingFromDriver()
Request disarming of acquisition.
ValueType getSnapshot()
Return the current snapshot value of the parameter.
Definition: TRConfigParam.h:107
TRBaseDriver(TRBaseConfig const &cfg)
Constructor for TRBaseDriver, to be used from constructors of derived classes.
Defines the TRBaseConfig class, used for configuring TRBaseDriver.
Defines the TRConfigParam class, representing an acquisition configuration parameter.
virtual asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value)
Overridden asyn parameter write handler.
virtual void stopAcquisition()=0
Configure the hardware to stop acquisition.
virtual bool checkOverflow(bool *had_overflow, int *num_buffer_bursts)
Check if there has been a buffer overlow.
virtual bool waitForPreconditions()
Wait for preconditions for arming to be satisifed.
Transient Recorder configuration parameter.
Definition: TRConfigParam.h:65
virtual void interruptReading()
Interrupt reading of data.
void setDigitizerName(char const *name)
Set the name of the digitizer, which will appear as the value of the "name" PV.
bool isArmed()
Check if acquisition is currently armed.
virtual TRChannelsDriver * createChannelsDriver()
Create the channels driver.
Construction parameters for TRBaseDriver.
Definition: TRBaseConfig.h:29
int getNumPrePostSamplesSnapshot()
Returns the snapshot value for the total number of samples per event (counting pre-trigger and post-t...
Definition: TRBaseDriver.h:237
virtual void onDisarmed()
Called when isArmed() changes from true to false.
double getAchievableSampleRateSnapshot()
Returns the snapshot value of the achievable sample rate.
Definition: TRBaseDriver.h:267
Defines the TRArmInfo class, used for passing information to the framework during arming...
virtual bool processBurstData()
Process the read that has just been read by readBurst.
virtual bool checkSettings(TRArmInfo &arm_info)=0
Check preconditions for arming and report the sample freq rate for display.
virtual asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value)
Overridden asyn parameter write handler.
virtual bool readBurst()
This is called in a loop to wait for and read a burst of data.