27#if !defined(_PSYSPACE_H_)
118 std::map<uint32, TimeQueueSchedule*> schedules;
183 PsySpace(
const char* name = NULL,
bool isAdHoc =
true, uint16 procID = 0,
bool isLocal =
false);
196 bool connect(uint16 systemID,
bool isMaster =
false,
const char* cmdline = NULL);
210 bool start(uint16 threadCount = 5);
342 std::map<std::string, CrankFunction> internalCranks;
344 bool threadPoolDispatch();
345 bool runContinuousComponent();
346 bool startContinuousComponent(uint32 compID);
347 bool setThreadPoolSize(uint16 threadCount);
348 CrankFunction loadCrankFromLibrary(
const char* crankName,
const char* libraryFilename);
350 bool pullRemoteComponentData(uint32 compID, uint16 fromNodeID);
358 bool finishedShuttingDown;
359 uint64 currentInstID;
362 uint64 masterCreatedTime;
364 uint32 waitCounters[3];
365 uint32 procCounters[3];
367 uint32 threadPoolWaitLowerThreshold;
368 uint32 threadPoolWaitUpperThreshold;
369 uint32 threadPoolWaitIncrement;
370 uint64 lastThreadPoolCheck;
371 uint64 threadPoolCheckInterval;
378 std::map<uint16, CrankFunction> cranks;
379 std::map<uint32, uint16> compCrankIDs;
380 std::map<std::string, utils::Library*> libraries;
381 std::map<uint32, PsyAPI*> psyAPIs;
382 std::map<PsyType, SignalStruct*> signalList;
385 std::map<uint32, uint8> threadPool;
386 std::map<uint32, uint32> continuousComponentThreads;
The binary DataMessage container — the central data-exchange object of Psyclone/CMSDK.
Central shared-memory manager for a Psyclone node: master segment, per-subsystem shared maps and the ...
PsyAPI — the component-facing API handle of the CMSDK.
Built-in internal cranks and message-script playback structures.
CMSDK time: µs-resolution 64-bit timestamps and the Time Mapping Constant (TMC).
Subscription, trigger, retrieval, query, post and signal specifications — the declarative wiring of a...
#define THREAD_FUNCTION_CALL
The central Psyclone data container: a self-contained binary message with typed, named user entries.
Top-level facade of the shared-memory subsystem for one process.
The API handle a component (crank) uses to talk to the Psyclone system.
bool postMessage(DataMessage *msg)
Post a raw message into the system for distribution to subscribers.
bool reset()
Reset the space's runtime state (counters, queues) without disconnecting.
bool connect(uint16 systemID, bool isMaster=false, const char *cmdline=NULL)
Join a Psyclone system (attach to the node's shared memory).
bool registerInternalCrank(const char *name, CrankFunction func)
Register a built-in ("internal") crank by function name, resolved when a component's <crank function=...
bool shutdown()
Request an orderly shutdown of the space and all its components.
friend THREAD_RET THREAD_FUNCTION_CALL PsySpaceRun(THREAD_ARG arg)
Thread entry for the space's main service thread.
bool start(uint16 threadCount=5)
Start processing: spin up the thread pool and begin dispatching triggers.
uint8 query(DataMessage *msg, DataMessage **result, uint32 timeout)
Send a query message and wait for its reply.
uint32 getComponentID(const char *name)
Look up the numeric component id for a component name.
DataMessage * waitForSignal(const PsyType &type, uint32 timeout, uint64 lastReceivedTime=0)
Block until a signal of the given type arrives (or has already arrived).
friend THREAD_RET THREAD_FUNCTION_CALL PsySpacePoolRun(THREAD_ARG arg)
Thread entry for pool worker threads.
friend THREAD_RET THREAD_FUNCTION_CALL PsySpaceContinuousRun(THREAD_ARG arg)
Thread entry for continuously running components.
bool isConnected(uint32 timeoutMS=5000)
Wait until the space is fully connected to the system.
MemoryManager * manager
The process-local memory manager: entry point to the node's shared-memory fabric. Owned by the space.
bool registerCrankCallback(const char *name, CrankFunction func)
Register a C/C++ entry function for a crank, to be invoked by the thread pool when the component trig...
bool addPsyProbeCustomView(uint32 compID, const char *name, const char *templateURL)
Add a custom PsyProbe view tab for a component (space-level variant of PsyAPI::addPsyProbeCustomView(...
PsyAPI * getCrankAPI(const char *name)
Get (or create) the PsyAPI handle for a crank hosted in this space.
bool queryReply(uint32 id, uint8 status, DataMessage *result)
Reply to a previously received query.
bool emitSignal(const PsyType &type, DataMessage *msg)
Emit a system-wide signal of the given type.
bool logEntry(LogEntry *entry)
LogReceiver interface: accept a log entry produced within this space.
PsySpace(const char *name=NULL, bool isAdHoc=true, uint16 procID=0, bool isLocal=false)
Create a space (does not yet join a system; call connect()).
Runnable()
Initialise flags: not running, allowed to continue.
Time-binned activation queue used by a PsySpace to drive time-triggered modules.
DataMessage * waitForNextEvent(uint32 ms)
Block until the next scheduled event is due, or the timeout expires.
bool removeSchedule(uint32 id)
Remove (and delete) a schedule by id.
bool addSchedule(TimeQueueSchedule *schedule)
Add a schedule to the queue.
~TimeQueue()
Destroy the queue and delete all remaining schedules (owned by the queue).
TimeQueue()
Create an empty time queue with its own timer.
One recurring (or time-bounded) activation schedule managed by a TimeQueue.
uint32 msgTag
Tag attached to the generated message.
uint64 start
First-activation time (µs), or 0 for immediate.
PsyType msgType
Type of the message generated on each activation.
uint64 nextTrigger
Next activation time (PsyTime µs timestamp), maintained by the TimeQueue.
uint32 interval
Repeat interval in milliseconds.
TimeQueueSchedule(uint32 interval, uint64 start=0, uint64 end=0)
Create a schedule.
~TimeQueueSchedule()
Destructor.
uint64 end
Expiry time (µs), or 0 for no expiry.
uint32 id
Unique schedule id, used for removal via TimeQueue::removeSchedule().
Auto-reset notification event (condition variable style), optionally named for cross-process use.
Recursive mutual-exclusion lock, optionally named for cross-process use.
Counting semaphore, optionally named for cross-process use.
Multiplexing timer: schedule many periodic timers and consume their expiries from one queue.
int8(* CrankFunction)(PsyAPI *api)
Signature of a component (crank) entry function.
THREAD_RET THREAD_FUNCTION_CALL PsySpaceContinuousRun(THREAD_ARG arg)
Continuous-component thread entry: runs PsySpace::runContinuousComponent() for the space passed in ar...
THREAD_RET THREAD_FUNCTION_CALL PsySpaceRun(THREAD_ARG arg)
Main service-thread entry: runs PsySpace::run() for the space passed in arg.
THREAD_RET THREAD_FUNCTION_CALL PsySpacePoolRun(THREAD_ARG arg)
Pool worker-thread entry: runs PsySpace::threadPoolDispatch() for the space passed in arg.
Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone.
Wire/storage layout of one log record: fixed header immediately followed by the message text.
Per-signal bookkeeping for PsySpace signal distribution.
utils::Mutex mutex
Protects lastSignalMsg.
DataMessage * lastSignalMsg
Most recently emitted message for this signal type (owned by the space).
utils::Event event
Signalled whenever a new message arrives; wakes waiters.
Small recursive XML DOM parser (XMLNode) used by CMSDK for all PsySpec XML parsing.