12struct PsyType
PsyAPI::CTRL_SYSTEM_READY = { { 1,10200,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
13struct PsyType
PsyAPI::CTRL_PROCESS_INITIALISE = { { 1,10201,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
14struct PsyType
PsyAPI::CTRL_PROCESS_GREETING = { { 1,10202,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
15struct PsyType
PsyAPI::CTRL_PROCESS_SHUTDOWN = { { 1,10203,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
16struct PsyType
PsyAPI::CTRL_CONTEXT_CHANGE = { { 1,10297,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
17struct PsyType
PsyAPI::CTRL_SYSTEM_SHUTDOWN = { { 1,10298,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
18struct PsyType
PsyAPI::CTRL_SYSTEM_SHUTTINGDOWN = { { 1,10299,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
19struct PsyType
PsyAPI::CTRL_TRIGGER = { { 1,10300,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
20struct PsyType
PsyAPI::CTRL_TRIGGER_GROUP = { { 1,10307,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
21struct PsyType
PsyAPI::CTRL_QUERY = { { 1,10301,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
22struct PsyType
PsyAPI::CTRL_QUERY_REPLY = { { 1,10302,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
23struct PsyType
PsyAPI::CTRL_PULLCOMPONENTDATA = { { 1,10303,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
24struct PsyType
PsyAPI::CTRL_CREATECUSTOMPAGE = { { 1,10304,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
25struct PsyType
PsyAPI::CTRL_ADDSUBSCRIPTION = { { 1,10305,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
26struct PsyType
PsyAPI::CTRL_RETRIEVESYSTEMIDS = { { 1,10306,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
27struct PsyType
PsyAPI::CTRL_INTERSYSTEM_QUERY = { { 1,10998,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
28struct PsyType
PsyAPI::CTRL_INTERSYSTEM_QUERY_REPLY = { { 1,10999,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } };
34 shouldContinueRunning =
false;
46 commandlineBasedir[0] = 0;
47 currentTriggerName[0] = 0;
48 currentTriggerMsg = NULL;
50 currentSignalMsg = NULL;
51 currentTriggerSpec = NULL;
56 shouldContinueRunning =
false;
58 delete(currentTriggerMsg);
59 currentTriggerMsg = NULL;
62 delete(currentSignalMsg);
63 currentSignalMsg = NULL;
65 std::map<std::string, DataMessage*>::iterator git, gitEnd;
66 for (git = currentGroupMap.begin(), gitEnd = currentGroupMap.end(); git != gitEnd; git++)
67 if (git->second)
delete(git->second);
68 currentGroupMap.clear();
77 return (
const char*)ptr;
81 if (!apiMutex.enter(1000))
94 if (!apiMutex.enter(1000))
96 if (shouldContinueRunning) {
107 return commandlineBasedir;
117 return space->manager->componentMemory->getComponentName(currentCompID, name, maxSize);
121 return space->manager->componentMemory->getComponentNameString(currentCompID);
125 return space->manager->componentMemory->getComponentNameString(
id);
129 return space->manager->dataMapsMemory->getCrankLanguage(currentCrankID, language, maxSize);
133 char* language =
new char[1024];
134 if (!space->manager->dataMapsMemory->getCrankLanguage(currentCrankID, language, 1024)) {
138 std::string lang = language;
144 return space->manager->dataMapsMemory->getCrankScript(currentCrankID, script, 1024);
149 if (!space->manager->dataMapsMemory->getCrankScript(currentCrankID, script,
MAXSCRIPTLEN)) {
153 std::string scr = script;
159 return space->manager->dataMapsMemory->getCrankLibraryFilename(currentCrankID, file, 1024);
163 char* file =
new char[1024];
164 if (!space->manager->dataMapsMemory->getCrankLibraryFilename(currentCrankID, file, 1024)) {
168 std::string filename = file;
174 if (!apiMutex.enter(1000, __FUNCTION__))
176 if (currentTriggerSpec) {
177 if (currentTriggerSpec->getRetrieveSpec(name)) {
187 if (!apiMutex.enter(1000, __FUNCTION__))
189 if (currentTriggerSpec) {
190 if (currentTriggerSpec->getSignalSpec(name)) {
201 if (!apiMutex.enter(1000, __FUNCTION__))
203 if (currentTriggerSpec) {
204 if (currentTriggerSpec->getQuerySpec(name)) {
214 if (!apiMutex.enter(1000, __FUNCTION__))
216 if (currentTriggerSpec) {
217 if (currentTriggerSpec->getPostSpec(name)) {
227 std::set<std::string> postNames;
228 if (!apiMutex.enter(1000, __FUNCTION__))
230 if (currentTriggerSpec) {
231 std::list<PostSpec*>* postSpecs = currentTriggerSpec->getPostSpecs(NULL);
232 if (postSpecs && postSpecs->size()) {
233 std::list<PostSpec*>::iterator it = postSpecs->begin(), itEnd = postSpecs->end();
234 while (it != itEnd) {
235 postNames.insert((*it)->name);
246 if (!apiMutex.enter(1000, __FUNCTION__))
248 uint32 qSize = (uint32)inputQueue.size();
255 return space->manager->typeToText(type);
259 return space->manager->contextToText(context);
262bool PsyAPI::begin() {
263 if (!apiMutex.
enter(1000))
266 shouldContinueRunning =
true;
269 lastWallTime = startedRunning;
282bool PsyAPI::finish() {
284 if (!apiMutex.
enter(1000))
291 uint64 currentCPUTicks;
294 currentCPUTicks - lastCPUTicks,
301 lastCPUTicks = currentCPUTicks;
308 apiMutex.enter(1000);
309 shouldContinueRunning =
false;
318 return space->addPsyProbeCustomView(currentCompID, name, templateURL);
323uint64 PsyAPI::checkLastWaitForMessage() {
324 if (!apiMutex.
enter(1000))
328 if (startedRunning && currentCrankID) {
329 if (inputQueue.size() && (
GetTimeAgeMS(lastWallTime) > 5000)) {
341 if (!apiMutex.enter(1000))
345 if (startedRunning && currentCrankID) {
346 if (crankID == currentCrankID) {
349 inputQueueSemaphore.signal();
360 currentCrankID = crankID;
361 currentCompID = compID;
376 inputQueueSemaphore.signal();
383 const char* triggerName;
388 return currentTriggerName;
392 if (this->currentTriggerSpec)
393 return this->currentTriggerSpec->context;
403 uint64 currentCPUTicks;
406 if (!apiMutex.enter(1000, __FUNCTION__))
409 if (!inputQueue.size()) {
412 if (!inputQueueSemaphore.wait(ms) || !inputQueue.size()) {
415 currentCPUTicks - lastCPUTicks,
421 lastCPUTicks = currentCPUTicks;
429 if (!apiMutex.enter(1000, __FUNCTION__))
452 tm = inputQueue.front();
461 delete(currentTriggerMsg);
462 currentTriggerMsg = msgFirst;
465 triggerName = currentTriggerName;
488 if (msgFirst && msgSecond) {
505 currentCPUTicks - lastCPUTicks,
511 lastCPUTicks = currentCPUTicks;
525 std::map<std::string, DataMessage*>::iterator git, gitEnd;
526 for (git = currentGroupMap.begin(), gitEnd = currentGroupMap.end(); git != gitEnd; git++)
527 if (git->second)
delete(git->second);
528 currentGroupMap.clear();
531 const char* triggerName = NULL;
537 if (triggerName && currentTriggerMsg && currentTriggerMsg->getType() ==
CTRL_TRIGGER_GROUP) {
538 currentGroupMap = currentTriggerMsg->getAttachedMessageMap(
"Members");
539 groupName = triggerName;
541 else if (triggerName && primary) {
544 if (triggerName) groupName = triggerName;
548 return currentGroupMap;
552 autoDelete = autodel;
559 if (currentTriggerMsg && (t = currentTriggerMsg->getRecvTime()) )
562 return currentMsg->getRecvTime();
583 uint64 currentCPUTicks;
586 if (!apiMutex.enter(1000))
590 msg->
addTimeUsage((uint32)(currentCPUTicks - lastCPUTicks), (uint32)
GetTimeAge(lastWallTime), chainCPUTicks, chainWallTime, chainCount + 1);
592 uint32 currentTag = 0;
594 currentTag = currentMsg->getTag();
599 if (!currentTriggerSpec) {
602 logPrint(1,
"Posting none - out of context");
605 if (currentTag && !msg->
getTag())
608 if (space->postMessage(msg)) {
613 logPrint(0,
"Failed to post direct message to component %u", to);
619 logPrint(1,
"Posting none - out of context");
626 std::list<PostSpec*>* postSpecs = currentTriggerSpec->getPostSpecs(postName);
627 if (!postSpecs || !postSpecs->size()) {
631 postSpecs = currentTriggerSpec->getPostSpecs(msg->
getType());
632 if (!postSpecs || !postSpecs->size()) {
635 logPrint(2,
"Posting nothing - no post specs match for post name '%s'", postName);
646 msg->
addTimeUsage((uint32)(currentCPUTicks - lastCPUTicks), (uint32)
GetTimeAge(lastWallTime), chainCPUTicks, chainWallTime, chainCount + 1);
651 if (currentTag && !msg->
getTag())
656 std::list<PostSpec*>::iterator it = postSpecs->begin(), itEnd = postSpecs->end();
657 while (it != itEnd) {
658 if (postSpec = *it) {
672 if (space->postMessage(msg)) {
677 logPrint(0,
"Failed to deliver posted msg to %u", postSpec->
to);
687 msgSentCount += success;
690 logPrint(0,
"No msgs were delivered at postOutputMessage", success);
696 currentCPUTicks - lastCPUTicks,
703 lastCPUTicks = currentCPUTicks;
707 if (!success && failed)
716 if (!apiMutex.enter(1000))
719 if (!currentTriggerSpec) {
725 SignalSpec* signalSpec = currentTriggerSpec->getSignalSpec(name);
735 if (space->emitSignal(signalSpec->
type, msg)) {
748 apiMutex.enter(3000, __FUNCTION__);
750 if (!currentTriggerSpec) {
755 SignalSpec* signalSpec = currentTriggerSpec->getSignalSpec(name);
762 DataMessage* msg = space->waitForSignal(signalSpec->
type, timeout, lastReceivedTime);
765 apiMutex.enter(3000, __FUNCTION__);
766 if (currentSignalMsg)
767 delete(currentSignalMsg);
768 currentSignalMsg = msg;
778uint8
PsyAPI::retrieve(std::list<DataMessage*> &result,
const char* name, uint32 maxcount, uint32 maxage, uint32 timeout) {
779 if (!apiMutex.enter(1000))
782 if (!currentTriggerSpec) {
787 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
799 specCopy->
maxage = maxage;
802 uint8 res =
retrieve(result, specCopy, timeout);
806uint8
PsyAPI::retrieveTimeParam(std::list<DataMessage*> &result,
const char* name, uint64 startTime, uint64 endTime, uint32 maxcount, uint32 maxage, uint32 timeout) {
807 std::list<DataMessage*> list;
810 if (!apiMutex.enter(1000))
813 if (!currentTriggerSpec) {
818 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
833 specCopy->
maxage = maxage;
836 uint8 res =
retrieve(result, specCopy, timeout);
840uint8
PsyAPI::retrieveStringParam(std::list<DataMessage*> &result,
const char* name,
const char* startString,
const char* endString, uint32 maxcount, uint32 maxage, uint32 timeout) {
841 std::list<DataMessage*> list;
842 if (!startString || !strlen(startString))
845 if (!apiMutex.enter(1000))
848 if (!currentTriggerSpec) {
853 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
868 specCopy->
maxage = maxage;
871 uint8 res =
retrieve(result, specCopy, timeout);
875uint8
PsyAPI::retrieveIntegerParam(std::list<DataMessage*> &result,
const char* name, int64 startInteger, int64 endInteger, uint32 maxcount, uint32 maxage, uint32 timeout) {
876 std::list<DataMessage*> list;
880 if (!apiMutex.enter(1000))
883 if (!currentTriggerSpec) {
888 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
899 specCopy->
endInt = endInteger;
903 specCopy->
maxage = maxage;
906 uint8 res =
retrieve(result, specCopy, timeout);
910uint8
PsyAPI::retrieveFloatParam(std::list<DataMessage*> &result,
const char* name, float64 startFloat, float64 endFloat, uint32 maxcount, uint32 maxage, uint32 timeout) {
911 std::list<DataMessage*> list;
914 if (!apiMutex.enter(1000))
917 if (!currentTriggerSpec) {
922 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
937 specCopy->
maxage = maxage;
940 uint8 res =
retrieve(result, specCopy, timeout);
947 spec->
origin = currentCompID;
953 uint8 status = space->query(msg, &resultMsg, timeout);
958 logPrint(0,
"Query failed and did not return a message...");
965 const char* data = resultMsg->
getData(
"ReplyData", size);
966 if (!data || !resultMsg->
getInt(
"ReplyCount", count)) {
968 logPrint(0,
"Query did not return any ReplyData...");
970 logPrint(0,
"Query did not return any ReplyCount...");
977 const char* src = data;
978 for (uint32 n=0; n<(uint32)count; n++) {
982 result.push_back(subMsg);
992 if (!apiMutex.enter(1000))
998 uint8 status = space->query(msg, &resultMsg, 5000);
1013 if (!apiMutex.enter(1000))
1016 if (!currentTriggerSpec) {
1017 logPrint(1,
"Query '%s' cannot execute before a trigger message has been processed", name);
1022 QuerySpec* querySpec = currentTriggerSpec->getQuerySpec(name);
1024 logPrint(1,
"Query '%s' not found in PsySpec", name);
1031 if (strlen(querySpec->
type))
1033 if (strlen(querySpec->
ext))
1035 if (strlen(querySpec->
subdir))
1037 if (strlen(querySpec->
key))
1039 if (strlen(querySpec->
value))
1046 if (!querySpec->
ipHost) {
1053 querySpec->
ipPort = 10000;
1069 uint8 status = space->query(msg, resultMsg, timeout);
1083 if (chosenAddress > numAddresses)
1087 if (chosenAddress) {
1089 result =
queryRemoteCatalog(resultMsg, componentName, ipAddresses[chosenAddress-1], port, msg, timeout);
1096 for (uint32 n = 0; n < numAddresses; n++) {
1097 result =
queryRemoteCatalog(resultMsg, componentName, ipAddresses[n], port, msg, timeout);
1099 chosenAddress = n + 1;
1118 msg->
setString(
"INTERSYSTEM_SOURCENAME", componentName);
1119 msg->
setInt(
"INTERSYSTEM_ADDRESS", ipAddress);
1120 msg->
setInt(
"INTERSYSTEM_PORT", port);
1122 uint8 status = space->query(msg, resultMsg, timeout);
1131uint8
PsyAPI::queryCatalog(
char** result, uint32 &resultsize,
const char* name,
const char* query,
const char* operation,
const char* data, uint32 datasize, uint32 timeout) {
1133 if (!apiMutex.enter(1000,
"Replying to query"))
1136 if (!currentTriggerSpec) {
1141 QuerySpec* querySpec = currentTriggerSpec->getQuerySpec(name);
1151 if (query && strlen(query))
1153 if (data && datasize)
1154 msg->
setData(
"Data", data, datasize);
1155 if (operation && strlen(operation))
1160 if (strlen(querySpec->
type))
1162 if (strlen(querySpec->
ext))
1164 if (strlen(querySpec->
subdir))
1166 if (strlen(querySpec->
key))
1168 if (strlen(querySpec->
value))
1175 if (!querySpec->
ipHost) {
1182 querySpec->
ipPort = 10000;
1199 uint8 status = space->query(msg, &resultMsg, timeout);
1203 *result = resultMsg->
getDataCopy(
"ReplyData", resultsize);
1214 msg->
setData(
"ReplyData", data, size);
1215 msg->
setInt(
"ReplyCount", count);
1224 if (!apiMutex.enter(1000,
"Replying to query"))
1226 bool res = space->queryReply(
id, status, msg);
1235 va_start(args, formatstring);
1238 if (!str || !lenStr) {
1243 char* name =
new char[256];
1244 if (!space->manager->componentMemory->getComponentName(currentCompID, name, 255)) {
1263 entry->
source = currentCompID;
1265 entry->
level = (uint8)level;
1267 entry->
setText(newStr, lenNewStr);
1270 return space->logEntry(entry);
#define COMPSTATUS_STARTING
Component is starting up.
#define COMPSTATUS_FINISHED
Component finished/stopped.
#define COMPSTATUS_RUNNING
Component is executing a run.
#define GetObjID(data)
Extract the cid field from a binary object block: the uint32 at byte offset 4 (after the leading size...
PsyAPI — the component-facing API handle of the CMSDK.
#define QUERY_NOT_REACHABLE
The target could not be reached (e.g.
#define QUERY_SUCCESS
The query succeeded.
#define POST_NOSPEC
Posting attempted before any trigger arrived (no active spec).
#define POST_FAILED
An error occurred while posting.
#define QUERY_NOT_AVAILABLE
The target exists but is not available.
#define CRANKAPI_RUNNING
The crank is currently executing.
#define QUERY_FAILED
General failure.
#define QUERY_COMPONENT_UNKNOWN
The target component is unknown.
#define POST_OUTOFCONTEXT
The crank's context is no longer active.
#define CRANKAPI_IDLE
The crank is idle, waiting for input.
#define LOG_COMPONENT
Log source id used by components when writing entries to the system log.
#define CRANKAPI_FAILED
The API could not be obtained or is invalid.
#define CRANKAPI_INUSE
The API is already in use by another thread.
#define QUERY_NAME_UNKNOWN
The query name is not defined in the spec.
#define MESSAGE_NON_GUARANTEED
Delivery policy flag: message delivery is not guaranteed (may be dropped under load).
static struct PsyType NOTYPE
The empty/unset message type (isValid() == false).
static struct PsyContext NOCONTEXT
The empty/unset context (isValid() == false).
#define MAXCOMMANDLINELEN
bool addComponentStats(uint32 cid, uint8 status, uint64 usageCPUTicks, DataMessage *inputMsg, DataMessage *outputMsg, uint32 runCount, uint32 cycleCount)
Fold a run's activity into the component's stats (counters, rings, CPU ticks).
The central Psyclone data container: a self-contained binary message with typed, named user entries.
bool addTimeUsage(uint32 cycleCPUTime, uint32 cycleWallTime, uint32 chainCPUTime=0, uint32 chainWallTime=0, uint32 chainCount=0)
addTimeUsage()
bool setString(const char *key, const char *value)
setString(const char* key, const char* value)
bool getInt(const char *key, int64 &value)
getInt(const char* key, int64& value)
bool setInt(const char *key, int64 value)
setInt(const char* key, int64 value)
bool setTag(uint32 tag)
setTag(uint32 tag)
char * getDataCopy(const char *key, uint32 &size)
getDataCopy(const char* key, uint32& size)
DataMessageHeader * data
Pointer to the message's flat memory block (header + user entries).
PsyType getType()
getType()
const char * getData(const char *key, uint32 &size)
getData(const char* key, uint32& size)
uint32 getSize()
getSize() Get message size Many types of data of any size can be put into a message as user entries; ...
bool setFrom(uint32 from)
setFrom(uint32 from)
bool setTo(uint32 to)
setTo(uint32 to)
bool setType(PsyType &type)
setType(PsyType &type)
uint32 getTag()
getTag() Retrieve and return message tag id Tags can be used to segment data temporally,...
bool setData(const char *key, const char *value, uint32 size)
setData(const char* key, const char* value, uint32 size)
bool setMultiple(uint32 from, uint32 to, uint32 tag, uint64 ttl, uint8 policy, uint64 sendtime)
setMultiple(uint32 from, uint32 to, uint32 tag, uint64 ttl, uint8 policy, uint64 sendtime) Set multip...
bool setContextChange(PsyContext &context)
setContextChange(PsyContext& context)
ComponentMemory * componentMemory
Accessor for the component registry.
The API handle a component (crank) uses to talk to the Psyclone system.
bool setAutoDelete(bool autodel)
Internal use only.
static struct PsyType CTRL_CONTEXT_CHANGE
Announces a system context change.
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().
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 isRunning()
Internal use only.
std::string contextToText(PsyContext context)
Get textual representation of the context.
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.
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.
~PsyAPI()
Destructor for the PsyAPI.
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.
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 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.
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.
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.
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.
uint64 getCurrentMessageReceiveTime()
Get the time the current trigger (or, failing that, the current message) was received by the system,...
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.
DataMessage * waitForNewMessage(uint32 ms)
Wait for the next trigger message from the component's input queue.
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...
static struct PsyType CTRL_QUERY
Carries a query to a component/catalog.
std::set< std::string > getCurrentPostNames()
Get a list of post names currently active - i.e.
static struct PsyType CTRL_ADDSUBSCRIPTION
Adds triggers/posts to a registration at runtime.
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.
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.
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.
std::string getCurrentScriptLanguage()
Internal use only.
MemoryManager * manager
The process-local memory manager: entry point to the node's shared-memory fabric. Owned by the space.
bool leave()
Release the mutex.
bool enter()
Block until the mutex is acquired.
uint64 GetTimeNow()
Return the current absolute time (µs since year 0) according to the TMC.
int32 GetTimeAgeMS(uint64 t)
Age of a timestamp relative to now, in milliseconds.
int64 GetTimeAge(uint64 t)
Age of a timestamp relative to now.
bool GetCPUTicks(ThreadHandle hThread, uint64 &ticks)
Get accumulated CPU time of a specific thread.
uint32 strcpyavail(char *dst, const char *src, uint32 maxlen, bool copyAvailable)
Bounded strcpy that always NUL-terminates.
char * StringFormatVA(uint32 &size, const char *format, va_list args)
va_list core used by the other StringFormat overloads.
bool LookupIPAddress(const char *name, uint32 &address)
Resolve a hostname to an IPv4 address.
std::string StringFormat(const char *format,...)
printf into a std::string.
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.
bool isValid()
A type is valid if its root level is non-zero.
Wire/storage layout of one log record: fixed header immediately followed by the message text.
bool setText(char *text, uint32 len)
Copy len bytes of text into the payload area and update size.
Specification of a message to post when a trigger fires (or a crank completes).
uint8 policy
Delivery policy flags (e.g.
PsyType type
Type of the posted message.
uint32 addContentToMsg(DataMessage *msg)
Unpack the inline content entries into msg as typed user entries.
uint32 to
Addressee component id (0 = publish to subscribers).
uint32 tag
Tag for the posted message.
uint64 ttl
Time-to-live of the posted message in microseconds.
PsyContext contextchange
Context switch the posted message announces (NOCONTEXT if none).
Specification of a query against a catalog/service/feed, attached to a TriggerSpec.
char type[MAXKEYNAMELEN+1]
Requested data/content type.
char hostName[MAXKEYNAMELEN+1]
External source: host name (alternative to ipHost).
uint32 ipHost
External source: IPv4 host (as uint32), 0 if not used.
char operation[MAXKEYNAMELEN+1]
Operation to perform (source-specific verb).
char key[MAXKEYNAMELEN+1]
Key to query on.
char value[MAXVALUENAMELEN+1]
Value to match.
char name[MAXKEYNAMELEN+1]
Name of this query, used to reference its results in the crank.
char subdir[MAXKEYNAMELEN+1]
Sub-directory/collection within the source.
char sourceName[MAXKEYNAMELEN+1]
Name of the source component (alternative to numeric id).
bool binary
Request results in binary form rather than text.
uint16 ipPort
External source: TCP/UDP port, 0 if not used.
char ext[MAXKEYNAMELEN+1]
File extension / data format selector.
uint32 source
Component id of the source to query.
Specification of a whiteboard retrieval attached to a TriggerSpec.
uint64 endTime
Range end when keytype == INDEX_TIME (microseconds).
char endString[MAXVALUENAMELEN+1]
Range end when keytype == INDEX_STRING.
char startString[MAXVALUENAMELEN+1]
Range start when keytype == INDEX_STRING.
uint64 startTime
Range start when keytype == INDEX_TIME (microseconds).
uint32 origin
Restrict to messages originating from this component id (0 = any).
int64 endInt
Range end when keytype == INDEX_INTEGER.
int64 startInt
Range start when keytype == INDEX_INTEGER.
uint32 maxcount
Maximum number of messages to return (0 = unlimited).
uint32 source
Component id of the whiteboard to retrieve from.
float64 startFloat
Range start when keytype == INDEX_FLOAT.
float64 endFloat
Range end when keytype == INDEX_FLOAT.
uint64 maxage
Maximum message age in MICROSECONDS (XML gives ms; parser multiplies by 1000).
Specification of a signal (a typed notification without payload) emitted when a trigger fires.
PsyType type
Type of the signal to emit.
A complete trigger definition: what fires a component's crank and what happens then.