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
502 return space->manager->retrieveAllSystemIDs();
569 bool setPrivateData(
const char* name,
const char* data, uint64 size,
const char* mimetype = NULL) {
570 return space->manager->componentMemory->setPrivateData(currentCompID, name, data, size, mimetype);
581 return space->manager->componentMemory->getPrivateDataSize(currentCompID, name);
591 return space->manager->componentMemory->getPrivateDataCopy(currentCompID, name, size);
604 return space->manager->componentMemory->getPrivateData(currentCompID, name, data, maxSize);
615 return space->manager->componentMemory->deletePrivateData(currentCompID, name);
642 bool createParameter(
const char* name,
const char* val,
const char* defaultValue = NULL) {
643 return space->manager->componentMemory->createParameter(currentCompID, name, val, defaultValue);
656 bool createParameter(
const char* name,
const char* val, uint32 count, uint32 defaultIndex) {
657 return space->manager->componentMemory->createParameter(currentCompID, name, val, count, defaultIndex);
669 bool createParameter(
const char* name, std::vector<std::string> values,
const char* defaultValue = NULL) {
670 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
683 bool createParameter(
const char* name, int64* val, uint32 count, uint32 defaultIndex) {
684 return space->manager->componentMemory->createParameter(currentCompID, name, val, count, defaultIndex);
696 bool createParameter(
const char* name, std::vector<std::string> values, int64 defaultValue) {
697 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
709 bool createParameter(
const char* name, std::vector<int64> values, int64 defaultValue = 0) {
710 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
723 bool createParameter(
const char* name, float64* val, uint32 count, uint32 defaultIndex) {
724 return space->manager->componentMemory->createParameter(currentCompID, name, val, count, defaultIndex);
736 bool createParameter(
const char* name, std::vector<std::string> values, float64 defaultValue) {
737 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
749 bool createParameter(
const char* name, std::vector<float64> values, float64 defaultValue = 0) {
750 return space->manager->componentMemory->createParameter(currentCompID, name, values, defaultValue);
764 bool createParameter(
const char* name, int64 val, int64 min = 0, int64 max = 0, int64 interval = 0) {
765 return space->manager->componentMemory->createParameter(currentCompID, name, val, min, max, interval);
779 bool createParameter(
const char* name, float64 val, float64 min = 0, float64 max = 0, float64 interval = 0) {
780 return space->manager->componentMemory->createParameter(currentCompID, name, val, min, max, interval);
791 return space->manager->componentMemory->hasParameter(currentCompID, name);
802 return space->manager->componentMemory->deleteParameter(currentCompID, name);
827 return space->manager->componentMemory->getParameterDataType(currentCompID, name);
838 return space->manager->componentMemory->getParameterValueSize(currentCompID, name);
851 return space->manager->componentMemory->getParameter(currentCompID, name, val, maxSize);
862 return space->manager->componentMemory->getParameterString(currentCompID, name);
875 return space->manager->componentMemory->getParameterAsBool(currentCompID, name);
886 return space->manager->componentMemory->getParameterInt(currentCompID, name);
897 return space->manager->componentMemory->getParameterFloat(currentCompID, name);
909 return space->manager->componentMemory->getParameter(currentCompID, name, val);
921 return space->manager->componentMemory->getParameter(currentCompID, name, val);
933 return space->manager->componentMemory->setParameter(currentCompID, name, val);
945 return space->manager->componentMemory->setParameter(currentCompID, name, val);
957 return space->manager->componentMemory->setParameter(currentCompID, name, val);
968 return space->manager->componentMemory->resetParameter(currentCompID, name);
981 return space->manager->componentMemory->tweakParameter(currentCompID, name, tweak);
1022 uint8
retrieve(std::list<DataMessage*> &result,
const char* name, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1037 uint8
retrieveTimeParam(std::list<DataMessage*> &result,
const char* name, uint64 startTime, uint64 endTime = 0, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1052 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);
1067 uint8
retrieveIntegerParam(std::list<DataMessage*> &result,
const char* name, int64 startInteger, int64 endInteger =
INT64_NOVALUE, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1082 uint8
retrieveFloatParam(std::list<DataMessage*> &result,
const char* name, float64 startFloat, float64 endFloat =
FLOAT64_NOVALUE, uint32 maxcount = 0, uint32 maxage = 0, uint32 timeout = 5000);
1124 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);
1206 uint8
queryRemoteCatalog(
DataMessage** resultMsg, uint32& chosenAddress,
const char* componentName, uint32* ipAddresses, uint32 numAddresses, uint16 port,
DataMessage* msg, uint32 timeout = 5000);
1237 bool queryReply(uint32
id, uint8 status,
char* data, uint32 size, uint32 count);
1274 bool logPrint(
int level,
const char *formatstring, ... );
1279 uint64 startedRunning;
1280 bool shouldContinueRunning;
1281 uint32 currentCrankID;
1282 uint32 currentCompID;
1283 uint32 msgReceivedCount;
1284 uint32 msgInputCount;
1285 uint32 msgSentCount;
1286 uint32 msgPostedCount;
1287 uint64 lastCPUTicks;
1288 uint64 lastWallTime;
1289 uint32 chainCPUTicks;
1290 uint32 chainWallTime;
1293 std::queue<TriggerAndMessage> inputQueue;
1299 std::map<std::string, DataMessage*> currentGroupMap;
1309 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.