public override void Start() { logger.Log("Started: {0}", ToString()); string dummyDeviceId = moduleInfo.Args()[0]; serialPortNameforArudino = moduleInfo.Args()[1]; //.... Open the serial port - AJB TODO - error checking on port name serialPortOpen = OpenSerialPort(); //.................instantiate the port VPortInfo portInfo = GetPortInfoFromPlatform("arduino-" + dummyDeviceId); dummyPort = InitPort(portInfo); // ..... initialize the list of roles we are going to export and bind to the role List<VRole> listRole = new List<VRole>() { RoleDummy.Instance}; BindRoles(dummyPort, listRole); //.................register the port after the binding is complete RegisterPortWithPlatform(dummyPort); workThread = new SafeThread(delegate() { Work(); } , "ArduinoDriverDummy work thread" , logger); workThread.Start(); imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger); }
public override void Start() { logger.Log("Started: {0}", ToString()); string airConditionCtrlDevice = moduleInfo.Args()[0]; //.................instantiate the port VPortInfo portInfo = GetPortInfoFromPlatform(airConditionCtrlDevice); airConditionCtrlPort = InitPort(portInfo); // ..... initialize the list of roles we are going to export and bind to the role List<VRole> listRole = new List<VRole>() { RoleSwitchMultiLevel.Instance }; BindRoles(airConditionCtrlPort, listRole); //.................register the port after the binding is complete RegisterPortWithPlatform(airConditionCtrlPort); workThread = new SafeThread(delegate() { Work(); }, "DriverAirConditionCtrl work thread", logger); workThread.Start(); imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger); gm.ComPort = "COM6"; gm.BaudRate = 9600; gm.Open(); gm.SmsRecieved+=new EventHandler(gm_SmsRecieved); }
protected override void DoTraverse(Port rootPort, IScanVisitor visitor, bool ignoreHold) { List<Guid> signals = new List<Guid>(); List<Guid> ports = new List<Guid>(); List<Guid> buses = new List<Guid>(); TraversePort(signals, ports, buses, rootPort, null, ignoreHold, visitor); }
public override void Start() { string kinectStr = moduleInfo.Args()[0]; foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { //encode the id string as per the encoding in the scout so the match will work // '\' and '&' cause problem when the values get written to the config file (XML writer not happy) string kinectid = "Kinect Sensor:" + potentialSensor.UniqueKinectId.Replace("\\", "-").Replace("&", "."); if (kinectStr == kinectid) { this.sensor = potentialSensor; break; } } } //Create a new port on the platform. VPortInfo pInfo = GetPortInfoFromPlatform("kinect" + kinectStr); List<VRole> roles = new List<VRole>() { RoleCamera.Instance, RoleDepthCam.Instance, RoleMicrophone.Instance, RoleSkeletonTracker.Instance, RoleSpeechReco.Instance }; kinectPort = InitPort(pInfo); BindRoles(kinectPort, roles, OnOperationInvoke); RegisterPortWithPlatform(kinectPort); logger.Log("Kinect Sensor Registered."); StartKinect(); }
public override bool FulfillsCondition(Signal output, Port port) { if(port == null) return false; return port.HasArchitectureLink && _match(port.CurrentArchitecture); }
public void CtorSideEffects() { int count = 0; var pa = new Port<int> (); var pb = new Port<string> (); var ra = Arbiter.Receive (false, pa, (i) => count += i); var rb = Arbiter.Receive (false, pb, (s) => count += s.Length); var c = new Choice (ra, rb); IPortReceive pra = pa; IPortReceive prb = pb; Assert.AreEqual (ArbiterTaskState.Created, c.ArbiterState, "#1"); Assert.AreEqual (0, c.PortElementCount, "#2"); Assert.AreEqual (0, pra.GetReceivers ().Length, "#3"); Assert.AreEqual (0, prb.GetReceivers ().Length, "#4"); Assert.IsNull (ra.Arbiter, "#5"); Assert.IsNull (rb.Arbiter, "#6"); Assert.IsNull (ra.ArbiterContext, "#7"); Assert.IsNull (rb.ArbiterContext, "#8"); Assert.IsNull (ra.ArbiterCleanupHandler, "#9"); Assert.IsNull (rb.ArbiterCleanupHandler, "#10"); }
public void TestInterpreter() { var Step = Z80Interpreter.CreateExecuteStep(); var Memory = new SimpleFastMemory4(13); var Port = new Port(); var CpuContext = new CSharpCpu.Z80.CpuContext(Memory, Port); CpuContext.IFF1 = true; Assert.AreEqual(true, CpuContext.IFF1); CpuContext.PC = 0; // ROM:0000 di // ROM:0001 im 1 // ROM:0003 jp loc_97 Memory.WriteBytes(0, new byte[] { 0xF3, 0xED, 0x56, 0xC3, 0x97, 0x00 }); Step(CpuContext.ReadInstruction, CpuContext); Assert.AreEqual(0x0001, CpuContext.PC); Assert.AreEqual(false, CpuContext.IFF1); Step(CpuContext.ReadInstruction, CpuContext); Assert.AreEqual(0x0003, CpuContext.PC); Assert.AreEqual(1, CpuContext.IM); Step(CpuContext.ReadInstruction, CpuContext); Assert.AreEqual(0x0097, CpuContext.PC); }
static void Mul(InputData data, Port<int> resp) { int i, j; System.Diagnostics.Stopwatch sWatch = new System.Diagnostics.Stopwatch(); sWatch.Start(); for (i = data.start; i <= data.stop-1; i++) { for (j = i+1; j <= data.stop; j++) { if (a[j] < a[i]) //сортировка пузырьком { var temp = a[i]; a[i] = a[j]; a[j] = temp; } } } //внимательно присмотревшись к этой функции и к условиям, в которых она вызывается, можно сделать вывод //что она вернет массив, состоящий из двух сортированных половинок, но не сортированный целиком //так оно и есть, потому что параллельный пузырек - необычная задумка //в данной лабораторной работе эта проблема решается в делегате, описанном в приемнике, штатными средствами C# sWatch.Stop(); resp.Post(1); Console.WriteLine("Поток № {0}: Параллельный алгоритм = {1} мс.", Thread.CurrentThread.ManagedThreadId, sWatch.ElapsedMilliseconds.ToString()); }
public void CleanupTask() { Port<int> pa = new Port<int> (); Port<string> pb = new Port<string> (); Type[] types = new Type[] { typeof (int), typeof (string) }; IPortReceive[] ports = new IPortReceive[] { pa, pb }; int count = 2; Handler<ICollection[]> handler = (cols) => { }; var mig = new MultipleItemGather (types, ports, count, handler); var dq = new SerialDispatchQueue (); mig.TaskQueue = dq; mig.Execute (); ITask task = null; var rec = ports [0].GetReceivers () [0]; Assert.IsTrue (rec.Evaluate (new PortElement<int> (10), ref task), "#1"); Assert.IsNull (task, "#2"); Assert.IsTrue (rec.Evaluate (new PortElement<int> (20), ref task), "#3"); Assert.IsNotNull (task, "#4"); mig.Cleanup (task); Assert.AreEqual (2, pa.ItemCount, "#4"); Assert.AreEqual (0, pb.ItemCount, "#5"); Assert.AreEqual (10, pa.Test (), "#6"); Assert.AreEqual (20, pa.Test (), "#7"); }
public override bool EnterSignal(Signal signal, Port parent, bool again, bool root) { if(again) return false; _signals.Add(signal); return true; }
public override void Start() { logger.Log("Started: {0}", ToString()); string deviceName = moduleInfo.Args()[0]; string deviceAddress = moduleInfo.Args()[1]; string deviceClassType = moduleInfo.Args()[2]; string deviceType = moduleInfo.Args()[3]; //try pair with the device. bool pair = tryPairWithDevice(deviceAddress, deviceType); if (!pair) { //think of something } else { logger.Log("Bluetooth Driver: Paired with \"" + deviceName + " - " + deviceAddress + "\""); } //init the port VPortInfo portInfo = GetPortInfoFromPlatform(deviceName); bluetoothPort = InitPort(portInfo); //init the role List<VRole> listRole = new List<VRole>() { RoleBluetooth.Instance }; BindRoles(bluetoothPort, listRole); //register the port RegisterPortWithPlatform(bluetoothPort); workThread = new SafeThread(delegate() { Work(); }, "DriverBluetooth work thread", logger); workThread.Start(); }
public void CleanupDoneInlineWithoutArbiter() { Port<int> pa = new Port<int> (); Port<string> pb = new Port<string> (); Type[] types = new Type[] { typeof (int), typeof (string) }; IPortReceive[] ports = new IPortReceive[] { pa, pb }; int count = 1; Handler<ICollection[]> handler = (cols) => { }; var mig = new MultipleItemGather (types, ports, count, handler); var dq = new SerialDispatchQueue (); dq.exec = false; mig.TaskQueue = dq; mig.Execute (); var rec = ports [0].GetReceivers () [0]; var rec2 = ports [0].GetReceivers () [1]; ITask task = null; Assert.IsTrue (rec.Evaluate (new PortElement<int> (10), ref task), "#1"); Assert.IsNotNull (task, "#2"); Assert.AreEqual (ReceiverTaskState.CleanedUp, mig.State, "#3"); Assert.AreEqual (ReceiverTaskState.Persistent, rec.State, "#4"); Assert.AreEqual (ReceiverTaskState.Persistent, rec2.State, "#5"); Assert.AreEqual (0, dq.count, "#6"); }
public override void Start() { logger.Log("Started: {0} ", ToString()); string meterDevice = moduleInfo.Args()[0]; //Instantiate the port VPortInfo portInfo = GetPortInfoFromPlatform(meterDevice); powermeterPort = InitPort(portInfo); //Initialize the list of roles we are going to export and bind to the role List<VRole> listRole = new List<VRole>() {RolePowerMeter.Instance}; BindRoles(powermeterPort, listRole); //Register the port after the binding is complete RegisterPortWithPlatform(powermeterPort); imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger); System.Threading.Thread.Sleep(1 * 10 * 1000); }
public override bool EnterPort(Port port, Signal parent, bool again, bool root) { if(again) return false; _ports.Add(port); return true; }
public InputStateEventArgs(Port port, Device device, uint index, uint id) { Port = port; Device = device; Index = index; Id = id; }
protected override void DoTraverse(Port rootPort, IScanVisitor visitor, bool ignoreHold) { List<Guid> signals = new List<Guid>(); foreach(Signal input in rootPort.InputSignals) if(!TraverseSignal(signals, input, rootPort, ignoreHold, visitor)) break; // finished }
static void Mul(InputData data, Port<int> resp) { int Result = 0; int i = 0; System.Diagnostics.Stopwatch sWatch = new System.Diagnostics.Stopwatch(); Random r = new Random(); for (int j = 0; j < n; j++) a[j] = r.Next(5); sWatch.Start(); for (i = data.start; i <= data.stop; i++) { Result = Result + a[i]; } resp.Post(1); Console.WriteLine("Поток № {0}: Параллельный алгоритм = {1} мс.", Thread.CurrentThread.ManagedThreadId, sWatch.ElapsedMilliseconds.ToString()); sWatch.Stop(); Console.WriteLine("Сумма:"); Console.WriteLine(Result); }
public override bool FulfillsCondition(Signal output, Port port) { foreach(Condition c in _conditions) if(!c.FulfillsCondition(output, port)) return false; return true; }
public override bool SupportsPort(Port port) { if(port == null) throw new ArgumentNullException("port"); return port.BusCount == 0 && port.InputSignalCount == port.OutputSignalCount+1; }
private static void Run(int n, int threadCount) { Dispatcher d = new Dispatcher(threadCount, "ccr pool"); DispatcherQueue dq = new DispatcherQueue("disp", d); Port<int> p1 = new Port<int>(), p2 = new Port<int>(); EventWaitHandle done1 = new AutoResetEvent(false), done2 = new AutoResetEvent(false); PingPonger pp1 = new PingPonger(done1, n, p2), pp2 = new PingPonger(done2, n, p1); Arbiter.Activate(dq, Arbiter.Interleave( new TeardownReceiverGroup(), new ExclusiveReceiverGroup(Arbiter.Receive(true, p1, pp1.Update)), new ConcurrentReceiverGroup())); Arbiter.Activate(dq, Arbiter.Interleave( new TeardownReceiverGroup(), new ExclusiveReceiverGroup(Arbiter.Receive(true, p2, pp2.Update)), new ConcurrentReceiverGroup())); p1.Post(0); EventWaitHandle.WaitAll(new[] { done1, done2 }); dq.Dispose(); d.Dispose(); }
static void Mul(InputData data, Port<int> resp) { int i; double Pi = 0,dx=0,x=0; System.Diagnostics.Stopwatch sWatch = new System.Diagnostics.Stopwatch(); sWatch.Start(); dx = 1 / 10000000.0; x = data.start / 10000000.0; for (i = data.start; i <= data.stop; i++) { Pi += Math.Sqrt(1 - x * x)*4*dx; x += dx; } Console.WriteLine("часть Pi №{0} = {1}", Thread.CurrentThread.ManagedThreadId,Pi); sWatch.Stop(); resp.Post(1); Console.WriteLine("Поток № {0}: Параллельный алгоритм = {1} мс.", Thread.CurrentThread.ManagedThreadId, sWatch.ElapsedMilliseconds.ToString()); }
public override void Start() { foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } //Create a new port on the platform. string kinectStr = moduleInfo.Args()[0]; VPortInfo pInfo = GetPortInfoFromPlatform("kinect" + kinectStr); List<VRole> roles = new List<VRole>() { RoleCamera.Instance, RoleDepthCam.Instance, RoleMicrophone.Instance, RoleSkeletonTracker.Instance }; kinectPort = InitPort(pInfo); BindRoles(kinectPort, roles, OnOperationInvoke); RegisterPortWithPlatform(kinectPort); /* sensor.ColorStream.Enable(); sensor.DepthStream.Enable(); sensor.SkeletonStream.Enable();*/ logger.Log("Kinect Sensor Rigistered."); StartKinect(); }
public InterstellarPlugin() { Samplerate = 48000; DevInfo = new DeviceInfo(); ParameterInfo = new Parameter[1]; PortInfo = new Port[2]; }
static void Mul(InputData data, Port<int> resp) { long Result = 0; int i = 0; System.Diagnostics.Stopwatch sWatch = new System.Diagnostics.Stopwatch(); Random r = new Random(); for (int j = 0; j < n; j++) { a[j] = r.Next(1, 3); b[j] = r.Next(1, 3); } long ResultA = 1; long ResultB = 1; long Res = 0; sWatch.Start(); for (i = data.start; i <= data.stop; i++) { ResultA = ResultA * a[i]; ResultB = ResultB * b[i]; ResultA = ResultA / 25; ResultArr[i] = ResultA + ResultB; Res = Res + ResultArr[i]; } sWatch.Stop(); resp.Post(1); Console.WriteLine("Поток № {0}: Параллельный алгоритм = {1} мс.", Thread.CurrentThread.ManagedThreadId, sWatch.ElapsedMilliseconds.ToString()); }
public void DispatchEventWithDispatcherQueueExceptionPort() { using (Dispatcher d = new Dispatcher ()) { var dq = new DispatcherQueue ("foo", d); var evt = new AutoResetEvent (false); var port = new Port<Exception> (); dq.UnhandledExceptionPort = port; int portPost = 0; int dispEx = 0; d.UnhandledException += delegate { ++dispEx; }; var rec = Arbiter.Receive (true, port, (e) => { ++portPost; evt.Set(); }); rec.TaskQueue = dq; rec.Execute (); dq.Enqueue (Arbiter.FromHandler (() => { throw new Exception (); })); Assert.IsTrue (evt.WaitOne (2000), "#1"); Assert.AreEqual (1, portPost, "#2"); Assert.AreEqual (0, dispEx, "#3"); dq.Enqueue (Arbiter.FromHandler (() => { throw new Exception (); })); Assert.IsTrue (evt.WaitOne (2000), "#4"); Assert.AreEqual (2, portPost, "#5"); Assert.AreEqual (0, dispEx, "#6"); } }
public override void Start() { logger.Log("Started: {0}", ToString()); List<COMPortInfo> comportList = COMPortInfo.GetCOMPortsInfo(); foreach (COMPortInfo comPortInfo in comportList) { if (comPortInfo.Description.Contains(Prolific)) { this.SerialPortName = comPortInfo.Name; break; } } logger.Log("Discovered envi sensor on COM port: "+SerialPortName); // ..... initialize the list of roles we are going to export List<VRole> listRole = new List<VRole>() {RoleSensorMultiLevel.Instance }; //AJ add the other roles - like temperature into this list and then below do notifications on them //List<VRole> listRole = new List<VRole>() { RoleSensor.Instance }; //.................instantiate the port VPortInfo portInfo = GetPortInfoFromPlatform("envi"); enviPort = InitPort(portInfo); //..... bind the port to roles and delegates BindRoles(enviPort, listRole, null); //.................register the port after the binding is complete RegisterPortWithPlatform(enviPort); ReadFromSerialPort(); }
public override void Start() { try { string[] words = moduleInfo.Args(); deviceId = words[0]; } catch (Exception e) { logger.Log("{0}: Improper arguments: {1}. Exiting module", this.ToString(), e.ToString()); return; } //get the IP address PortName = GetDevicePort(deviceId); logger.Log("Got a port name of {0}", new string[] { PortName }); if (PortName == null) { logger.Log("{0} did not get a device ip for deviceId: {1}. Returning", base.moduleInfo.BinaryName(), deviceId.ToString()); return; } //add the service port VPortInfo pInfo = GetPortInfoFromPlatform("valve-" + deviceId); devicePort = InitPort(pInfo); // add role and register with platform BindRoles(devicePort, GetRoleList(), OnOperationInvoke); RegisterPortWithPlatform(devicePort); imageServer = new WebFileServer(moduleInfo.BinaryDir(), moduleInfo.BaseURL(), logger); }
public void TwoArgsCtor() { var port = new Port<int> (); var pe = new PortElement<int> (10, port); Assert.AreEqual (10, pe.TypedItem, "#1"); Assert.AreEqual (10, pe.Item, "#2"); Assert.AreEqual (port, pe.Owner, "#3"); }
public override bool EnterPort(Port port, Signal parent, bool again, bool root) { if(again) return false; if(_match(port)) return _action(port); return true; }
public override bool SupportsPort(Port port) { if(port == null) throw new ArgumentNullException("port"); // all inputs must be empty or of type TokenValue return !port.InputSignals.Exists(delegate(Signal s) { return (s.Value as TokenValue) == null; }); }
/// <summary> /// Reads a number of bytes from registers. /// </summary> /// <param name="startingRegisterAddress">The starting register address to read.</param> /// <param name="byteCount">The number of bytes to read.</param> /// <param name="port">The I/O port used with the registers.</param> /// <param name="bank">The bank type that determines how the registers are mapped.</param> /// <returns>The data read from the registers.</returns> public override byte[] Read(Register.Address startingRegisterAddress, byte byteCount, Port port = Port.PortA, Bank bank = Bank.Bank1) { Write(startingRegisterAddress, new byte[] { }, port, bank); // Set address to register first. byte[] readBuffer = new byte[byteCount]; _i2cDevice.Read(readBuffer); return(readBuffer); }
/// <summary> /// Writes a number of bytes to registers. /// </summary> /// <param name="startingRegisterAddress">The starting register address to write.</param> /// <param name="data">The data to write to registers.</param> /// <param name="port">The I/O port used with the registers.</param> /// <param name="bank">The bank type that determines how the registers are mapped.</param> public override void Write(Register.Address startingRegisterAddress, byte[] data, Port port = Port.PortA, Bank bank = Bank.Bank1) { byte[] writeBuffer = new byte[data.Length + 1]; // Include Register Address. writeBuffer[0] = Register.GetMappedAddress(startingRegisterAddress, port, bank); data.CopyTo(writeBuffer, 1); _i2cDevice.Write(writeBuffer); }
public abstract void DockAt(Port port);
public abstract Vehicle CreateVehicle(string name, Port port);
///<summary>Returns a string representation of this object.</summary> ///<returns>A string with information about this object.</returns> public override string ToString() { return("HTTP service on " + Address.ToString() + ":" + Port.ToString()); }
////Get ping status (bool) and latency (int) //public Tuple<bool, int> Ping(string ip) //{ // Ping pinger = new Ping(); // PingOptions pingOptions = new PingOptions(); // pingOptions.DontFragment = true; // byte[] buffer = new byte[4] { 0, 0, 0, 0 }; // PingReply pingReply = pinger.Send(ip, Timeout, buffer, pingOptions); // if (pingReply.Status == IPStatus.Success) // { // int latency = Convert.ToInt32(pingReply.RoundtripTime); // return new Tuple<bool, int>(true, latency); // } // return new Tuple<bool, int>(false, Int32.MaxValue); //} public override string ToString() { return(string.Concat(Host, ":", Port.ToString())); }
public override string ToString() { if (IsUnixPipe) { return(Scheme.ToLowerInvariant() + Uri.SchemeDelimiter + Host.ToLowerInvariant()); } else { return(Scheme.ToLowerInvariant() + Uri.SchemeDelimiter + Host.ToLowerInvariant() + ":" + Port.ToString(CultureInfo.InvariantCulture) + PathBase); } }
public static int GetPortCount(this KMBombInfo bombInfo, Port portType) { return(bombInfo.GetPortCount(portType.ToString())); }
protected abstract void Action(Port port, int index);
public static bool IsPortPresent(this KMBombInfo bombInfo, Port portType) { return(bombInfo.IsPortPresent(portType.ToString())); }
public static bool IsNotAlgebraicExpressionMember(Port port) { return(Instance.IsMember(port) == CategoryMembershipLevel.NotMember); }
private void AddVoy(int voy_number, string account, string laycan, string contract, string cargo, string sf, string pol, string facility, string pod, string cargo_charterer, string owner_charterer, string shipper, string consignee, string mob, string latitude, string altitude, DateTime lastKnowPosition, DateTime eta, DateTime etb, DateTime etc, DateTime etd, Vessel vessel, Company company, Port port, Employee employee) { _context.Voys.Add(new Voy { Voy_number = voy_number, Account = account, Laycan = laycan, Contract = contract, Cargo = cargo, Sf = sf, Pol = pol, Facility = facility, Pod = pod, Cargo_Charterer = cargo_charterer, Owner_Charterer = owner_charterer, Shipper = shipper, Consignee = consignee, Latitude = latitude, Altitude = altitude, LastKnowPosition = lastKnowPosition, Eta = eta, Etb = etb, Etc = etc, Etd = etd, Vessel = vessel, Company = company, Port = port, Employee = employee, } ); }
public static bool IsDuplicatePortPresent(this KMBombInfo bombInfo, Port port) { return(IsDuplicatePortPresent(bombInfo, port.ToString())); }
public BufferedPortImageRgba(Port port) : this(yarpPINVOKE.new_BufferedPortImageRgba__SWIG_1(Port.getCPtr(port)), true) { if (yarpPINVOKE.SWIGPendingException.Pending) { throw yarpPINVOKE.SWIGPendingException.Retrieve(); } }
public virtual Port asPort() { Port ret = new Port(yarpPINVOKE.AbstractContactable_asPort__SWIG_0(swigCPtr), false); return(ret); }
private void AddTerminal(string terminal_Name, string max_Loa, string max_Beam, string max_Draft, string displacement, string water_Density, string working_hours, string type_Cargo, string URL, Port port) { _context.Terminals.Add(new Terminal { Terminal_Name = terminal_Name, Max_Loa = max_Loa, Max_Beam = max_Beam, Max_Draft = max_Draft, Displacement = displacement, Water_Density = water_Density, Working_hours = working_hours, Type_Cargo = type_Cargo, ImageUrl = URL, Port = port, } ); }
protected override UnityEditor.GenericMenu OnDragAndDropPortContextMenu(UnityEditor.GenericMenu menu, Port port) { if (macro == null) { return(menu); } if (port.IsInputPort()) { menu.AddItem(new GUIContent(string.Format("Promote to new Input '{0}'", port.name)), false, () => { var def = new DynamicParameterDefinition(port.name, port.type); var defPort = macro.AddInputDefinition(def); BinderConnection.Create(defPort, port); }); } return(menu); }
///---------------------------------------------------------------------------------------------- ///---------------------------------------UNITY EDITOR------------------------------------------- #if UNITY_EDITOR void IEditorMenuCallbackReceiver.OnMenu(UnityEditor.GenericMenu menu, Vector2 pos, Port sourcePort, object dropInstance) { if (sourcePort != null) { if (sourcePort is ValueInput && !sourcePort.type.IsAssignableFrom(returnType)) { return; } if (sourcePort is ValueOutput && !parameterTypes.Any(t => t.IsAssignableFrom(sourcePort.type))) { return; } } menu.AddItem(new GUIContent(string.Format("Functions/Custom/Call '{0}()'", identifier)), false, () => { var node = flowGraph.AddNode <CustomFunctionCall>(pos); node.SetFunction(this); FlowGraphExtensions.Finalize(node, sourcePort, null); }); }
public DrawingTool() { InitializeComponent(); if (Device.RuntimePlatform == Device.Android) { Xamarin.Forms.DependencyService.Get <IText>().GenerateFactor(); } diagram.IsReadOnly = true; Node n1 = DrawNode(145, 110, 100, 55, ShapeType.Rectangle, "Node1"); if (Device.RuntimePlatform == Device.UWP) { n1.ShapeType = ShapeType.Rectangle; } n1.Style.Brush = new SolidBrush(Color.FromRgb(49, 162, 255)); n1.Style.StrokeBrush = new SolidBrush(Color.FromRgb(23, 132, 206)); PortCollection node1ports = new PortCollection(); Port port1 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 0, ShapeType = ShapeType.Circle, IsVisible = true }; Port port2 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true }; Port port3 = new Port() { Width = 10, Height = 10, NodeOffsetX = 1, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true }; Port port4 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 1, ShapeType = ShapeType.Circle, IsVisible = true }; node1ports.Add(port1); node1ports.Add(port2); node1ports.Add(port3); node1ports.Add(port4); n1.Ports = node1ports; Node n2 = DrawNode(30, 260, 100, 55, ShapeType.Rectangle, "Node2"); if (Device.RuntimePlatform == Device.UWP) { n2.ShapeType = ShapeType.Rectangle; } n2.Style.Brush = new SolidBrush(Color.FromRgb(239, 75, 93)); n2.Style.StrokeBrush = new SolidBrush(Color.FromRgb(201, 32, 61)); PortCollection node2ports = new PortCollection(); Port port5 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 0, ShapeType = ShapeType.Circle, IsVisible = true }; Port port6 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true }; Port port7 = new Port() { Width = 10, Height = 10, NodeOffsetX = 1, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true }; Port port8 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 1, ShapeType = ShapeType.Circle, IsVisible = true }; node2ports.Add(port5); node2ports.Add(port6); node2ports.Add(port7); node2ports.Add(port8); n2.Ports = node2ports; Node n3 = DrawNode(260, 260, 100, 55, ShapeType.Rectangle, "Node3"); if (Device.RuntimePlatform == Device.UWP) { n3.ShapeType = ShapeType.Rectangle; } n3.Style.Brush = new SolidBrush(Color.FromRgb(0, 194, 192)); n3.Style.StrokeBrush = new SolidBrush(Color.FromRgb(14, 142, 135)); PortCollection node3ports = new PortCollection(); Port port9 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 0, ShapeType = ShapeType.Circle, IsVisible = true }; Port port10 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true }; Port port11 = new Port() { Width = 10, Height = 10, NodeOffsetX = 1, NodeOffsetY = 0.5, ShapeType = ShapeType.Circle, IsVisible = true }; Port port12 = new Port() { Width = 10, Height = 10, NodeOffsetX = 0.5, NodeOffsetY = 1, ShapeType = ShapeType.Circle, IsVisible = true }; node3ports.Add(port9); node3ports.Add(port10); node3ports.Add(port11); node3ports.Add(port12); n3.Ports = node3ports; Connector con1 = new Connector() { SourcePort = port4, TargetPort = port5, SegmentType = SegmentType.StraightSegment, TargetDecoratorType = DecoratorType.None }; Connector con2 = new Connector() { SourcePort = port4, TargetPort = port9, SegmentType = SegmentType.StraightSegment, TargetDecoratorType = DecoratorType.None }; Connector con3 = new Connector() { SourcePort = port7, TargetPort = port10, SegmentType = SegmentType.StraightSegment, TargetDecoratorType = DecoratorType.None }; diagram.AddNode(n1); diagram.AddNode(n2); diagram.AddNode(n3); diagram.AddConnector(con1); diagram.AddConnector(con2); diagram.AddConnector(con3); }
public override int GetHashCode() { return Math.Abs($"{IP}:{Port.ToString()}".GetHashCode()); }
public void ClearLinks() { Port.ClearLinks(); }
void OnChangedStateCb(Thing thing, Port port, string state) { }
public static bool IsNotLogicValueMember(Port port) { return(Instance.IsMember(port) == CategoryMembershipLevel.NotMember); }
public static void Main() { try { ServiceDescription myDescription = ServiceDescription.Read("AddNumbersIn_cs.wsdl"); // Add the ServiceHttpPost binding. Binding myBinding = new Binding(); myBinding.Name = "ServiceHttpPost"; XmlQualifiedName myXmlQualifiedName = new XmlQualifiedName("s0:ServiceHttpPost"); myBinding.Type = myXmlQualifiedName; HttpBinding myHttpBinding = new HttpBinding(); myHttpBinding.Verb = "POST"; myBinding.Extensions.Add(myHttpBinding); // Add the operation name AddNumbers. OperationBinding myOperationBinding = new OperationBinding(); myOperationBinding.Name = "AddNumbers"; HttpOperationBinding myOperation = new HttpOperationBinding(); myOperation.Location = "/AddNumbers"; myOperationBinding.Extensions.Add(myOperation); // Add the input binding. InputBinding myInput = new InputBinding(); MimeContentBinding postMimeContentbinding = new MimeContentBinding(); postMimeContentbinding.Type = "application/x-www-form-urlencoded"; myInput.Extensions.Add(postMimeContentbinding); // Add the InputBinding to the OperationBinding. myOperationBinding.Input = myInput; // Add the ouput binding. OutputBinding myOutput = new OutputBinding(); MimeXmlBinding postMimeXmlbinding = new MimeXmlBinding(); postMimeXmlbinding.Part = "Body"; myOutput.Extensions.Add(postMimeXmlbinding); // Add the OutPutBinding to the OperationBinding. myOperationBinding.Output = myOutput; myBinding.Operations.Add(myOperationBinding); myDescription.Bindings.Add(myBinding); // Add the port definition. Port postPort = new Port(); postPort.Name = "ServiceHttpPost"; postPort.Binding = new XmlQualifiedName("s0:ServiceHttpPost"); HttpAddressBinding postAddressBinding = new HttpAddressBinding(); postAddressBinding.Location = "http://localhost/Service_cs.asmx"; postPort.Extensions.Add(postAddressBinding); myDescription.Services[0].Ports.Add(postPort); // Add the post port type definition. PortType postPortType = new PortType(); postPortType.Name = "ServiceHttpPost"; Operation postOperation = new Operation(); postOperation.Name = "AddNumbers"; OperationMessage postInput = (OperationMessage) new OperationInput(); postInput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostIn"); OperationOutput postOutput = new OperationOutput(); postOutput.Message = new XmlQualifiedName("s0:AddNumbersHttpPostOut"); postOperation.Messages.Add(postInput); postOperation.Messages.Add(postOutput); postPortType.Operations.Add(postOperation); myDescription.PortTypes.Add(postPortType); // Add the first message information. Message postMessage1 = new Message(); postMessage1.Name = "AddNumbersHttpPostIn"; MessagePart postMessagePart1 = new MessagePart(); postMessagePart1.Name = "firstnumber"; postMessagePart1.Type = new XmlQualifiedName("s:string"); // Add the second message information. MessagePart postMessagePart2 = new MessagePart(); postMessagePart2.Name = "secondnumber"; postMessagePart2.Type = new XmlQualifiedName("s:string"); postMessage1.Parts.Add(postMessagePart1); postMessage1.Parts.Add(postMessagePart2); Message postMessage2 = new Message(); postMessage2.Name = "AddNumbersHttpPostOut"; // Add the third message information. MessagePart postMessagePart3 = new MessagePart(); postMessagePart3.Name = "Body"; postMessagePart3.Element = new XmlQualifiedName("s0:int"); postMessage2.Parts.Add(postMessagePart3); myDescription.Messages.Add(postMessage1); myDescription.Messages.Add(postMessage2); // Write the ServiceDescription as a WSDL file. myDescription.Write("AddNumbersOut_cs.wsdl"); Console.WriteLine("WSDL file named AddNumbersOut_cs.Wsdl" + " created successfully."); } catch (Exception e) { Console.WriteLine("Exception caught!!!"); Console.WriteLine("Source : " + e.Source); Console.WriteLine("Message : " + e.Message); } }
private async Task <bool> connectNewConnection() { var connection = new FTPConnection(Username, Password, new HostName(Server), Port.ToString(), this); connection.DisconnectedEvent += () => { _connections.Remove(connection); connection = null; }; connection.CommandSendEvent += (command) => { History += ("\nCLIENT: " + command); }; connection.AnswerReadEvent += (answer) => { History += ("\nSERVER: " + answer); }; connection.EncryptionMode = EncryptionMode; connection.ProtectionMode = ProtectionMode; //do this in the try block; maybe the connection cannot be established (e.g. IO problems) try { var isConnected = await connection.Connect(); //now add the connection to the list because the connection was established at least once if (isConnected) { _connections.Add(connection); } if (isConnected) { return(connection.Login()); } } catch (Exception) { return(false); } return(false); }
public override CategoryMembershipLevel IsMember(Port port) { return(EvaluateJointChildMembership(port.InputSignals)); }
private IInterpreter ResolveInterpreter <A, S>(Port <A> ma) { return((IInterpreter)_serviceProvider.GetService(GetTypeMarker(ma))); }
public void Reset() { _failedPort = null; _failedPortTarget = null; }
/// <summary> /// Starts the server in an infinite loop waiting for connections. /// </summary> public static void Start() { //1. Start the API endpoint. try { WebApp.Start <Startup>(url: ApiBaseUrl); Console.WriteLine(" API Server endpoint started on URL " + ApiBaseUrl); } catch (Exception ex) { Console.WriteLine(string.Concat("ERROR: Could not start the API server endpoint. Possibly a permissions issue." , Environment.NewLine, ex.Message, Environment.NewLine , "If you are on a Windows machine, try running this command as an Administrator:", Environment.NewLine , "netsh http add urlacl url=http://*:8880/ user=Everyone listen=yes", Environment.NewLine , "Don't forget to change the port number (8880 above) as per your App.config settings.")); } //2. Setup the Bot engine and start the TCP server AIMLBot myBot = new AIMLBot(); try { myBot.LoadSettings(); myBot.LoadAIMLFromFiles(); } catch (Exception ex) { Console.WriteLine(string.Concat(ex.Message, Environment.NewLine, "Could not load the bot settings and/or AIML files. ", "Please ensure that config and aiml folders exist in the same directory as your .exe file or the directory as per your configuration." )); Environment.Exit(0); } Users = new Dictionary <string, BotUser>(); Guid defaultId = Guid.NewGuid(); BotUser myUser = new BotUser(defaultId, myBot); DefaultUser = myUser; Users[defaultId.ToString()] = myUser; myBot.IsAcceptingInput = false; myBot.IsAcceptingInput = true; ActiveBot = myBot; TcpListener serverSocket = new TcpListener(IPAddress, Port); TcpClient clientSocket = default(TcpClient); int counter = 0; serverSocket.Start(); Console.WriteLine(" Karmaloop AIML Bot Server Started on port " + Port.ToString()); Console.WriteLine("---------------------------------------------------------------- "); Console.WriteLine(); Console.WriteLine("Take the bot for a spin! Try hitting the URL http://localhost:8880/api/ChatUi/index.html from your local browser!"); counter = 0; while (!ForceStop) { counter += 1; clientSocket = serverSocket.AcceptTcpClient(); Console.WriteLine(" >> " + "Client No:" + Convert.ToString(counter) + " started!"); KarmaloopClient client = new KarmaloopClient(); client.StartClient(clientSocket, Convert.ToString(counter)); } }
private Type GetTypeMarker <A>(Port <A> ma) => ma.GetType().GetInterfaces().Single(p => _nonGenericTypeMaker.IsAssignableFrom(p) && p.IsGenericType);