1435 PMXML_NODE
pn, pr, pt, pe;
1438 int i,
j, l,
n,
status, size, index1, index2,
state,
run_number, cont;
1449 if (
c->pnseq == NULL) {
1466 pr = mxml_find_node(
c->pnseq,
"RunSequence");
1468 seq_error(seq,
c,
"Cannot find <RunSequence> tag in XML file");
1472 int last_line = mxml_get_line_number_end(pr);
1491 cm_msg(
MTALK,
"sequencer",
"Sequencer is finished.");
1516 if (mxml_get_attribute(
pn,
"var")) {
1518 if (mxml_get_attribute(
pn,
"values")) {
1522 }
else if (mxml_get_attribute(
pn,
"n")) {
1525 sprintf(
str,
"Variables/%s",
name);
1526 size = strlen(
value) + 1;
1577 if (mxml_get_attribute(
pn,
"l"))
1579 if (mxml_get_attribute(
pn,
"fn")) {
1580 std::string filename = mxml_get_attribute(
pn,
"fn");
1583 if (filename != std::string(seq.
sfilename)) {
1589 if (mxml_get_attribute(
pn,
"l") && (!mxml_get_attribute(
pn,
"lvl") || atoi(mxml_get_attribute(
pn,
"lvl")) == 0))
1598 midas::odb o(
"/" +
c->odb_path +
"/Script/Lines");
1613 if (!mxml_get_attribute(
pn,
"path")) {
1614 seq_error(seq,
c,
"Missing attribute \"path\"");
1617 if (mxml_get_attribute(
pn,
"notify"))
1626 if (!mxml_get_attribute(
pn,
"path")) {
1627 seq_error(seq,
c,
"Missing attribute \"path\"");
1630 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1631 strlcat(odbpath,
"/",
sizeof(odbpath));
1632 strlcat(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
1634 if (strchr(odbpath,
'$')) {
1635 if (strchr(odbpath,
'[')) {
1637 std::string s(odbpath);
1638 std::string s1 = s.substr(0, s.find(
'['));
1639 std::string s2 = s.substr(s.find(
'['));
1642 strlcpy(odbpath, s1.c_str(),
sizeof(odbpath));
1645 std::string s(odbpath);
1647 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1654 if (mxml_get_attribute(
pn,
"notify"))
1655 notify = atoi(mxml_get_attribute(
pn,
"notify"));
1657 index1 = index2 = 0;
1669 sprintf(
str,
"ODB key \"%s\" not found", odbpath);
1673 sprintf(
str,
"Internal error %d",
status);
1682 if (mxml_get_value(
pn)[0] ==
'/') {
1686 path +=
"userfiles/sequencer/";
1693 path +=
"userfiles/sequencer/";
1697 char *fullpath = strrchr(
value,
'/');
1699 *(++fullpath) =
'\0';
1704 if (mxml_get_attribute(
pn,
"path")) {
1706 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1707 strlcat(odbpath,
"/",
sizeof(odbpath));
1708 strlcat(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
1710 if (strchr(odbpath,
'$')) {
1711 std::string s(odbpath);
1713 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1720 sprintf(errorstr,
"Cannot find ODB key \"%s\"", odbpath);
1736 sprintf(
str,
"Error reading file \"%s\"",
value);
1740 seq_error(seq,
c,
"Internal error loading ODB file!");
1747 if (mxml_get_value(
pn)[0] ==
'/') {
1751 path +=
"userfiles/sequencer/";
1758 path +=
"userfiles/sequencer/";
1762 char *fullpath = strrchr(
value,
'/');
1764 *(++fullpath) =
'\0';
1768 if (strchr(
value,
'$')) {
1769 std::string s(
value);
1775 if (mxml_get_attribute(
pn,
"path") && *mxml_get_attribute(
pn,
"path")) {
1777 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1778 strlcat(odbpath,
"/",
sizeof(odbpath));
1779 strlcat(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
1781 if (strchr(odbpath,
'$')) {
1782 std::string s(odbpath);
1784 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1791 sprintf(errorstr,
"Cannot find ODB key \"%s\"", odbpath);
1795 if (strstr(
value,
".json") || strstr(
value,
".JSON") || strstr(
value,
".js") || strstr(
value,
".JS"))
1797 else if (strstr(
value,
".xml") || strstr(
value,
".XML"))
1803 sprintf(err,
"Cannot save file \"%s\", error %d",
value,
status);
1809 seq_error(seq,
c,
"No ODB path specified in ODBSAVE command");
1818 sprintf(
str,
"Error reading file \"%s\"",
value);
1822 seq_error(seq,
c,
"Internal error loading ODB file!");
1829 if (!mxml_get_attribute(
pn,
"path")) {
1830 seq_error(seq,
c,
"Missing attribute \"path\"");
1833 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1834 strlcat(odbpath,
"/",
sizeof(odbpath));
1835 strlcat(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
1837 if (strchr(odbpath,
'$')) {
1838 if (strchr(odbpath,
'[')) {
1840 std::string s(odbpath);
1841 std::string s1 = s.substr(0, s.find(
'['));
1842 std::string s2 = s.substr(s.find(
'['));
1845 strlcpy(odbpath, s1.c_str(),
sizeof(odbpath));
1848 std::string s(odbpath);
1850 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1855 index1 = index2 = 0;
1862 sprintf(errorstr,
"Cannot find ODB key \"%s\"", odbpath);
1867 size =
sizeof(
data);
1875 sprintf(
str,
"Variables/%s",
name);
1876 size = strlen(
value) + 1;
1890 if (!mxml_get_attribute(
pn,
"path")) {
1891 seq_error(seq,
c,
"Missing attribute \"path\"");
1894 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1895 strlcat(odbpath,
"/",
sizeof(odbpath));
1896 strlcat(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
1898 if (strchr(odbpath,
'$')) {
1899 if (strchr(odbpath,
'[')) {
1901 std::string s(odbpath);
1902 std::string s1 = s.substr(0, s.find(
'['));
1903 std::string s2 = s.substr(s.find(
'['));
1906 strlcpy(odbpath, s1.c_str(),
sizeof(odbpath));
1909 std::string s(odbpath);
1911 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1915 index1 = index2 = 0;
1923 sprintf(errorstr,
"Cannot find ODB key \"%s\"", odbpath);
1927 size =
sizeof(
data);
1932 sprintf(
str,
"%lg",
d);
1933 size =
sizeof(
data);
1939 if (mxml_get_attribute(
pn,
"notify"))
1940 notify = atoi(mxml_get_attribute(
pn,
"notify"));
1951 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1952 strlcat(odbpath,
"/",
sizeof(odbpath));
1953 strlcat(odbpath, mxml_get_value(
pn),
sizeof(odbpath));
1955 if (strchr(odbpath,
'$')) {
1956 std::string s(odbpath);
1958 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1964 sprintf(errorstr,
"Cannot find ODB key \"%s\"", odbpath);
1970 sprintf(errorstr,
"Cannot delete ODB key \"%s\"", odbpath);
1979 if (!mxml_get_attribute(
pn,
"path")) {
1980 seq_error(seq,
c,
"Missing attribute \"path\"");
1981 }
else if (!mxml_get_attribute(
pn,
"type")) {
1982 seq_error(seq,
c,
"Missing attribute \"type\"");
1985 if (strlen(odbpath) > 0 && odbpath[strlen(odbpath) - 1] !=
'/')
1986 strlcat(odbpath,
"/",
sizeof(odbpath));
1987 strlcat(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
1989 if (strchr(odbpath,
'$')) {
1990 std::string s(odbpath);
1992 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
1997 for (tid = 0; tid <
TID_LAST; tid++) {
2003 seq_error(seq,
c,
"Type must be one of UINT8,INT8,UINT16,INT16,UINT32,INT32,BOOL,FLOAT,DOUBLE,STRING");
2016 memset(dummy, 0,
sizeof(dummy));
2023 sprintf(errorstr,
"Cannot createODB key \"%s\", error code %d", odbpath,
status);
2027 if (mxml_get_attribute(
pn,
"size")) {
2028 i = atoi(
eval_var(seq,
c, mxml_get_attribute(
pn,
"size")).c_str());
2046 sprintf(
str,
"%s", mxml_get_value(
pn));
2048 if (mxml_get_attribute(
pn,
"params")) {
2051 for (
i = 0;
i <
n;
i++) {
2062 std::string r =
ss_execs(s.c_str());
2075 size =
sizeof(
state);
2082 char errorstr[1500];
2083 sprintf(errorstr,
"Cannot start run: %s",
str);
2089 size =
sizeof(
state);
2099 size =
sizeof(
state);
2106 char errorstr[1500];
2107 sprintf(errorstr,
"Cannot stop run: %s",
str);
2113 size =
sizeof(
state);
2126 cm_msg(
MTALK,
"sequencer",
"Sequencer is finished by \"stop after current run\".");
2135 sprintf(
str,
"Invalid transition \"%s\"", mxml_get_value(
pn));
2144 n = atoi(
eval_var(seq,
c, mxml_get_value(
pn)).c_str());
2158 }
else if (
equal_ustring(mxml_get_attribute(
pn,
"for"),
"ODBValue")) {
2161 if (!mxml_get_attribute(
pn,
"path")) {
2162 seq_error(seq,
c,
"\"path\" must be given for ODB values");
2165 strlcpy(odbpath, mxml_get_attribute(
pn,
"path"),
sizeof(odbpath));
2168 if (strchr(odbpath,
'$')) {
2169 if (strchr(odbpath,
'[')) {
2171 std::string s(odbpath);
2172 std::string s1 = s.substr(0, s.find(
'['));
2173 std::string s2 = s.substr(s.find(
'['));
2176 strlcpy(odbpath, s1.c_str(),
sizeof(odbpath));
2179 std::string s(odbpath);
2181 strlcpy(odbpath, s.c_str(),
sizeof(odbpath));
2185 index1 = index2 = 0;
2190 sprintf(errorstr,
"Cannot find ODB key \"%s\"", odbpath);
2194 if (mxml_get_attribute(
pn,
"op"))
2195 strlcpy(op, mxml_get_attribute(
pn,
"op"),
sizeof(op));
2201 size =
sizeof(
data);
2222 sprintf(
str,
"Invalid comaprison \"%s\"", op);
2256 sprintf(
str,
"Invalid wait attribute \"%s\"", mxml_get_attribute(
pn,
"for"));
2270 seq_error(seq,
c,
"Maximum loop nesting exceeded");
2275 if (mxml_get_attribute(
pn,
"l"))
2277 if (mxml_get_attribute(
pn,
"le"))
2281 if (mxml_get_attribute(
pn,
"n")) {
2288 }
else if (mxml_get_attribute(
pn,
"values")) {
2293 seq_error(seq,
c,
"Missing \"var\" or \"n\" attribute");
2297 if (mxml_get_attribute(
pn,
"var")) {
2299 sprintf(
str,
"Variables/%s",
name);
2300 size = strlen(
value) + 1;
2331 seq_error(seq,
c,
"\"Break\" outside any loop");
2344 seq_error(seq,
c,
"Maximum number of nested if..endif exceeded");
2355 pe = mxml_get_node_at_line(
c->pnseq,
j);
2359 j = mxml_get_line_number_end(pe);
2373 seq_error(seq,
c,
"Invalid number in comparison");
2400 cm_msg(
MTALK,
"sequencer",
"Sequencer is finished.");
2406 if (!mxml_get_attribute(
pn,
"line") && !mxml_get_attribute(
pn,
"sline")) {
2410 if (mxml_get_attribute(
pn,
"line")) {
2413 if (mxml_get_attribute(
pn,
"sline")) {
2415 for (
i = 0;
i < last_line;
i++) {
2416 pt = mxml_get_node_at_line(
c->pnseq,
i);
2417 if (pt && mxml_get_attribute(pt,
"l")) {
2418 l = atoi(mxml_get_attribute(pt,
"l"));
2419 if (atoi(
str) == l) {
2448 if (!mxml_get_attribute(
pn,
"name")) {
2455 if (strchr(
name,
'[')) {
2458 if (strchr(
str,
']'))
2459 *strchr(
str,
']') = 0;
2461 *strchr(
name,
'[') = 0;
2462 sprintf(
str,
"Variables/%s",
name);
2468 size = strlen(
value) + 1;
2473 sprintf(
str,
"Variables/%s",
name);
2474 size = strlen(
value) + 1;
2484 if (mxml_get_attribute(pr,
"var")) {
2495 if (strchr(mxml_get_value(
pn),
'$'))
2499 const char *wait_attr = mxml_get_attribute(
pn,
"wait");
2502 wait = (atoi(wait_attr) == 1);
2538 if (strchr(mxml_get_value(
pn),
'$'))
2542 std::string
type =
"INFO";
2543 if (mxml_get_attribute(
pn,
"type"))
2544 type = std::string(mxml_get_attribute(
pn,
"type"));
2546 if (
type ==
"ERROR")
2548 else if (
type ==
"DEBUG")
2550 else if (
type ==
"LOG")
2552 else if (
type ==
"TALK")
2562 if (!mxml_get_attribute(
pn,
"name")) {
2569 sprintf(
str,
"Variables/%s",
name);
2570 size = strlen(
value) + 1;
2581 seq_error(seq,
c,
"Maximum subroutine level exceeded");
2590 for (
i = 1;
i < mxml_get_line_number_end(mxml_find_node(
c->pnseq,
"RunSequence"));
i++) {
2591 pt = mxml_get_node_at_line(
c->pnseq,
i);
2594 if (
equal_ustring(mxml_get_attribute(pt,
"name"), mxml_get_attribute(
pn,
"name"))) {
2600 if (mxml_get_value(
pn))
2609 if (
i == mxml_get_line_number_end(mxml_find_node(
c->pnseq,
"RunSequence"))) {
2610 sprintf(
str,
"Subroutine '%s' not found", mxml_get_attribute(
pn,
"name"));
2618 sprintf(
str,
"Unknown statement \"%s\"", mxml_get_name(
pn));
2624 size =
sizeof(seq1);
2634 if (seq.
debug && !skip_step)
INT cm_transition(INT transition, INT run_number, char *errstr, INT errstr_size, INT async_flag, INT debug_flag)
#define CM_DEFERRED_TRANSITION
std::string ss_execs(const char *cmd)
std::string ss_replace_env_variables(const std::string &inputPath)
INT ss_sleep(INT millisec)
INT cm_msg_retrieve(INT n_message, char *message, INT buf_size)
INT db_get_data_index(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT idx, DWORD type)
INT db_delete_key(HNDLE hDB, HNDLE hKey, BOOL follow_links)
INT db_get_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, void *data, INT *buf_size, DWORD type, BOOL create)
INT db_save_json(HNDLE hDB, HNDLE hKey, const char *filename, int flags)
INT db_save_xml(HNDLE hDB, HNDLE hKey, const char *filename)
INT db_create_key(HNDLE hDB, HNDLE hKey, const char *key_name, DWORD type)
INT db_get_record(HNDLE hDB, HNDLE hKey, void *data, INT *buf_size, INT align)
INT db_save(HNDLE hDB, HNDLE hKey, const char *filename, BOOL bRemote)
INT db_get_key(HNDLE hDB, HNDLE hKey, KEY *key)
INT db_load(HNDLE hDB, HNDLE hKeyRoot, const char *filename, BOOL bRemote)
INT db_set_data_index(HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type)
INT db_sprintf(char *string, const void *data, INT data_size, INT idx, DWORD type)
INT db_set_value(HNDLE hDB, HNDLE hKeyRoot, const char *key_name, const void *data, INT data_size, INT num_values, DWORD type)
INT db_set_data_index1(HNDLE hDB, HNDLE hKey, const void *data, INT data_size, INT idx, DWORD type, BOOL bNotify)
INT db_sscanf(const char *data_str, void *data, INT *data_size, INT i, DWORD tid)
INT db_set_num_values(HNDLE hDB, HNDLE hKey, INT num_values)
const char * rpc_tid_name(INT id)
void seq_array_index(SEQUENCER &seq, SeqCon *c, char *odbpath, int *index1, int *index2)
int concatenate(SEQUENCER &seq, SeqCon *c, char *result, int size, char *value)
int set_all_matching(HNDLE hDB, HNDLE hBaseKey, char *odbpath, char *value, int index1, int index2, int notify)
static void seq_start_next(SEQUENCER &seq, SeqCon *c)
int eval_condition(SEQUENCER &seq, SeqCon *c, const char *condition)
#define JSFLAG_FOLLOW_LINKS
#define JSFLAG_OMIT_LAST_WRITTEN
int if_line[SEQ_NEST_LEVEL_IF]
static void pn(const te_expr *n, int depth)