/******************************************************************************* * Control.h Control process * T.Barnaby, BEAM Ltd, 2007-02-07 ******************************************************************************* */ #ifndef Control_H #define Control_H 1 #include #include #include #include #include #include #include #include #include #include #include #include #include class Control; class CycleParams { public: CycleParams(BString cycleType, CycleParam& params); BString cycleType; // The Cycle type name BList params; // Parameters for channels }; /// A resource test class. this implements a simple timer operated function called every second, that can be used to check on system resources. class ControlTimer : public BThread { public: ControlTimer(Control& control); void sync(); ///< Synchronises timer void* function(); void tick(); private: Control& ocontrol; BSema otick; public: static ControlTimer* timer; static void sigFunc(int sig, siginfo_t* sigInfo, void* data); }; /// The main system control class class Control { public: Control(int dbFixed); ~Control(); BError init(int number); ///< Initialise the system void abort(); ///< Abort processing // Main functionality BError initCmd(); BError setProcessPriority(BUInt32 priority); BError configure(ConfigInfo configInfo); ///< Configure the system for use. This includes mapping the individual physical PickUp channels to logical pickup channels. BError test(BList& errors); BError getStatus(BList& statusList); BError getStatistics(BList& statsList); BError getMasterPuChannel(PuChannel& puChannel); BError addEventServer(BString name); BError delEventServer(BString name); BError setControlInfo(CycleParam params); BError setNextCycle(UInt32 cycleNumber, BString cycleType); BError getStatus(PuChannel puChannel, PuStatus& puStatus); BError getCycleInformation(UInt32 cycleNumber, CycleInformation& cycleInformation); BError getData(PuChannel puChannel, DataInfo dataInfo, Data& data); BError requestData(PuChannel puChannel, DataInfo dataInfo); BError setTestMode(PuChannel puChannel, UInt32 testOutput, UInt32 timingDisableMask); BError setTimingSignals(PuChannel puChannel, UInt32 timingSignals); BError captureDiagnostics(PuChannel puChannel, TestCaptureInfo captureInfo, BArray& data); BError setTestData(PuChannel puChannel, Int32 on, BArray data); ///< This function will set a PU channel to sample data from memory rather than the ADC's BError setPupeConfig(PuChannel puPhysChannel, PupeConfig pupeConfig); BError getPupeConfig(PuChannel puPhysChannel, PupeConfig& pupeConfig); void run(); ///< Start the system running // System utilities void timer(); void cycleStart(UInt32 cycleNumber); ///< The CYCLE_START event has occured void cycleStop(UInt32 cycleNumber); ///< The CYCLE_STOP event has occured void cycleError(UInt32 cycleNumber, BError error); ///< A Cycle error occurred BError getPuChannel(PuChannel puPhysChannel, UInt32& puChannel); BError getPuPhysChannel(UInt32 puChannel, PuChannel& puPhysChannel); int moduleNum(); ///< Returns the module controller number public: // General data int osimulate; ///< Simulation mode int osimulateTiming; ///< Simulate timing inputs BMutex odmaLock; ///< DMA lock for all PUPE's private: // Low level bits BError initPupeEngines(); BString getName(); BError mergeError(BError err); // Control data int odebugFixed; ///< Fixed debug level from command line int onum; ///< The Module controller number int oinitialised; ///< The system has been initialised int omaster; ///< The master PUPE BMutex olock; ///< Lock for data access ControlTimer otimer; int owatchdog; ///< Watchdog timer BString oserverName; ///< The BOAP Servers host name BoapServer oboapServer; ///< The overal Boap server class PuControlServer opuControlServer; ///< The PuControl API interface PuProcessServer opuProcessServer; ///< The PuProcess API interface PupeGeog opupeGeog; ///< The physical location of Pupe boards ConfigInfo oconfigInfo; ///< The configuration of PickUp channels BMutex oconfigInfoLock; BList opupeEngines; ///< The list of PUPE engines BRWLock opupeEnginesLock; BMutex opupeLock; ///< Locks access to the pupe engines TmsEventServerList oeventServers; ///< The list of event servers BList ocycleParms; ///< The table of cycle parameters BMutex ocycleParmsLock; UInt32 ocycleNumber; ///< The current cycle number BString ocycleType; ///< The current cycle type UInt32 ocycleNumberNext; ///< The next cycle number BString ocycleTypeNext; ///< The next cycle type UInt32 oprocessingCycle; ///< We are processing a cycle UInt32 ocycleTick; ///< Cycle tick for software simulatted timing signals // Statistics double ostartTime; ///< The start time UInt64 ocycleProcessed; ///< The number of cycles processed }; #endif