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;
48 commandlineBasedir[0] = 0;
49 currentTriggerName[0] = 0;
50 currentTriggerMsg = NULL;
52 currentSignalMsg = NULL;
53 currentTriggerSpec = NULL;
58 shouldContinueRunning =
false;
62 delete(currentTriggerMsg);
63 currentTriggerMsg = NULL;
66 delete(currentSignalMsg);
67 currentSignalMsg = NULL;
69 std::map<std::string, DataMessage*>::iterator git, gitEnd;
70 for (git = currentGroupMap.begin(), gitEnd = currentGroupMap.end(); git != gitEnd; git++)
71 if (git->second)
delete(git->second);
72 currentGroupMap.clear();
81 return (
const char*)ptr;
85 if (!apiMutex.enter(1000))
98 if (!apiMutex.enter(1000))
102 if (shouldContinueRunning && currentCompID) {
104 if (now - lastPauseCheck > 100000) {
105 lastPauseCheck = now;
106 pausedSeen = space->manager->componentMemory->isComponentPaused(currentCompID);
108 if (pausedSeen) shouldContinueRunning =
false;
110 if (shouldContinueRunning) {
121 return commandlineBasedir;
131 return space->manager->componentMemory->getComponentName(currentCompID, name, maxSize);
135 return space->manager->componentMemory->getComponentNameString(currentCompID);
139 return space->manager->componentMemory->getComponentNameString(
id);
143 return space->manager->dataMapsMemory->getCrankLanguage(currentCrankID, language, maxSize);
147 char* language =
new char[1024];
148 if (!space->manager->dataMapsMemory->getCrankLanguage(currentCrankID, language, 1024)) {
152 std::string lang = language;
158 return space->manager->dataMapsMemory->getCrankScript(currentCrankID, script, 1024);
163 if (!space->manager->dataMapsMemory->getCrankScript(currentCrankID, script,
MAXSCRIPTLEN)) {
167 std::string scr = script;
173 return space->manager->dataMapsMemory->getCrankLibraryFilename(currentCrankID, file, 1024);
177 char* file =
new char[1024];
178 if (!space->manager->dataMapsMemory->getCrankLibraryFilename(currentCrankID, file, 1024)) {
182 std::string filename = file;
188 if (!apiMutex.enter(1000, __FUNCTION__))
190 if (currentTriggerSpec) {
191 if (currentTriggerSpec->getRetrieveSpec(name)) {
201 if (!apiMutex.enter(1000, __FUNCTION__))
203 if (currentTriggerSpec) {
204 if (currentTriggerSpec->getSignalSpec(name)) {
215 if (!apiMutex.enter(1000, __FUNCTION__))
217 if (currentTriggerSpec) {
218 if (currentTriggerSpec->getQuerySpec(name)) {
228 if (!apiMutex.enter(1000, __FUNCTION__))
230 if (currentTriggerSpec) {
231 if (currentTriggerSpec->getPostSpec(name)) {
241 std::set<std::string> postNames;
242 if (!apiMutex.enter(1000, __FUNCTION__))
244 if (currentTriggerSpec) {
245 std::list<PostSpec*>* postSpecs = currentTriggerSpec->getPostSpecs(NULL);
246 if (postSpecs && postSpecs->size()) {
247 std::list<PostSpec*>::iterator it = postSpecs->begin(), itEnd = postSpecs->end();
248 while (it != itEnd) {
249 postNames.insert((*it)->name);
260 if (!apiMutex.enter(1000, __FUNCTION__))
262 uint32 qSize = (uint32)inputQueue.size();
269 return space->manager->typeToText(type);
273 return space->manager->contextToText(context);
276bool PsyAPI::begin() {
277 if (!apiMutex.
enter(1000))
280 shouldContinueRunning =
true;
285 lastWallTime = startedRunning;
298bool PsyAPI::finish() {
300 if (!apiMutex.
enter(1000))
308 uint32 finishedCompID = currentCompID;
311 uint64 currentCPUTicks;
314 currentCPUTicks - lastCPUTicks,
321 lastCPUTicks = currentCPUTicks;
328 apiMutex.enter(1000);
329 shouldContinueRunning =
false;
338 return space->addPsyProbeCustomView(currentCompID, name, templateURL);
343uint64 PsyAPI::checkLastWaitForMessage() {
344 if (!apiMutex.
enter(1000))
348 if (startedRunning && currentCrankID) {
349 if (inputQueue.size() && (
GetTimeAgeMS(lastWallTime) > 5000)) {
358uint8 PsyAPI::claimForWake(uint32 crankID, uint32 compID) {
359 if (!apiMutex.enter(1000))
361 if (startedRunning && currentCrankID) {
366 currentCrankID = crankID;
367 currentCompID = compID;
376 if (!apiMutex.enter(1000))
380 if (startedRunning && currentCrankID) {
381 if (crankID == currentCrankID) {
384 inputQueueSemaphore.signal();
395 currentCrankID = crankID;
396 currentCompID = compID;
411 inputQueueSemaphore.signal();
418 const char* triggerName;
423 return currentTriggerName;
427 if (this->currentTriggerSpec)
428 return this->currentTriggerSpec->context;
438 uint64 currentCPUTicks;
441 if (!apiMutex.enter(1000, __FUNCTION__))
444 if (!inputQueue.size()) {
447 if (!inputQueueSemaphore.wait(ms) || !inputQueue.size()) {
450 currentCPUTicks - lastCPUTicks,
456 lastCPUTicks = currentCPUTicks;
464 if (!apiMutex.enter(1000, __FUNCTION__))
487 tm = inputQueue.front();
496 delete(currentTriggerMsg);
497 currentTriggerMsg = msgFirst;
500 triggerName = currentTriggerName;
523 if (msgFirst && msgSecond) {
540 currentCPUTicks - lastCPUTicks,
546 lastCPUTicks = currentCPUTicks;
560 std::map<std::string, DataMessage*>::iterator git, gitEnd;
561 for (git = currentGroupMap.begin(), gitEnd = currentGroupMap.end(); git != gitEnd; git++)
562 if (git->second)
delete(git->second);
563 currentGroupMap.clear();
566 const char* triggerName = NULL;
572 if (triggerName && currentTriggerMsg && currentTriggerMsg->getType() ==
CTRL_TRIGGER_GROUP) {
573 currentGroupMap = currentTriggerMsg->getAttachedMessageMap(
"Members");
574 groupName = triggerName;
576 else if (triggerName && primary) {
579 if (triggerName) groupName = triggerName;
583 return currentGroupMap;
587 autoDelete = autodel;
594 if (currentTriggerMsg && (t = currentTriggerMsg->getRecvTime()) )
597 return currentMsg->getRecvTime();
618 uint64 currentCPUTicks;
621 if (!apiMutex.enter(1000))
625 msg->
addTimeUsage((uint32)(currentCPUTicks - lastCPUTicks), (uint32)
GetTimeAge(lastWallTime), chainCPUTicks, chainWallTime, chainCount + 1);
627 uint32 currentTag = 0;
629 currentTag = currentMsg->getTag();
634 if (!currentTriggerSpec) {
637 logPrint(1,
"Posting none - out of context");
640 if (currentTag && !msg->
getTag())
643 if (space->postMessage(msg)) {
648 logPrint(0,
"Failed to post direct message to component %u", to);
654 logPrint(1,
"Posting none - out of context");
661 std::list<PostSpec*>* postSpecs = currentTriggerSpec->getPostSpecs(postName);
662 if (!postSpecs || !postSpecs->size()) {
666 postSpecs = currentTriggerSpec->getPostSpecs(msg->
getType());
667 if (!postSpecs || !postSpecs->size()) {
670 logPrint(2,
"Posting nothing - no post specs match for post name '%s'", postName);
681 msg->
addTimeUsage((uint32)(currentCPUTicks - lastCPUTicks), (uint32)
GetTimeAge(lastWallTime), chainCPUTicks, chainWallTime, chainCount + 1);
686 if (currentTag && !msg->
getTag())
691 std::list<PostSpec*>::iterator it = postSpecs->begin(), itEnd = postSpecs->end();
692 while (it != itEnd) {
693 if (postSpec = *it) {
707 if (space->postMessage(msg)) {
712 logPrint(0,
"Failed to deliver posted msg to %u", postSpec->
to);
722 msgSentCount += success;
725 logPrint(0,
"No msgs were delivered at postOutputMessage", success);
731 currentCPUTicks - lastCPUTicks,
738 lastCPUTicks = currentCPUTicks;
742 if (!success && failed)
751 if (!apiMutex.enter(1000))
754 if (!currentTriggerSpec) {
760 SignalSpec* signalSpec = currentTriggerSpec->getSignalSpec(name);
770 if (space->emitSignal(signalSpec->
type, msg)) {
783 apiMutex.enter(3000, __FUNCTION__);
785 if (!currentTriggerSpec) {
790 SignalSpec* signalSpec = currentTriggerSpec->getSignalSpec(name);
797 DataMessage* msg = space->waitForSignal(signalSpec->
type, timeout, lastReceivedTime);
800 apiMutex.enter(3000, __FUNCTION__);
801 if (currentSignalMsg)
802 delete(currentSignalMsg);
803 currentSignalMsg = msg;
813uint8
PsyAPI::retrieve(std::list<DataMessage*> &result,
const char* name, uint32 maxcount, uint32 maxage, uint32 timeout) {
814 if (!apiMutex.enter(1000))
817 if (!currentTriggerSpec) {
822 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
834 specCopy->
maxage = maxage;
837 uint8 res =
retrieve(result, specCopy, timeout);
841uint8
PsyAPI::retrieveTimeParam(std::list<DataMessage*> &result,
const char* name, uint64 startTime, uint64 endTime, uint32 maxcount, uint32 maxage, uint32 timeout) {
842 std::list<DataMessage*> list;
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::retrieveStringParam(std::list<DataMessage*> &result,
const char* name,
const char* startString,
const char* endString, uint32 maxcount, uint32 maxage, uint32 timeout) {
876 std::list<DataMessage*> list;
877 if (!startString || !strlen(startString))
880 if (!apiMutex.enter(1000))
883 if (!currentTriggerSpec) {
888 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
903 specCopy->
maxage = maxage;
906 uint8 res =
retrieve(result, specCopy, timeout);
910uint8
PsyAPI::retrieveIntegerParam(std::list<DataMessage*> &result,
const char* name, int64 startInteger, int64 endInteger, uint32 maxcount, uint32 maxage, uint32 timeout) {
911 std::list<DataMessage*> list;
915 if (!apiMutex.enter(1000))
918 if (!currentTriggerSpec) {
923 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
934 specCopy->
endInt = endInteger;
938 specCopy->
maxage = maxage;
941 uint8 res =
retrieve(result, specCopy, timeout);
945uint8
PsyAPI::retrieveFloatParam(std::list<DataMessage*> &result,
const char* name, float64 startFloat, float64 endFloat, uint32 maxcount, uint32 maxage, uint32 timeout) {
946 std::list<DataMessage*> list;
949 if (!apiMutex.enter(1000))
952 if (!currentTriggerSpec) {
957 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
972 specCopy->
maxage = maxage;
975 uint8 res =
retrieve(result, specCopy, timeout);
982 spec->
origin = currentCompID;
988 uint8 status = space->query(msg, &resultMsg, timeout);
993 logPrint(0,
"Query failed and did not return a message...");
1000 const char* data = resultMsg->
getData(
"ReplyData", size);
1001 if (!data || !resultMsg->
getInt(
"ReplyCount", count)) {
1003 logPrint(0,
"Query did not return any ReplyData...");
1005 logPrint(0,
"Query did not return any ReplyCount...");
1012 const char* src = data;
1013 for (uint32 n=0; n<(uint32)count; n++) {
1017 result.push_back(subMsg);
1027 if (!apiMutex.enter(1000))
1033 uint8 status = space->query(msg, &resultMsg, 5000);
1048 if (!apiMutex.enter(1000))
1051 if (!currentTriggerSpec) {
1052 logPrint(1,
"Query '%s' cannot execute before a trigger message has been processed", name);
1057 QuerySpec* querySpec = currentTriggerSpec->getQuerySpec(name);
1059 logPrint(1,
"Query '%s' not found in PsySpec", name);
1066 if (strlen(querySpec->
type))
1068 if (strlen(querySpec->
ext))
1070 if (strlen(querySpec->
subdir))
1072 if (strlen(querySpec->
key))
1074 if (strlen(querySpec->
value))
1081 if (!querySpec->
ipHost) {
1088 querySpec->
ipPort = 10000;
1104 uint8 status = space->query(msg, resultMsg, timeout);
1118 if (chosenAddress > numAddresses)
1122 if (chosenAddress) {
1124 result =
queryRemoteCatalog(resultMsg, componentName, ipAddresses[chosenAddress-1], port, msg, timeout);
1131 for (uint32 n = 0; n < numAddresses; n++) {
1132 result =
queryRemoteCatalog(resultMsg, componentName, ipAddresses[n], port, msg, timeout);
1134 chosenAddress = n + 1;
1153 msg->
setString(
"INTERSYSTEM_SOURCENAME", componentName);
1154 msg->
setInt(
"INTERSYSTEM_ADDRESS", ipAddress);
1155 msg->
setInt(
"INTERSYSTEM_PORT", port);
1157 uint8 status = space->query(msg, resultMsg, timeout);
1166uint8
PsyAPI::queryCatalog(
char** result, uint32 &resultsize,
const char* name,
const char* query,
const char* operation,
const char* data, uint32 datasize, uint32 timeout) {
1168 if (!apiMutex.enter(1000,
"Replying to query"))
1171 if (!currentTriggerSpec) {
1176 QuerySpec* querySpec = currentTriggerSpec->getQuerySpec(name);
1186 if (query && strlen(query))
1188 if (data && datasize)
1189 msg->
setData(
"Data", data, datasize);
1190 if (operation && strlen(operation))
1195 if (strlen(querySpec->
type))
1197 if (strlen(querySpec->
ext))
1199 if (strlen(querySpec->
subdir))
1201 if (strlen(querySpec->
key))
1203 if (strlen(querySpec->
value))
1210 if (!querySpec->
ipHost) {
1217 querySpec->
ipPort = 10000;
1234 uint8 status = space->query(msg, &resultMsg, timeout);
1238 *result = resultMsg->
getDataCopy(
"ReplyData", resultsize);
1249 msg->
setData(
"ReplyData", data, size);
1250 msg->
setInt(
"ReplyCount", count);
1259 if (!apiMutex.enter(1000,
"Replying to query"))
1261 bool res = space->queryReply(
id, status, msg);
1270 va_start(args, formatstring);
1273 if (!str || !lenStr) {
1278 char* name =
new char[256];
1279 if (!space->manager->componentMemory->getComponentName(currentCompID, name, 255)) {
1298 entry->
source = currentCompID;
1300 entry->
level = (uint8)level;
1302 entry->
setText(newStr, lenNewStr);
1305 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 1.x 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.