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;
365 inputQueueSemaphore.signal();
372 const char* triggerName;
377 return currentTriggerName;
381 if (this->currentTriggerSpec)
382 return this->currentTriggerSpec->context;
392 uint64 currentCPUTicks;
395 if (!apiMutex.enter(1000, __FUNCTION__))
398 if (!inputQueue.size()) {
401 if (!inputQueueSemaphore.wait(ms) || !inputQueue.size()) {
404 currentCPUTicks - lastCPUTicks,
410 lastCPUTicks = currentCPUTicks;
418 if (!apiMutex.enter(1000, __FUNCTION__))
441 tm = inputQueue.front();
450 delete(currentTriggerMsg);
451 currentTriggerMsg = msgFirst;
454 triggerName = currentTriggerName;
477 if (msgFirst && msgSecond) {
494 currentCPUTicks - lastCPUTicks,
500 lastCPUTicks = currentCPUTicks;
514 std::map<std::string, DataMessage*>::iterator git, gitEnd;
515 for (git = currentGroupMap.begin(), gitEnd = currentGroupMap.end(); git != gitEnd; git++)
516 if (git->second)
delete(git->second);
517 currentGroupMap.clear();
520 const char* triggerName = NULL;
526 if (triggerName && currentTriggerMsg && currentTriggerMsg->getType() ==
CTRL_TRIGGER_GROUP) {
527 currentGroupMap = currentTriggerMsg->getAttachedMessageMap(
"Members");
528 groupName = triggerName;
530 else if (triggerName && primary) {
533 if (triggerName) groupName = triggerName;
537 return currentGroupMap;
541 autoDelete = autodel;
548 if (currentTriggerMsg && (t = currentTriggerMsg->getRecvTime()) )
551 return currentMsg->getRecvTime();
572 uint64 currentCPUTicks;
575 if (!apiMutex.enter(1000))
579 msg->
addTimeUsage((uint32)(currentCPUTicks - lastCPUTicks), (uint32)
GetTimeAge(lastWallTime), chainCPUTicks, chainWallTime, chainCount + 1);
581 uint32 currentTag = 0;
583 currentTag = currentMsg->getTag();
588 if (!currentTriggerSpec) {
591 logPrint(1,
"Posting none - out of context");
594 if (currentTag && !msg->
getTag())
597 if (space->postMessage(msg)) {
602 logPrint(0,
"Failed to post direct message to component %u", to);
608 logPrint(1,
"Posting none - out of context");
615 std::list<PostSpec*>* postSpecs = currentTriggerSpec->getPostSpecs(postName);
616 if (!postSpecs || !postSpecs->size()) {
620 postSpecs = currentTriggerSpec->getPostSpecs(msg->
getType());
621 if (!postSpecs || !postSpecs->size()) {
624 logPrint(2,
"Posting nothing - no post specs match for post name '%s'", postName);
635 msg->
addTimeUsage((uint32)(currentCPUTicks - lastCPUTicks), (uint32)
GetTimeAge(lastWallTime), chainCPUTicks, chainWallTime, chainCount + 1);
640 if (currentTag && !msg->
getTag())
645 std::list<PostSpec*>::iterator it = postSpecs->begin(), itEnd = postSpecs->end();
646 while (it != itEnd) {
647 if (postSpec = *it) {
661 if (space->postMessage(msg)) {
666 logPrint(0,
"Failed to deliver posted msg to %u", postSpec->
to);
676 msgSentCount += success;
679 logPrint(0,
"No msgs were delivered at postOutputMessage", success);
685 currentCPUTicks - lastCPUTicks,
692 lastCPUTicks = currentCPUTicks;
696 if (!success && failed)
705 if (!apiMutex.enter(1000))
708 if (!currentTriggerSpec) {
714 SignalSpec* signalSpec = currentTriggerSpec->getSignalSpec(name);
724 if (space->emitSignal(signalSpec->
type, msg)) {
737 apiMutex.enter(3000, __FUNCTION__);
739 if (!currentTriggerSpec) {
744 SignalSpec* signalSpec = currentTriggerSpec->getSignalSpec(name);
751 DataMessage* msg = space->waitForSignal(signalSpec->
type, timeout, lastReceivedTime);
754 apiMutex.enter(3000, __FUNCTION__);
755 if (currentSignalMsg)
756 delete(currentSignalMsg);
757 currentSignalMsg = msg;
767uint8
PsyAPI::retrieve(std::list<DataMessage*> &result,
const char* name, uint32 maxcount, uint32 maxage, uint32 timeout) {
768 if (!apiMutex.enter(1000))
771 if (!currentTriggerSpec) {
776 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
788 specCopy->
maxage = maxage;
791 uint8 res =
retrieve(result, specCopy, timeout);
795uint8
PsyAPI::retrieveTimeParam(std::list<DataMessage*> &result,
const char* name, uint64 startTime, uint64 endTime, uint32 maxcount, uint32 maxage, uint32 timeout) {
796 std::list<DataMessage*> list;
799 if (!apiMutex.enter(1000))
802 if (!currentTriggerSpec) {
807 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
822 specCopy->
maxage = maxage;
825 uint8 res =
retrieve(result, specCopy, timeout);
829uint8
PsyAPI::retrieveStringParam(std::list<DataMessage*> &result,
const char* name,
const char* startString,
const char* endString, uint32 maxcount, uint32 maxage, uint32 timeout) {
830 std::list<DataMessage*> list;
831 if (!startString || !strlen(startString))
834 if (!apiMutex.enter(1000))
837 if (!currentTriggerSpec) {
842 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
857 specCopy->
maxage = maxage;
860 uint8 res =
retrieve(result, specCopy, timeout);
864uint8
PsyAPI::retrieveIntegerParam(std::list<DataMessage*> &result,
const char* name, int64 startInteger, int64 endInteger, uint32 maxcount, uint32 maxage, uint32 timeout) {
865 std::list<DataMessage*> list;
869 if (!apiMutex.enter(1000))
872 if (!currentTriggerSpec) {
877 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
888 specCopy->
endInt = endInteger;
892 specCopy->
maxage = maxage;
895 uint8 res =
retrieve(result, specCopy, timeout);
899uint8
PsyAPI::retrieveFloatParam(std::list<DataMessage*> &result,
const char* name, float64 startFloat, float64 endFloat, uint32 maxcount, uint32 maxage, uint32 timeout) {
900 std::list<DataMessage*> list;
903 if (!apiMutex.enter(1000))
906 if (!currentTriggerSpec) {
911 RetrieveSpec* retrieveSpec = currentTriggerSpec->getRetrieveSpec(name);
926 specCopy->
maxage = maxage;
929 uint8 res =
retrieve(result, specCopy, timeout);
936 spec->
origin = currentCompID;
942 uint8 status = space->query(msg, &resultMsg, timeout);
947 logPrint(0,
"Query failed and did not return a message...");
954 const char* data = resultMsg->
getData(
"ReplyData", size);
955 if (!data || !resultMsg->
getInt(
"ReplyCount", count)) {
957 logPrint(0,
"Query did not return any ReplyData...");
959 logPrint(0,
"Query did not return any ReplyCount...");
966 const char* src = data;
967 for (uint32 n=0; n<(uint32)count; n++) {
971 result.push_back(subMsg);
981 if (!apiMutex.enter(1000))
987 uint8 status = space->query(msg, &resultMsg, 5000);
1002 if (!apiMutex.enter(1000))
1005 if (!currentTriggerSpec) {
1006 logPrint(1,
"Query '%s' cannot execute before a trigger message has been processed", name);
1011 QuerySpec* querySpec = currentTriggerSpec->getQuerySpec(name);
1013 logPrint(1,
"Query '%s' not found in PsySpec", name);
1020 if (strlen(querySpec->
type))
1022 if (strlen(querySpec->
ext))
1024 if (strlen(querySpec->
subdir))
1026 if (strlen(querySpec->
key))
1028 if (strlen(querySpec->
value))
1035 if (!querySpec->
ipHost) {
1042 querySpec->
ipPort = 10000;
1058 uint8 status = space->query(msg, resultMsg, timeout);
1072 if (chosenAddress > numAddresses)
1076 if (chosenAddress) {
1078 result =
queryRemoteCatalog(resultMsg, componentName, ipAddresses[chosenAddress-1], port, msg, timeout);
1085 for (uint32 n = 0; n < numAddresses; n++) {
1086 result =
queryRemoteCatalog(resultMsg, componentName, ipAddresses[n], port, msg, timeout);
1088 chosenAddress = n + 1;
1107 msg->
setString(
"INTERSYSTEM_SOURCENAME", componentName);
1108 msg->
setInt(
"INTERSYSTEM_ADDRESS", ipAddress);
1109 msg->
setInt(
"INTERSYSTEM_PORT", port);
1111 uint8 status = space->query(msg, resultMsg, timeout);
1120uint8
PsyAPI::queryCatalog(
char** result, uint32 &resultsize,
const char* name,
const char* query,
const char* operation,
const char* data, uint32 datasize, uint32 timeout) {
1122 if (!apiMutex.enter(1000,
"Replying to query"))
1125 if (!currentTriggerSpec) {
1130 QuerySpec* querySpec = currentTriggerSpec->getQuerySpec(name);
1140 if (query && strlen(query))
1142 if (data && datasize)
1143 msg->
setData(
"Data", data, datasize);
1144 if (operation && strlen(operation))
1149 if (strlen(querySpec->
type))
1151 if (strlen(querySpec->
ext))
1153 if (strlen(querySpec->
subdir))
1155 if (strlen(querySpec->
key))
1157 if (strlen(querySpec->
value))
1164 if (!querySpec->
ipHost) {
1171 querySpec->
ipPort = 10000;
1188 uint8 status = space->query(msg, &resultMsg, timeout);
1192 *result = resultMsg->
getDataCopy(
"ReplyData", resultsize);
1203 msg->
setData(
"ReplyData", data, size);
1204 msg->
setInt(
"ReplyCount", count);
1213 if (!apiMutex.enter(1000,
"Replying to query"))
1215 bool res = space->queryReply(
id, status, msg);
1224 va_start(args, formatstring);
1227 if (!str || !lenStr) {
1232 char* name =
new char[256];
1233 if (!space->manager->componentMemory->getComponentName(currentCompID, name, 255)) {
1252 entry->
source = currentCompID;
1254 entry->
level = (uint8)level;
1256 entry->
setText(newStr, lenNewStr);
1259 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.