public static void Main(string[] args) { //Create instance of RCL class which handles functions from rcl.h RCL rcl = new RCL(); //Initialise RCL with default allocator rcl.Init(args); //Create an executor that will task our node Executor demoExecutor = new SingleThreadedExecutor(); //Let the executor task all nodes with the given timespan demoExecutor.Spin(new TimeSpan(0, 0, 0, 0, 10)); //Create a Node Node testNode = new Node("BasicNodeExample"); //Add node to executor demoExecutor.AddNode(testNode); //Do some fancy stuff //Dispose the node so there won't be any unmanaged resources testNode.Dispose(); //Remember to stop the executor - you could start it again afterwards demoExecutor.Cancel(); //Dispose the rcl object - this will call rcl_shutdown rcl.Dispose(); }
public static void Main(string[] args) { //Create instance of RCL class which handles functions from rcl.h //RCL implements IDisposable so the using statement makes sure rcl_shutdown will be called after usages using (RCL rcl = new RCL()) { //Initialise RCL with default allocator rcl.Init(args); Console.WriteLine("RCL Init was successfull"); //Create an executor that will task our node using (Executor demoExecutor = new SingleThreadedExecutor()) { //Let the executor task all nodes with the given timespan demoExecutor.Spin(new TimeSpan(0, 0, 0, 0, 10)); //Create a Node using (Node testNode = new Node("BasicNodeExample")) { Console.WriteLine("Creation of node was successfull"); //Add node to executor demoExecutor.AddNode(testNode); //Now do some fancy stuff //Keeps app from closing instantly Console.ReadKey(); } Console.WriteLine("Disposed node"); } } //rcl_shutdown gets called automatically }
public void BindContext <T>(string key, T obj) { if (contextDictionary.ContainsKey(key)) { Waring($"[{RCL.Wrap("Context", ConsoleColor.Cyan)}] '{key}' is already defined."); return; } contextDictionary.Add(key, obj); jsEngine.SetValue(key, obj); if (typeof(T) == typeof(Action <string>)) { this.BindDelegate((Action <string>)(object) obj, key); } if (typeof(T) == typeof(Action <int>)) { this.BindDelegate((Action <int>)(object) obj, key); } if (typeof(T) == typeof(Action <bool>)) { this.BindDelegate((Action <bool>)(object) obj, key); } if (typeof(T) == typeof(Action <object>)) { this.BindDelegate((Action <object>)(object) obj, key); } if (typeof(T) == typeof(Action <byte>)) { this.BindDelegate((Action <byte>)(object) obj, key); } }
public void Start() { var sq = (Func <object, Task <object> >)(async(i) => { Terminal.WriteLine($"[{RCL.Wrap("Core", ConsoleColor.DarkMagenta)}]: result:{i}!"); return(null); }); var qwe0 = EngineVM.Execute( @"return function(data, callback) { Log('sqe0 execute!'); exports.nure = 1; data(exports.nure++, true); callback(null, null); } "); var qwe1 = EngineVM.Execute(@" return function(data, callback) { Log('sqe1 execute!'); data(exports.nure++, true); callback(null, null); } "); qwe0(sq).Wait(); qwe1(sq).Wait(); qwe1(sq).Wait(); qwe1(sq).Wait(); qwe1(sq).Wait(); var func = EngineVM.Execute(@" let ts = require('typescript'); let TCSResult = ''; let compilerOptions = { module: ts.ModuleKind.None, removeComments: true }; return function(data, callback) { TCSResult = ts.transpile(data, compilerOptions, undefined, undefined,'FlameScript'); callback(null, TCSResult); } "); string tsc = (string)func(File.ReadAllText(mainTS)).Result; //try //{ // jsEngine.Execute(tsc); // jsEngine.Execute("YRes = Dummy.TestClass.testMethod2();"); // //jsEngine.Execute("TCSResult = TypeScript.compile(TSSource, null, function(e) { VMError(e); });"); //} //catch (JavaScriptException e) //{ // e.Print(); //} }
public static string ToRCLString(this Exception e) { string ex = e.ToString(); ex = types.Aggregate(ex, (current, s) => current.Replace(s, RCL.Wrap(s, ConsoleColor.DarkGreen))); ex = typesEnum.Aggregate(ex, (current, s) => current.Replace(s, RCL.Wrap(s, ConsoleColor.DarkYellow))); ex = typesNameSpace.Aggregate(ex, (current, s) => current.Replace(s, RCL.Wrap(s, ConsoleColor.Gray))); return(ex); }
public static void Print(this JavaScriptException e) { Terminal.WriteLine($"+==============================================+"); Terminal.WriteLine($"+=| {RCL.Wrap("JavaScript Exception", ConsoleColor.DarkRed)}"); Terminal.WriteLine($"+=| Column :{e.Column}"); Terminal.WriteLine($"+=| Location :{e.Location}"); Terminal.WriteLine($"+=| Line :{e.LineNumber}"); Terminal.WriteLine($"+=| Error :{e.Error}"); Terminal.WriteLine($"+=| Exception:{e.Message}"); Terminal.WriteLine($"+==============================================+"); }
public static void Main(string[] args) { //Create instance of RCL class which handles functions from rcl.h //RCL implements IDisposable so the using statement makes sure rcl_shutdown will be called after usages using (RCL rcl = new RCL()) { //Initialise RCL with default allocator rcl.Init(args); Console.WriteLine("RCL init was successfull - Press any key to exit"); Console.ReadKey(); } //rcl_shutdown gets called automatically Console.WriteLine("If you can read this exit was successfull "); }
public static int Main(string[] args) { Console.Title = "builder"; try { Assembler.Asm(); } catch (Exception e) { Assembler.Error($"{RCL.Wrap("!!!", ConsoleColor.Red)} CATCHING EXCEPTION WARIOUT {RCL.Wrap("!!!", ConsoleColor.Red)}"); Assembler.Error(e.ToRCLString()); Assembler.Error($"{RCL.Wrap("!!!", ConsoleColor.Red)} STOP {RCL.Wrap("!!!", ConsoleColor.Red)}"); Console.ReadKey(); return(-1); } return(1); }
public static void Main(string[] args) { //Create instance of RCL class which handles functions from rcl.h //RCL implements IDisposable so the using statement makes sure rcl_shutdown will be called after usages using (RCL rcl = new RCL()) { //Initialise RCL with default allocator rcl.Init(args); //Create an executor that will task our node Executor demoExecutor = new SingleThreadedExecutor(); //Let the executor task all nodes with the given timespan demoExecutor.Spin(new TimeSpan(0, 0, 0, 0, 10)); //Create a Node using (Node testNode = new Node("BasicNodeExample")) { //Add node to executor demoExecutor.AddNode(testNode); //Now we're creating a publisher with the Dummy message //TODO show alternative to Node.CreatePublisher<T> using (Publisher <cs_msgs.msg.Dummy> testPublisher = testNode.CreatePublisher <cs_msgs.msg.Dummy> ("TestTopic")) { //Create a message using (cs_msgs.msg.Dummy testMsg = new cs_msgs.msg.Dummy()) { //Fill the message fields testMsg.thisafloat32 = 0.4f; //Fill a string testMsg.thisisastring = "TestString"; //Fill an array testMsg.thisafloat32array = (new float[] { 1.3f, 100000.4f }); //Use a nested type testMsg.thisisatime.sec = 100; //And now publish the message testPublisher.Publish(testMsg); //Free unmanaged memory } } } //Remember to stop the executor - you could start it again afterwards demoExecutor.Cancel(); } //rcl_shutdown gets called automatically }
public static void Main(string[] args) { //Create instance of RCL class which handles functions from rcl.h //RCL implements IDisposable so the using statement makes sure rcl_shutdown will be called after usages using (RCL rcl = new RCL()) { //Initialise RCL with default allocator rcl.Init(args); Console.WriteLine("RCL Init was successfull"); //Create an executor that will task our node using (Executor demoExecutor = new SingleThreadedExecutor()) { //Let the executor task all nodes with the given timespan demoExecutor.Spin(new TimeSpan(0, 0, 0, 0, 10)); //Create a Node using (Node testNode = new Node("BasicNodeExample")) { Console.WriteLine("Creation of node was successfull"); //Add node to executor demoExecutor.AddNode(testNode); using (Client <cs_msgs.srv.DummySrv_Request, cs_msgs.srv.DummySrv_Response> DummyClient = new Client <cs_msgs.srv.DummySrv_Request, cs_msgs.srv.DummySrv_Response> (testNode, "TestService")) { DummyClient.RecievedResponse += (object sender, ClientRecievedResponseEventArgs <cs_msgs.srv.DummySrv_Response> e) => { Console.WriteLine("Dummy client recieved response"); }; using (cs_msgs.srv.DummySrv_Request testRequest = new cs_msgs.srv.DummySrv_Request()) { testRequest.a = 10; testRequest.b = 100; DummyClient.SendRequest(testRequest); } } //Keeps app from closing instantly Console.ReadKey(); } Console.WriteLine("Disposed node"); } } //rcl_shutdown gets called automatically }
public static void Main(string[] args) { //Create instance of RCL class which handles functions from rcl.h //RCL implements IDisposable so the using statement makes sure rcl_shutdown will be called after usages using (RCL rcl = new RCL()) { //Initialise RCL with default allocator rcl.Init(args); //Create an executor that will task our node Executor demoExecutor = new SingleThreadedExecutor(); //Let the executor task all nodes with the given timespan demoExecutor.Spin(new TimeSpan(0, 0, 0, 0, 10)); //Create a Node using (Node testNode = new Node("BasicNodeExample")) { //Add node to executor demoExecutor.AddNode(testNode); //Create subscription on TestTopic using (Subscription <cs_msgs.msg.Dummy> testSub = testNode.CreateSubscription <cs_msgs.msg.Dummy> ("TestTopic")) { //Register on MessageRecieved event testSub.MessageRecieved += (object sender, MessageRecievedEventArgs <cs_msgs.msg.Dummy> e) => { //Simply print all message items foreach (var item in e.Message.GetType().GetFields()) { Console.Write(item.Name + " :" + item.GetValue(e.Message)); Console.WriteLine(); } }; //Call readkey so the program won't close instantly Console.ReadKey(); } } //Remember to stop the executor - you could start it again afterwards demoExecutor.Cancel(); } //rcl_shutdown gets called automatically }
private void RC(bool EXV = false) { try { ROL.Refresh(); if (ROL.Items.Count > 0) { ROL.Items.Clear(); } RCL.Refresh(); if (RCL.Items.Count > 0) { RCL.Items.Clear(); } } catch (Exception EX) { if (EXV) { MessageBox.Show(EX.Message + "\n\n" + EX.StackTrace + "\n\n" + EX.Data); } } }
public void tMain(string[] args) { Console.OutputEncoding = Encoding.UTF8; RCL.EnablingVirtualTerminalProcessing(); Screen.Title = "KeyGen"; Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Version SuperChanger: "); Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Business - 3 "); Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Individual Pro - 4 "); Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Individual - 5 "); var Type = TypeProduct.AxTools; TR_0: Screen.Write($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Enter type of product :>"); if (int.TryParse(Console.ReadLine(), out var i)) { if (!(i >= 0 && i <= 5)) { Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Product type is incorrect!"); goto TR_0; } } else { Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Product type is not a number!"); goto TR_0; } // var TypeLic = i; var coding = Encoding.UTF8; // var ad = new ProfileLicense(); ad.ID = $"AxTools License ID Code"; switch (TypeLic) { case 0: case 1: case 2: Type = TypeProduct.AxTools; break; case 3: case 4: case 5: Type = TypeProduct.SuperChanger; break; } Screen.Title = "KeyGen " + Type; TR_1: Screen.Write($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Enter your name :>"); var name = Console.ReadLine(); if (name.Length > 20) { Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Your name is too long!"); goto TR_1; } Screen.Write($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Enter your surname :>"); var family = Console.ReadLine(); if (family.Length > 20) { Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] Your surname is too long!"); goto TR_1; } if (Type == TypeProduct.AxTools) { ad.LName = $"{name} {family}{new string('~', 50 - (name.Length + family.Length + 1))}"; } else { ad.LName = $"{name} {family}"; ad.EDate = DateTime.Now.AddYears(50); } var key = ""; switch (TypeLic) { case 0: case 1: case 2: key = LicenseDecryptor.Encrypt(TypeLic, ad); break; case 5: key = LicenseDecryptor.EncryptNew(SuperChangeLicenseType.Business, ad); break; case 4: key = LicenseDecryptor.EncryptNew(SuperChangeLicenseType.ProInv, ad); break; case 3: key = LicenseDecryptor.EncryptNew(SuperChangeLicenseType.Inv, ad); break; } Clipboard.SetText(key); Screen.WriteLine($"[{RCL.Wrap("KeyGen", Color.DarkOrchid)}] The key will be copied to the clipboard."); var qqq = new Licenser().Update(key); Screen.WriteLine(""); Screen.WriteLine(""); if (Type == TypeProduct.AxTools) { var profile = new AlhoritmAxTools(TypeLic).StrToAd(key); if (profile != null) { Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Is key correct: {RCL.Wrap(true, Color.CadetBlue)}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License type: {Type}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License identifier: {profile.ID}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Name of the license owner: {profile.LName}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Count: {profile.SCount}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License end date: {profile.EDate}"); } else { Screen.WriteLine($"Верен ли ключ: {RCL.Wrap(false, Color.CadetBlue)}"); } } else { var profile = ad; Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Is key correct: {RCL.Wrap(true, Color.CadetBlue)}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License type: {Type}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License identifier: {profile.ID}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] Name of the license owner: {profile.LName}"); Screen.WriteLine($"[{RCL.Wrap("License", Color.Red)}] License end date: {profile.EDate}"); } Console.ReadKey(); }
public static void Main(string[] args) { Console.WriteLine("Init RCL"); using (RCL rcl = new RCL()) { rcl.Init(args); Console.WriteLine("Creating node"); using (Node test_node = new Node("test_node")) { Console.WriteLine("Creating test publisher"); using (Publisher <cs_msgs.msg.Dummy> test_pub = new Publisher <cs_msgs.msg.Dummy> (test_node, "TestTopic", rmw_qos_profile_t.rmw_qos_profile_sensor_data)) { Console.WriteLine("Creating test subscription"); Subscription <cs_msgs.msg.Dummy> test_subscription = test_node.CreateSubscription <cs_msgs.msg.Dummy> ("TestTopic", rmw_qos_profile_t.rmw_qos_profile_sensor_data); test_subscription.MessageRecieved += (object sender, MessageRecievedEventArgs <cs_msgs.msg.Dummy> e) => { Console.WriteLine("Recieved message on test topic: "); foreach (var item in e.Message.GetType().GetProperties()) { Console.Write(item.Name + " :" + item.GetValue(e.Message)); Console.WriteLine(); } Console.Write("Float32 Array: "); foreach (var arritem in e.Message.thisafloat32array) { Console.Write(arritem + " ,"); } Console.WriteLine(); Console.Write("Double Array: "); foreach (var arritem in e.Message.thisisfloat64array) { Console.Write(arritem + " ,"); } Console.WriteLine(); Console.Write("int8 Array: "); foreach (var arritem in e.Message.thisisaint8array) { Console.Write(arritem + " ,"); } Console.WriteLine(); Console.Write("string Array: "); foreach (var arritem in e.Message.thisisastringarray) { Console.WriteLine(arritem + " ,"); } Console.WriteLine(); Console.Write("fixed Array: "); foreach (var arritem in e.Message.thisisafixedint16array) { Console.WriteLine(arritem + " ,"); } Console.WriteLine(); Console.WriteLine("Seconds: " + e.Message.thisisatime.sec); }; Console.WriteLine("Creating executor"); Executor executor = new SingleThreadedExecutor(); executor.AddNode(test_node); Console.WriteLine("Spinning"); executor.Spin(new TimeSpan(0, 0, 0, 0, 10)); Console.WriteLine("Creating new test_msgs.Dummy"); using (cs_msgs.msg.Dummy test_msg = new cs_msgs.msg.Dummy()) { test_msg.thisiauint8 = 10; test_msg.thisisabool = 1; test_msg.thisisaint16 = 15; test_msg.thisisfloat64 = 10.0f; test_msg.thisisastring = "test_test_test"; test_msg.thisisanotherstring = "test2"; test_msg.thisafloat32array = new float[] { 10.0f, 1.1f }; test_msg.thisisafixedint16array = new short[] { 10, 100, 5 }; test_msg.thisisastringarray = (new string[] { "test1", "test2", "test3" }); test_msg.thisisaint8array = (new byte[] { 100, 102, 200 }); test_msg.thisisfloat64array = new double[] { 10.4, 100.1, 100.10 }; test_msg.thisisatime.sec = 10; Console.WriteLine("Test seconds: " + test_msg.thisisatime.sec); Console.WriteLine("Test_2 seconds: " + test_msg.Data.thisisatime.sec); Console.WriteLine("Publishing message"); if (test_pub.Publish(test_msg)) { Console.WriteLine("Publish was successfull"); } } /*Console.WriteLine ("####################################################"); * Console.WriteLine ("Creating service"); * Service<test_msgs.srv.DummySrv_Request,test_msgs.srv.DummySrv_Response> test_service = test_node.CreateService<test_msgs.srv.DummySrv_Request,test_msgs.srv.DummySrv_Response> ("TestService"); * test_service.RequestRecieved += (object sender, ServiceRecievedRequestEventArgs<test_msgs.srv.DummySrv_Request,test_msgs.srv.DummySrv_Response> e) => { * Console.WriteLine ("Recieved new request"); * using(test_msgs.srv.DummySrv_Response response = new test_msgs.srv.DummySrv_Response()) * { * response.sum = e.Request.a + e.Request.b; * e.SendResponseFunc(response); * } * * }; * Client<test_msgs.srv.DummySrv_Request,test_msgs.srv.DummySrv_Response> test_client = test_node.CreateClient<test_msgs.srv.DummySrv_Request,test_msgs.srv.DummySrv_Response> ("TestService"); * test_client.RecievedResponse += (object sender, ClientRecievedResponseEventArgs<test_msgs.srv.DummySrv_Response> e) => { * Console.WriteLine ("Client recived response : sum: " + e.Response.sum); * }; * using (test_msgs.srv.DummySrv_Request testRequest = new test_msgs.srv.DummySrv_Request ()) { * testRequest.a = 10; * testRequest.b = 100; * test_client.SendRequest (testRequest); * }*/ Console.WriteLine("Press any key to exit"); Console.ReadKey(); executor.Cancel(); } } } }
public static void VMFlameInternalFatalLog(string s) { Terminal.WriteLine($"{Header}[{RCL.Wrap("INF", ConsoleColor.Gray)}]: {s}"); }
public static void VMVMInfo(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("INF", ConsoleColor.Gray) }]: {s}");
public static void VMWaring(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("WAR", ConsoleColor.DarkYellow)}]: {s}");
public static void VMError(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("ERR", ConsoleColor.DarkRed) }]: {s}");
public static void VMLog(string s) => Terminal.WriteLine($"{Header}[{RCL.Wrap("LOG", ConsoleColor.DarkGray) }]: {s}");
/// <summary> /// Colored string [RCL] /// </summary> public static string To(this string s, Color c) => RCL.Wrap(s, c);
public static void Waring(string s) { Terminal.WriteLine($"[{RCL.Wrap("asm", ConsoleColor.DarkMagenta)}][{RCL.Wrap("WAR", ConsoleColor.DarkYellow)}]: {s}"); }
public static void Error(string s) { Terminal.WriteLine($"[{RCL.Wrap("asm", ConsoleColor.DarkMagenta)}][{RCL.Wrap("ERR", ConsoleColor.DarkRed)}]: {s}"); }
public static void Log(string s) { Terminal.WriteLine($"[{RCL.Wrap("asm", ConsoleColor.DarkMagenta)}][{RCL.Wrap("LOG", ConsoleColor.DarkGray)}]: {s}"); }