summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrlm <rlm@techsat.com>2020-06-10 09:11:58 (GMT)
committerrlm <rlm@techsat.com>2020-06-10 09:11:58 (GMT)
commitfbf5005a9f4d821ee04dff7c0866f795382c7c35 (patch)
treecb8ed42d0fed895c28b59395d52879648610f8e4
parent06fb01af83ca81b827bbdbddddb3a5f2ae9fdfcf (diff)
downloaduscxml-fbf5005a9f4d821ee04dff7c0866f795382c7c35.zip
uscxml-fbf5005a9f4d821ee04dff7c0866f795382c7c35.tar.gz
uscxml-fbf5005a9f4d821ee04dff7c0866f795382c7c35.tar.bz2
:Jira: ADSVHTNG-1233 - ramp command definition in c transformer
Change-Id: Iae04c8f7e3c2894f5a433906b224b50425e0acd0
-rwxr-xr-xsrc/uscxml/transform/ChartToC.cpp53
-rw-r--r--src/uscxml/util/TASCXMLUtils.h7
2 files changed, 60 insertions, 0 deletions
diff --git a/src/uscxml/transform/ChartToC.cpp b/src/uscxml/transform/ChartToC.cpp
index 31918ca..98e20de 100755
--- a/src/uscxml/transform/ChartToC.cpp
+++ b/src/uscxml/transform/ChartToC.cpp
@@ -717,6 +717,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << "typedef struct uscxml_elem_taresult uscxml_elem_taresult;" << std::endl;
stream << "typedef struct uscxml_elem_taset uscxml_elem_taset;" << std::endl;
stream << "typedef struct uscxml_elem_taget uscxml_elem_taget;" << std::endl;
+ stream << "typedef struct uscxml_elem_taramp uscxml_elem_taramp;" << std::endl;
stream << std::endl;
stream << "typedef void* (*dequeue_internal_t)(const uscxml_ctx* ctx);" << std::endl;
@@ -745,6 +746,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << "typedef int (*exec_content_taresult_t)(const uscxml_ctx* ctx, const uscxml_elem_taresult* taresult);" << std::endl;
stream << "typedef int (*exec_content_taset_t)(const uscxml_ctx* ctx, const uscxml_elem_taset* taset);" << std::endl;
stream << "typedef int (*exec_content_taget_t)(const uscxml_ctx* ctx, const uscxml_elem_taget* taget);" << std::endl;
+ stream << "typedef int (*exec_content_taramp_t)(const uscxml_ctx* ctx, const uscxml_elem_taramp* taramp);" << std::endl;
stream << std::endl;
stream << "/**" << std::endl;
@@ -929,6 +931,19 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << std::endl;
stream << "/**" << std::endl;
+ stream << " * All information pertaining to a <tascxml:ramp> element" << std::endl;
+ stream << " */" << std::endl;
+ stream << "struct uscxml_elem_taramp {" << std::endl;
+ stream << " const char* id;" << std::endl;
+ stream << " const char* dataid;" << std::endl;
+ stream << " const char* slope;" << std::endl;
+ stream << " const char* startexpr;" << std::endl;
+ stream << " const char* endcond;" << std::endl;
+ stream << " const char* duration;" << std::endl;
+ stream << "};" << std::endl;
+ stream << std::endl;
+
+ stream << "/**" << std::endl;
stream << " * Represents an instance of a state-chart at runtime/" << std::endl;
stream << " */" << std::endl;
stream << "struct uscxml_ctx {" << std::endl;
@@ -963,6 +978,7 @@ void ChartToC::writeTypes(std::ostream& stream) {
stream << " exec_content_taresult_t exec_content_taresult;" << std::endl;
stream << " exec_content_taset_t exec_content_taset;" << std::endl;
stream << " exec_content_taget_t exec_content_taget;" << std::endl;
+ stream << " exec_content_taramp_t exec_content_taramp;" << std::endl;
stream << std::endl;
stream << " invoke_t invoke;" << std::endl;
stream << "};" << std::endl;
@@ -1469,6 +1485,16 @@ void ChartToC::writeExecContent(std::ostream& stream, const DOMNode* node, size_
stream << padding << " return USCXML_ERR_MISSING_CALLBACK;" << std::endl;
stream << padding << "}" << std::endl;
+ } else if(TAGNAME(elem) == tascxml::NS_PREFIX.str() + "ramp") {
+ stream << padding;
+ stream << "if likely(ctx->exec_content_taramp != NULL) {" << std::endl;
+ stream << padding;
+ stream << " if ((ctx->exec_content_taramp(ctx, &" << _prefix << "_elem_taramps[" << ATTR(elem, X("documentOrder")) << "]";
+ stream << ")) != USCXML_ERR_OK) return err;" << std::endl;
+ stream << padding << "} else {" << std::endl;
+ stream << padding << " return USCXML_ERR_MISSING_CALLBACK;" << std::endl;
+ stream << padding << "}" << std::endl;
+
} else {
LOGD(USCXML_VERBATIM) << "writeExecContent unsupported element: '" << TAGNAME(elem) << "'" << std::endl << *elem << std::endl;
assert(false);
@@ -1906,6 +1932,33 @@ void ChartToC::writeElementInfo(std::ostream& stream) {
stream << std::endl;
}
+ std::list<DOMElement*> taramps = DOMUtils::inDocumentOrder({ tascxml::NS_PREFIX.str() + "ramp" }, _scxml);
+ if (taramps.size() > 0) {
+ _hasElement.insert("ramp");
+ stream << "static const uscxml_elem_taramp " << _prefix << "_elem_taramps[" << taramps.size() << "] = {" << std::endl;
+ size_t i = 0;
+ for (auto iter = taramps.begin(); iter != taramps.end(); iter++, i++) {
+ DOMElement* taramp = *iter;
+ stream << " { ";
+ stream << std::endl << " /* id */ ";
+ stream << (HAS_ATTR(taramp, tascxml::kXMLCharId) ? "\"" + escape(ATTR(taramp, tascxml::kXMLCharId)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* dataid */ ";
+ stream << (HAS_ATTR(taramp, tascxml::kXMLCharDataId) ? "\"" + escape(ATTR(taramp, tascxml::kXMLCharDataId)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* slope */ ";
+ stream << (HAS_ATTR(taramp, tascxml::kXMLCharSlope) ? "\"" + escape(ATTR(taramp, tascxml::kXMLCharSlope)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* startexpr */ ";
+ stream << (HAS_ATTR(taramp, tascxml::kXMLCharStartExpr) ? "\"" + escape(ATTR(taramp, tascxml::kXMLCharStartExpr)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* endcond */ ";
+ stream << (HAS_ATTR(taramp, tascxml::kXMLCharEndCond) ? "\"" + escape(ATTR(taramp, tascxml::kXMLCharEndCond)) + "\"" : "NULL") << ", ";
+ stream << std::endl << " /* duration */ ";
+ stream << (HAS_ATTR(taramp, tascxml::kXMLCharDuration) ? "\"" + escape(ATTR(taramp, tascxml::kXMLCharDuration)) + "\"" : "NULL");
+ stream << std::endl << " }" << (i + 1 < taramps.size() ? "," : "") << std::endl;
+ taramp->setAttribute(X("documentOrder"), X(toStr(i)));
+ }
+ stream << "};" << std::endl;
+ stream << std::endl;
+ }
+
std::list<DOMElement*> donedatas = DOMUtils::inDocumentOrder({ XML_PREFIX(_scxml).str() + "donedata" }, _scxml);
stream << "static const uscxml_elem_donedata " << _prefix << "_elem_donedatas[" << donedatas.size() + 1 << "] = {" << std::endl;
stream << " /* source, content, contentexpr, params */" << std::endl;
diff --git a/src/uscxml/util/TASCXMLUtils.h b/src/uscxml/util/TASCXMLUtils.h
index 4d34695..9e64876 100644
--- a/src/uscxml/util/TASCXMLUtils.h
+++ b/src/uscxml/util/TASCXMLUtils.h
@@ -17,10 +17,17 @@ namespace tascxml {
static const uscxml::X kXMLChaRequirementId = uscxml::X("requirementid");
static const uscxml::X kXMLCharCurrentVaue = uscxml::X("currentvalue");
+ static const uscxml::X kXMLCharId = uscxml::X("id");
static const uscxml::X kXMLCharDataId = uscxml::X("dataid");
+
static const uscxml::X kXMLCharValue = uscxml::X("value");
static const uscxml::X kXMLCharValueExpr = uscxml::X("valueexpr");
+ static const uscxml::X kXMLCharSlope = uscxml::X("slope");
+ static const uscxml::X kXMLCharStartExpr = uscxml::X("startexpr");
+ static const uscxml::X kXMLCharEndCond = uscxml::X("endcond");
+ static const uscxml::X kXMLCharDuration = uscxml::X("duration");
+
}
#endif