summaryrefslogtreecommitdiff
path: root/workflow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'workflow.cpp')
-rw-r--r--workflow.cpp73
1 files changed, 55 insertions, 18 deletions
diff --git a/workflow.cpp b/workflow.cpp
index 63066baa..9edb6ea6 100644
--- a/workflow.cpp
+++ b/workflow.cpp
@@ -110,23 +110,12 @@ bool AnalysisContext::Inform(const string& request)
}
-WorkflowMachine::WorkflowMachine(Ref<BinaryView> view): m_view(view)
-{
-
-}
-
-
-WorkflowMachine::WorkflowMachine(Ref<Function> function): m_function(function)
-{
-
-}
-
-
-bool WorkflowMachine::Enable()
+bool WorkflowMachine::PostRequest(const std::string& command)
{
rapidjson::Document request(rapidjson::kObjectType);
rapidjson::Document::AllocatorType& allocator = request.GetAllocator();
- request.AddMember("command", "enable", allocator);
+ rapidjson::Value commandValue(command.c_str(), command.size(), allocator);
+ request.AddMember("command", commandValue, allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
request.Accept(writer);
@@ -146,11 +135,59 @@ bool WorkflowMachine::Enable()
}
+WorkflowMachine::WorkflowMachine(Ref<BinaryView> view): m_view(view)
+{
+
+}
+
+
+WorkflowMachine::WorkflowMachine(Ref<Function> function): m_function(function)
+{
+
+}
+
+
+bool WorkflowMachine::Run()
+{
+ return PostRequest("run");
+}
+
+
+bool WorkflowMachine::Halt()
+{
+ return PostRequest("halt");
+}
+
+
+bool WorkflowMachine::Reset()
+{
+ return PostRequest("reset");
+}
+
+
+bool WorkflowMachine::Enable()
+{
+ return PostRequest("enable");
+}
+
+
bool WorkflowMachine::Disable()
{
+ return PostRequest("disable");
+}
+
+
+bool WorkflowMachine::Step()
+{
+ return PostRequest("step");
+}
+
+
+string WorkflowMachine::GetState()
+{
rapidjson::Document request(rapidjson::kObjectType);
rapidjson::Document::AllocatorType& allocator = request.GetAllocator();
- request.AddMember("command", "disable", allocator);
+ request.AddMember("command", "status", allocator);
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
request.Accept(writer);
@@ -163,10 +200,10 @@ bool WorkflowMachine::Disable()
rapidjson::Document response(rapidjson::kObjectType);
response.Parse(jsonResult.c_str());
- if (response.HasMember("commandStatus") && response["commandStatus"].HasMember("accepted"))
- return response["commandStatus"]["accepted"].GetBool();
+ if (response.HasMember("machineState") && response["machineState"].HasMember("state"))
+ return response["machineState"]["state"].GetString();
- return false;
+ return "Invalid";
}