diff options
author | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-26 21:37:03 (GMT) |
---|---|---|
committer | Stefan Radomski <radomski@tk.informatik.tu-darmstadt.de> | 2014-06-26 21:37:03 (GMT) |
commit | a4b506fd774ec50ad79b7531bd3698c5a6339407 (patch) | |
tree | 5e524b2c91e97f1037818e0262616f74e5e628a4 /embedding/csharp | |
parent | fe84b93d3e80d4b03e7a401582654c84d7fa7d9a (diff) | |
download | uscxml-a4b506fd774ec50ad79b7531bd3698c5a6339407.zip uscxml-a4b506fd774ec50ad79b7531bd3698c5a6339407.tar.gz uscxml-a4b506fd774ec50ad79b7531bd3698c5a6339407.tar.bz2 |
More work on language bindings and C# examples
Diffstat (limited to 'embedding/csharp')
-rw-r--r-- | embedding/csharp/embedding/embedding.suo | bin | 15872 -> 33280 bytes | |||
-rw-r--r-- | embedding/csharp/embedding/embedding/Program.cs | 9 | ||||
-rw-r--r-- | embedding/csharp/embedding/embedding/TestDataModel.cs | 92 | ||||
-rw-r--r-- | embedding/csharp/embedding/embedding/TestExecutableContent.cs | 33 | ||||
-rw-r--r-- | embedding/csharp/embedding/embedding/TestIOProc.cs | 28 | ||||
-rw-r--r-- | embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs | 31 | ||||
-rw-r--r-- | embedding/csharp/embedding/embedding/TestInvoker.cs | 32 | ||||
-rw-r--r-- | embedding/csharp/embedding/embedding/embedding.csproj | 10 |
8 files changed, 229 insertions, 6 deletions
diff --git a/embedding/csharp/embedding/embedding.suo b/embedding/csharp/embedding/embedding.suo Binary files differindex f011087..3c8cd31 100644 --- a/embedding/csharp/embedding/embedding.suo +++ b/embedding/csharp/embedding/embedding.suo diff --git a/embedding/csharp/embedding/embedding/Program.cs b/embedding/csharp/embedding/embedding/Program.cs index 3899178..3b5a28c 100644 --- a/embedding/csharp/embedding/embedding/Program.cs +++ b/embedding/csharp/embedding/embedding/Program.cs @@ -17,18 +17,19 @@ namespace embedding {
/*
- * Make sure this path contains the umundoNativeCSharp.dll!
+ * Make sure this path contains the uscxmlNativeCSharp.dll!
*/
if (System.Environment.Is64BitProcess)
{
- SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\lib\\csharp64");
+ SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml64\\lib\\csharp");
}
else
{
- SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\lib\\csharp");
+ SetDllDirectory("C:\\Users\\sradomski\\Desktop\\build\\uscxml\\lib\\csharp");
}
- Interpreter interpreter = Interpreter.fromXML("<scxml><state id=\"foo\"/></scxml>");
+ Interpreter interpreter = Interpreter.fromXML("<scxml><state id=\"foo\" final=\"true\" /></scxml>");
+ interpreter.addMonitor(new TestInterpreterMonitor());
interpreter.interpret();
}
}
diff --git a/embedding/csharp/embedding/embedding/TestDataModel.cs b/embedding/csharp/embedding/embedding/TestDataModel.cs new file mode 100644 index 0000000..bfcfd30 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestDataModel.cs @@ -0,0 +1,92 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace EmbeddedDataModel
+{
+ class TestDataModel : DataModel
+ {
+ public override DataModel create(Interpreter interpreter)
+ {
+ return new TestDataModel();
+ }
+
+ public override void eval(string scriptElem, string expr)
+ {
+ // evaluate expr on the datamodel
+ }
+
+ public override bool evalAsBool(string elem, string content)
+ {
+ return evalAsBool(content);
+ }
+
+ public override bool evalAsBool(string expr)
+ {
+ // evaluate expr as bool
+ return false;
+ }
+
+ public override void assign(string assignElem, string location, string content)
+ {
+ // set variable at location to content
+ }
+
+ public override string evalAsString(string expr)
+ {
+ // evaluate given expr as a string (e.g. for <log>)
+ return "";
+ }
+
+ public override uint getLength(string expr)
+ {
+ // return the length of an expression for foreach
+ return 0;
+ }
+
+ public override StringList getNames()
+ {
+ // name of this datamodel to be used in scxml element
+ StringList names = new StringList();
+ names.add("simple");
+ return names;
+ }
+
+ public override DataNative getStringAsData(string content)
+ {
+ // DataNative ought to be wrapped by a Data.cs class - used to carry JSONesque structures
+ DataNative data = new DataNative();
+ return data;
+ }
+
+ public override void init(string dataElem, string location, string content)
+ {
+ // initialize variable at location to evaluated content - used for scxml data elements
+ }
+
+ public override void setEvent(Event arg0)
+ {
+ // represent given event as _event in datamodel
+ }
+
+ public override bool isDeclared(string expr)
+ {
+ // using an undeclared variable is an error.execution with some scxml constructs -
+ // determine whether the given expression is defined
+ return true;
+ }
+
+ public override void setForeach(string item, string array, string index, uint iteration)
+ {
+ // called per foreach iteration, set datamodel variables accordingly
+ }
+
+ public override bool validate(string location, string schema)
+ {
+ // primarily intended for xpath datamodel
+ return true;
+ }
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestExecutableContent.cs b/embedding/csharp/embedding/embedding/TestExecutableContent.cs new file mode 100644 index 0000000..199445b --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestExecutableContent.cs @@ -0,0 +1,33 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace embedding
+{
+ class TestExecutableContent : ExecutableContent
+ {
+ public override string getLocalName()
+ {
+ return "custom";
+ }
+
+ public override void enterElement(string node)
+ {
+
+ }
+
+ public override void exitElement(string node)
+ {
+
+ }
+
+ public override ExecutableContent create(Interpreter interpreter)
+ {
+ return new TestExecutableContent();
+ }
+
+
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestIOProc.cs b/embedding/csharp/embedding/embedding/TestIOProc.cs new file mode 100644 index 0000000..1c00034 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestIOProc.cs @@ -0,0 +1,28 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace embedding
+{
+ class TestIOProc : IOProcessor
+ {
+ public override DataNative getDataModelVariables()
+ {
+ DataNative data = new DataNative();
+ return data;
+ }
+
+ public override StringList getNames()
+ {
+ StringList names = new StringList();
+ names.add("simple");
+ return names;
+ }
+
+ public override void send(SendRequest req)
+ {
+ }
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs b/embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs new file mode 100644 index 0000000..03eb9d6 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestInterpreterMonitor.cs @@ -0,0 +1,31 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace embedding
+{
+ class TestInterpreterMonitor : InterpreterMonitor
+ {
+ public override void afterCompletion(Interpreter interpreter) { }
+ public override void afterMicroStep(Interpreter interpreter) { }
+ public override void beforeCompletion(Interpreter interpreter) { }
+ public override void beforeMicroStep(Interpreter interpreter) { }
+ public override void beforeProcessingEvent(Interpreter interpreter, Event arg1) { }
+ public override void onStableConfiguration(Interpreter interpreter) { }
+ public override void afterEnteringState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void afterExecutingContent(Interpreter interpreter, string tagName, string xpath, string element) { }
+ public override void afterExitingState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void afterInvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+ public override void afterTakingTransition(Interpreter interpreter, string xpath, string source, StringList targets, string element, bool moreComing) { }
+ public override void afterUninvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+ public override void beforeEnteringState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void beforeExecutingContent(Interpreter interpreter, string tagName, string xpath, string element) { }
+ public override void beforeExitingState(Interpreter interpreter, string stateId, string xpath, string state, bool moreComing) { }
+ public override void beforeInvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+ public override void beforeTakingTransition(Interpreter interpreter, string xpath, string source, StringList targets, string element, bool moreComing) { }
+ public override void beforeUninvoking(Interpreter interpreter, string xpath, string invokeid, string element) { }
+
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/TestInvoker.cs b/embedding/csharp/embedding/embedding/TestInvoker.cs new file mode 100644 index 0000000..11493d3 --- /dev/null +++ b/embedding/csharp/embedding/embedding/TestInvoker.cs @@ -0,0 +1,32 @@ +using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using org.uscxml;
+
+namespace EmbeddedInvoker
+{
+ class TestInvoker : Invoker
+ {
+ public override DataNative getDataModelVariables()
+ {
+ DataNative data = new DataNative();
+ return data;
+ }
+
+ public override StringList getNames()
+ {
+ StringList names = new StringList();
+ names.add("simple");
+ return names;
+ }
+
+ public override void invoke(InvokeRequest req)
+ {
+ }
+
+ public override void send(SendRequest req)
+ {
+ }
+ }
+}
diff --git a/embedding/csharp/embedding/embedding/embedding.csproj b/embedding/csharp/embedding/embedding/embedding.csproj index 53e1eed..ca54bd4 100644 --- a/embedding/csharp/embedding/embedding/embedding.csproj +++ b/embedding/csharp/embedding/embedding/embedding.csproj @@ -47,13 +47,19 @@ <Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
- <Reference Include="uscxmlCSharp">
- <HintPath>..\..\..\..\build\cli\lib\uscxmlCSharp.dll</HintPath>
+ <Reference Include="uscxmlCSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
+ <SpecificVersion>False</SpecificVersion>
+ <HintPath>C:\Users\sradomski\Desktop\build\uscxml\lib\uscxmlCSharp.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
+ <Compile Include="TestExecutableContent.cs" />
+ <Compile Include="TestInterpreterMonitor.cs" />
+ <Compile Include="TestIOProc.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="TestDataModel.cs" />
+ <Compile Include="TestInvoker.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
|