25#if !defined(_PSYAPI_H_)
38#define CRANKAPI_FAILED 1
39#define CRANKAPI_INUSE 2
40#define CRANKAPI_RUNNING 3
41#define CRANKAPI_IDLE 4
49#define POST_OUTOFCONTEXT -3
56#define QUERY_TIMEOUT 2
57#define QUERY_NAME_UNKNOWN 3
58#define QUERY_COMPONENT_UNKNOWN 4
59#define QUERY_QUERYFAILED 5
60#define QUERY_SUCCESS 6
61#define QUERY_NOT_AVAILABLE 7
62#define QUERY_NOT_REACHABLE 8
68#define LOG_COMPONENT 8
509 return space->manager->retrieveAllSystemIDs();
576 bool setPrivateData(
const char* name,
const char* data, uint64 size,
const char* mimetype = NULL) {
577 return space->manager->componentMemory->setPrivateData(currentCompID, name, data, size, mimetype);
588 return space->manager->componentMemory->getPrivateDataSize(currentCompID, name);
598 return space->manager->componentMemory->getPrivateDataCopy(currentCompID, name, size);
611 return space->manager->componentMemory->getPrivateData(currentCompID, name, data, maxSize);
622 return space->manager->componentMemory->deletePrivateData(currentCompID, name);
649 bool createParameter(
const char* name,
const char* val,
const char* defaultValue = NULL) {
650 return space->manager->componentMemory->createParameter(currentCompID, name, val, defaultValue);
663 bool createParameter(
const char* name,
const char* val, uint32 count, uint32 defaultIndex) {
664 return space->manager->componentMemory->createParameter(currentCompID, name, val, count, defaultIndex);
676 bool createParameter(
const char* name, std::vector<std::string> values,
const char* defaultValue = NULL) {
677 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
690 bool createParameter(
const char* name, int64* val, uint32 count, uint32 defaultIndex) {
691 return space->manager->componentMemory->createParameter(currentCompID, name, val, count, defaultIndex);
703 bool createParameter(
const char* name, std::vector<std::string> values, int64 defaultValue) {
704 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
716 bool createParameter(
const char* name, std::vector<int64> values, int64 defaultValue = 0) {
717 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
730 bool createParameter(
const char* name, float64* val, uint32 count, uint32 defaultIndex) {
731 return space->manager->componentMemory->createParameter(currentCompID, name, val, count, defaultIndex);
743 bool createParameter(
const char* name, std::vector<std::string> values, float64 defaultValue) {
744 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
756 bool createParameter(
const char* name, std::vector<float64> values, float64 defaultValue = 0) {
757 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
771 bool createParameter(
const char* name, int64 val, int64 min = 0, int64 max = 0, int64 interval = 0) {
772 return space->manager->componentMemory->createParameter(currentCompID, name, val, min, max, interval);
786 bool createParameter(
const char* name, float64 val, float64 min = 0, float64 max = 0, float64 interval = 0) {
787 return space->manager->componentMemory->createParameter(currentCompID, name, val, min, max, interval);
798 return space->manager->componentMemory->hasParameter(currentCompID, name);
809 return space->manager->componentMemory->deleteParameter(currentCompID, name);
834 return space->manager->componentMemory->getParameterDataType(currentCompID, name);
845 return space->manager->componentMemory->getParameterValueSize(currentCompID, name);
858 return space->manager->componentMemory->getParameter(currentCompID, name, val, maxSize);
869 return space->manager->componentMemory->getParameterString(currentCompID, name);
882 return space->manager->componentMemory->getParameterAsBool(currentCompID, name);
893 return space->manager->componentMemory->getParameterInt(currentCompID, name);
904 return space->manager->componentMemory->getParameterFloat(currentCompID, name);
916 return space->manager->componentMemory->getParameter(currentCompID, name, val);
928 return space->manager->componentMemory->getParameter(currentCompID, name, val);
940 return space->manager->componentMemory->setParameter(currentCompID, name, val);
952 return space->manager->componentMemory->setParameter(currentCompID, name, val);
964 return space->manager->componentMemory->setParameter(currentCompID, name, val);
975 return space->manager->componentMemory->resetParameter(currentCompID, name);
988 return space->manager->componentMemory->tweakParameter(currentCompID, name, tweak);
1029 uint8
retrieve(std::list<DataMessage*> &result,
const char* name, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1044 uint8
retrieveTimeParam(std::list<DataMessage*> &result,
const char* name, uint64 startTime, uint64 endTime = 0, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1059 uint8
retrieveStringParam(std::list<DataMessage*> &result,
const char* name,
const char* startString,
const char* endString = NULL, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1074 uint8
retrieveIntegerParam(std::list<DataMessage*> &result,
const char* name, int64 startInteger, int64 endInteger =
INT64_NOVALUE, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1089 uint8
retrieveFloatParam(std::list<DataMessage*> &result,
const char* name, float64 startFloat, float64 endFloat =
FLOAT64_NOVALUE, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1131 uint8
queryCatalog(
char** result, uint32 &resultsize,
const char* name,
const char* query,
const char* operation = NULL,
const char* data = NULL, uint32 datasize = 0, uint32 timeout = 5000);
1213 uint8
queryRemoteCatalog(
DataMessage** resultMsg, uint32& chosenAddress,
const char* componentName, uint32* ipAddresses, uint32 numAddresses, uint16 port,
DataMessage* msg, uint32 timeout = 5000);
1244 bool queryReply(uint32
id, uint8 status,
char* data, uint32 size, uint32 count);
1281 bool logPrint(
int level,
const char *formatstring, ... );
1286 uint64 startedRunning;
1287 bool shouldContinueRunning;
1288 uint32 currentCrankID;
1289 uint32 currentCompID;
1290 uint32 msgReceivedCount;
1291 uint32 msgInputCount;
1292 uint32 msgSentCount;
1293 uint32 msgPostedCount;
1294 uint64 lastCPUTicks;
1295 uint64 lastWallTime;
1296 uint32 chainCPUTicks;
1297 uint32 chainWallTime;
1300 std::queue<TriggerAndMessage> inputQueue;
1306 std::map<std::string, DataMessage*> currentGroupMap;
1316 uint64 checkLastWaitForMessage();
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 ...
The PsySpace process/node context: the runtime container in which Psyclone components (cranks) live a...
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 MAXCOMMANDLINELEN
The central Psyclone data container: a self-contained binary message with typed, named user entries.
bool setAutoDelete(bool autodel)
Internal use only.
static struct PsyType CTRL_CONTEXT_CHANGE
Announces a system context change.
static struct PsyType CTRL_PROCESS_INITIALISE
Sent to a process to initialise it.
bool createParameter(const char *name, std::vector< std::string > values, float64 defaultValue)
Creates a new string parameter with list of float values (?).
static const char * fromPythonAddressOf(unsigned long long ptr)
Internal use only — debug helper returning a printable address string for a Python-held pointer.
PsyContext getCurrentTriggerContext()
Get the context of the current trigger, just retrieved using waitForNewMessage().
bool removePsyProbeCustomView(const char *name)
Remove a custom module view tab for the PsyProbe web interface.
bool deleteParameter(const char *name)
Deletes a named parameter.
PsyAPI(PsySpace *space)
Constructor from a PsySpace.
uint8 retrieveIntegerParam(std::list< DataMessage * > &result, const char *name, int64 startInteger, int64 endInteger=INT64_NOVALUE, uint32 maxcount=0, uint32 maxage=0, uint32 timeout=5000)
Used by a module to retrieve messages from a whiteboard.
bool createParameter(const char *name, const char *val, uint32 count, uint32 defaultIndex)
Creates a new string list parameter with room for count entries.
bool resetParameter(const char *name)
Reset parameter to its default (or initial) value.
bool tweakParameter(const char *name, int32 tweak)
Step up or down list or range parameter value.
bool isRunning()
Internal use only.
std::string getParameterString(const char *name)
Read and return value of parameter by name.
bool createParameter(const char *name, std::vector< std::string > values, int64 defaultValue)
Creates a new String parameter with list of integer values (?).
std::string contextToText(PsyContext context)
Get textual representation of the context.
static struct PsyType CTRL_PROCESS_SHUTDOWN
Orders a single process to shut down.
bool createParameter(const char *name, float64 *val, uint32 count, uint32 defaultIndex)
Creates a new float parameter.
uint8 retrieve(std::list< DataMessage * > &result, const char *name, uint32 maxcount=0, uint32 maxage=0, uint32 timeout=5000)
Retrieve stored messages from a whiteboard, by named <retrieve> spec entry.
int64 getParameterInt(const char *name)
Read and return value of parameter by name.
static struct PsyType CTRL_PULLCOMPONENTDATA
Requests component data from another node.
static struct PsyType CTRL_TRIGGER_GROUP
T1.6: wraps a <triggergroup> joined-set delivery (member map) to a component.
static PsyAPI * fromPython(unsigned long long ptr)
Internal use only.
bool addSubscription(const char *xml)
This function adds triggers and posts to an existing registration.
bool addPsyProbeCustomView(const char *name, const char *templateURL)
Add a custom module view tab for the PsyProbe web interface by providing a template file.
static struct PsyType CTRL_TRIGGER
Wraps a trigger delivery to a component.
~PsyAPI()
Destructor for the PsyAPI.
bool getParameter(const char *name, char *val, uint32 maxSize)
Read string parameter into existing data chunk val, maximum size maxSize.
std::string getCommandlineBasedir()
Get the base dir that Psyclone is running from.
int32 postOutputMessage(const char *postName=NULL, DataMessage *msg=NULL)
Post the crank's output according to the spec's post entries.
static struct PsyType CTRL_PROCESS_GREETING
Handshake from a newly joined process.
float64 getParameterFloat(const char *name)
Read and return value of parameter by name.
bool setPrivateData(const char *name, const char *data, uint64 size, const char *mimetype=NULL)
Store a named chunk of data centrally, in the system's shared component memory.
bool shouldContinue()
Check whether the crank should keep running, or exit its loop.
bool hasCurrentRetrieveName(const char *name)
Check to see if the retrieve name is currently active - i.e.
bool createParameter(const char *name, int64 val, int64 min=0, int64 max=0, int64 interval=0)
Creates a new integer parameter.
bool emitSignal(const char *name, DataMessage *msg=NULL)
Emit a signal by its spec name.
bool hasCurrentPostName(const char *name)
Check to see if the post name is currently active - i.e.
bool queryReply(uint32 id, uint8 status, char *data, uint32 size, uint32 count)
Used by a module to reply to an incoming query by id.
static struct PsyType CTRL_SYSTEM_SHUTTINGDOWN
Broadcast while shutdown is in progress.
bool hasParameter(const char *name)
Checks if a named parameter exists.
std::map< std::string, DataMessage * > waitForNewMessageGroup(uint32 ms, std::string &groupName)
T1.6: Wait for the next <triggergroup> joined-set delivery from the input queue.
static struct PsyType CTRL_RETRIEVESYSTEMIDS
Requests the full id/name tables.
std::string getCurrentScript()
Internal use only.
static struct PsyType CTRL_QUERY_REPLY
Carries a query reply back to the asker.
bool setCommandlineBasedir(const char *cmdlineBasedir)
Internal use only.
std::string getOtherModuleName(uint32 id)
Get the name of another module by id.
DataMessage * waitForSignal(const char *name, uint32 timeout, uint64 lastReceivedTime=0)
Wait for a signal (latest-value broadcast) by its spec name.
bool setParameter(const char *name, int64 val)
Set integer parameter value.
static struct PsyType CTRL_SYSTEM_READY
Broadcast when the system has fully started.
uint8 queryCatalog(char **result, uint32 &resultsize, const char *name, const char *query, const char *operation=NULL, const char *data=NULL, uint32 datasize=0, uint32 timeout=5000)
Send a query to another module or catalog by named <query> spec entry, receiving raw bytes back.
uint32 getInputQueueSize()
Get the size of the input queue, i.e.
static struct PsyType CTRL_INTERSYSTEM_QUERY_REPLY
Reply from a different Psyclone system.
uint64 getCurrentMessageReceiveTime()
Get the time the current trigger (or, failing that, the current message) was received by the system,...
bool getParameter(const char *name, int64 &val)
Read integer parameter value.
bool setParameter(const char *name, float64 val)
Set float parameter value.
DataMessage * retrieveAllSystemIDs()
This function retrieves all names for types, contexts and components.
bool getPrivateData(const char *name, char *data, uint64 maxSize)
Reads a private chunk from the system into existing data space, maximum size is maxSize.
uint8 retrieveStringParam(std::list< DataMessage * > &result, const char *name, const char *startString, const char *endString=NULL, uint32 maxcount=0, uint32 maxage=0, uint32 timeout=5000)
Used by a module to retrieve messages from a whiteboard.
bool getParameterAsBool(const char *name)
Read and interpret value of parameter by name as boolean True: String 'Yes', Integer and Float non-ze...
DataMessage * waitForNewMessage(uint32 ms)
Wait for the next trigger message from the component's input queue.
static struct PsyType CTRL_SYSTEM_SHUTDOWN
Orders a full system shutdown.
uint8 queryRemoteCatalog(DataMessage **resultMsg, const char *componentName, const char *ipAddress, uint16 port, DataMessage *msg, uint32 timeout=5000)
Send a query to a component in a different Psyclone system by hostname/IP.
bool logPrint(int level, const char *formatstring,...)
Write a printf-style entry to the component's log (and the console when level is below the logging th...
bool createParameter(const char *name, std::vector< float64 > values, float64 defaultValue=0)
Creates a new float parameter with list of float values (?).
uint64 getPrivateDataSize(const char *name)
This returns the size of the private data chunk previously saved by the crank.
static struct PsyType CTRL_QUERY
Carries a query to a component/catalog.
bool setParameter(const char *name, const char *val)
Set string parameter value.
std::set< std::string > getCurrentPostNames()
Get a list of post names currently active - i.e.
bool createParameter(const char *name, float64 val, float64 min=0, float64 max=0, float64 interval=0)
Creates a new float parameter with min, max and interval limits for allowed values.
bool createParameter(const char *name, std::vector< std::string > values, const char *defaultValue=NULL)
Creates a new string parameter with a list of values.
static struct PsyType CTRL_ADDSUBSCRIPTION
Adds triggers/posts to a registration at runtime.
bool createParameter(const char *name, std::vector< int64 > values, int64 defaultValue=0)
Creates a new integer parameter with list of values.
bool deletePrivateData(const char *name)
Deletes a private data chunk by name.
bool hasCurrentQueryName(const char *name)
Check to see if the query name is currently active - i.e.
std::string getCurrentTriggerName()
Get the name of the current trigger, i.e.
uint32 getParameterValueSize(const char *name)
Return the amount of memory in bytes used by the parameter.
std::string getCurrentScriptFilename()
Internal use only.
static struct PsyType CTRL_INTERSYSTEM_QUERY
Query crossing to a different Psyclone system.
std::string typeToText(PsyType type)
Get textual representation of the type.
bool createParameter(const char *name, const char *val, const char *defaultValue=NULL)
Creates a new string parameter.
uint8 getParameterDataType(const char *name)
Gets the parameter type.
char * getPrivateDataCopy(const char *name, uint64 &size)
Returns a newly allocated copy of a private data entry, with the size written into size.
bool createParameter(const char *name, int64 *val, uint32 count, uint32 defaultIndex)
Creates a new integer list parameter with room for count entries.
uint8 retrieveFloatParam(std::list< DataMessage * > &result, const char *name, float64 startFloat, float64 endFloat=FLOAT64_NOVALUE, uint32 maxcount=0, uint32 maxage=0, uint32 timeout=5000)
Used by a module to retrieve messages from a whiteboard.
std::string getModuleName()
Get the module name.
uint8 retrieveTimeParam(std::list< DataMessage * > &result, const char *name, uint64 startTime, uint64 endTime=0, uint32 maxcount=0, uint32 maxage=0, uint32 timeout=5000)
Used by a module to retrieve messages from a whiteboard.
bool hasCurrentSignalName(const char *name)
Check to see if the signal name is currently active - i.e.
static struct PsyType CTRL_CREATECUSTOMPAGE
Registers a custom PsyProbe view.
std::string getCurrentScriptLanguage()
Internal use only.
bool getParameter(const char *name, float64 &val)
Read float parameter value.
The runtime container (one OS process/node context) hosting Psyclone components.
Recursive mutual-exclusion lock, optionally named for cross-process use.
Counting semaphore, optionally named for cross-process use.
std::pair< DataMessage *, DataMessage * > TriggerAndMessage
Pairing of a trigger message and its accompanying data message, as queued for a crank's input.
Hierarchical execution-context identifier.
Hierarchical message type identifier — the key used for publish/subscribe matching in Psyclone.
Specification of a whiteboard retrieval attached to a TriggerSpec.
A complete trigger definition: what fires a component's crank and what happens then.
Small recursive XML DOM parser (XMLNode) used by CMSDK for all PsySpec XML parsing.