summaryrefslogtreecommitdiff
path: root/quellcode/demo1/Controller/CorbaHandler.cs
diff options
context:
space:
mode:
authorManuel Traut <manut@mecka.net>2014-03-31 16:53:55 +0200
committerManuel Traut <manut@mecka.net>2014-03-31 16:53:55 +0200
commit1adba473e6917b227e1b0a1118148101dca202e7 (patch)
tree13180ede9564ba50c528b274ee5719b4e030ef06 /quellcode/demo1/Controller/CorbaHandler.cs
parenteacbf5bb4d57af21c731f41251015d3b991ad490 (diff)
add quellcodeHEADmaster
Signed-off-by: Manuel Traut <manut@mecka.net>
Diffstat (limited to 'quellcode/demo1/Controller/CorbaHandler.cs')
-rwxr-xr-xquellcode/demo1/Controller/CorbaHandler.cs84
1 files changed, 84 insertions, 0 deletions
diff --git a/quellcode/demo1/Controller/CorbaHandler.cs b/quellcode/demo1/Controller/CorbaHandler.cs
new file mode 100755
index 0000000..e705b7f
--- /dev/null
+++ b/quellcode/demo1/Controller/CorbaHandler.cs
@@ -0,0 +1,84 @@
+using System;
+using System.IO;
+using System.Runtime.Remoting;
+using System.Runtime.Remoting.Channels;
+// from IIOPChannel.dll
+using Ch.Elca.Iiop;
+using Ch.Elca.Iiop.Services;
+using omg.org.CosNaming;
+// from ExecutorI.dll
+using manut.Executor;
+namespace manut.Executor {
+ public class CorbaHandler {
+ // remote object
+ private manut.Executor.ExecCmd servant;
+ private IiopChannel chan2;
+ private CorbaInit init2;
+ private MainWindow window;
+ private string host;
+ private int port;
+ public CorbaHandler() {
+ host = "192.168.0.253";
+ port = 2809;
+ connect();
+ }
+ public CorbaHandler(string _host, int _port, MainWindow _window) {
+ host = _host;
+ port = _port;
+ window = _window;
+ }
+ public void serve(){
+ try {
+ // Host Servant
+ chan2 = new IiopChannel(0);
+ ChannelServices.RegisterChannel(chan2);
+ init2 = CorbaInit.GetInit();
+ NamingContext nameService2 = init2.GetNameService(host, port);
+ NameComponent[] moduleName2 = new NameComponent[] {new NameComponent("manut.Controller", "")};
+ NamingContext nameSpace2 = (NamingContext)nameService2.bind_new_context(moduleName2);
+ NameComponent[] interfaceName2 = new NameComponent[] {new NameComponent("Disp", "")};
+ manut.Controller.Disp interfaceImpl = new manut.Controller.Disp(window);
+ Console.WriteLine("4");
+ nameSpace2.bind(interfaceName2, interfaceImpl);
+ Console.WriteLine("DisplayServer ready");
+ } catch (Exception e) {
+ Console.WriteLine(e);
+ }
+ }
+ public void connect() {
+ try{
+ // Connect to Executer
+ // Access the COS naming service (NameService)...
+ NamingContext nameService = init2.GetNameService(host, port);
+ // Access the IDL-defined module
+ // (which maps to a .Net namespace)...
+ NameComponent[] moduleName = new NameComponent[] {new NameComponent("Executor", "")};
+ NamingContext nameSpace = (NamingContext)nameService.resolve(moduleName);
+ Console.Write("Executor ok, ");
+ // Access the IDL-defined interface
+ // (which maps to a .NET interface class)
+ NameComponent[] interfaceName = new NameComponent[] {new NameComponent("ExecCmd", "")};
+ this.servant = (manut.Executor.ExecCmd)nameSpace.resolve(interfaceName);
+ Console.Write("ExecCmd ok\n\nTesting... ");
+ this.servant.changeMode(2);
+ Console.Write("ok\n\n");
+ } catch (Exception e) {
+ Console.WriteLine(e);
+ }
+ }
+ public bool setPorts(short one, short two, short three) {
+ return this.servant.setPorts(one, two, three);
+ }
+ public bool setMode(short mode) {
+ try {
+ return this.servant.changeMode(mode);
+ } catch(Exception e) {
+ Console.WriteLine("setMode Exception: "+e);
+ return false;
+ }
+ }
+ public void display(string txt) {
+ window.display(txt);
+ }
+ }
+}