/// <summary> /// Adds OutputPort /// </summary> void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector) { var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); Debug.Console(2, this, "Adding output port '{0}'", portKey); OutputPorts.Add(new RoutingOutputPort(portKey, sigType, portType, selector, this)); }
private void Port_SamplerateChanged(object sender, SamplerateChangedEventArgs e) { foreach (var port in OutputPorts.OfType <NodeSystemLib2.FormatData1D.OutputPortData1D>()) { port.Samplerate = e.NewSamplerate; } }
public override void PrepareProcessing() { if (_editor != null && !_editor.IsDisposed && _editor.Edited) { _editor.AskForSave(); } if (_ctx == null) { throw new Exception("Python code has errors"); } try { _ctx.Call("prepare", new PyObject[0]); } catch (PyException e) { DisplayPythonError(e); throw; } foreach (var port in InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>()) { port.PrepareProcessing(); } foreach (var port in OutputPorts.OfType <NodeSystemLib2.FormatData1D.OutputPortData1D>()) { port.PrepareProcessing(); } }
public override void Transfer() { foreach (var port in OutputPorts.OfType <NodeSystemLib2.FormatData1D.OutputPortData1D>()) { port.Transfer(); } }
public void AddChildPort(bool incrementPortCount = true) { CodeGraph.Instance.InvalidateSaveButton(); var outputPort = base.InstantiatePort(Orientation.Horizontal, Direction.Output, Port.Capacity.Single, typeof(float)); outputPort.name = $"EventPort {EventPorts.Count + 1}"; outputPort.portName = $"child {EventPorts.Count + 1}"; outputPort.portColor = new Color(1, 1, 1, 0.2f); // AddOutputPort(outputPort, () => ""); var outputPortObj = new OutputPort(this, outputPort, () => ""); OutputPorts.Add(outputPortObj); EventPorts.Add(outputPortObj); OutputPortDictionary.Add(outputPort, outputPortObj); outputPort.contentContainer.Add(new Button(() => { RemovePort(outputPortObj); }) { text = "X" }); outputContainer.Add(outputPort); if (incrementPortCount) { PortCount++; } Refresh(); }
private void RemovePort(OutputPort port) { CodeGraph.Instance.InvalidateSaveButton(); var connectionsToRemove = new List <Edge>(); connectionsToRemove.AddRange(port.PortReference.connections); while (connectionsToRemove.Count > 0) { var conn = connectionsToRemove[0]; CodeGraph.Instance.GraphView.RemoveElement(conn); conn.input.Disconnect(conn); conn.output.Disconnect(conn); // conn = null; connectionsToRemove.RemoveAt(0); } outputContainer.Remove(port.PortReference); OutputPorts.Remove(port); EventPorts.Remove(port); OutputPortDictionary.Remove(port.PortReference); port.PortReference = null; PortCount--; FixPortNames(); Refresh(); }
public override void Process() { Dictionary <InputPort, double[]> datas = new Dictionary <InputPort, double[]>(); foreach (var port in InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>()) { var read = port.Read(); datas.Add(port, read.Data.Take(read.Available).ToArray()); } object result = null; if (datas.Values.Count == 1) { _matlab.Feval(_funcHeader.Name, _funcHeader.ReturnValues.Length, out result, datas.Values.ElementAt(0)); } else if (datas.Values.Count == 2) { _matlab.Feval(_funcHeader.Name, _funcHeader.ReturnValues.Length, out result, datas.Values.ElementAt(0), datas.Values.ElementAt(1)); } var data = (double[, ])((object[])result)[0]; ((NodeSystemLib2.FormatData1D.OutputPortData1D)OutputPorts.First()).Buffer.Write(data, 0, data.Length); }
public override void PrepareProcessing() { if (string.IsNullOrEmpty(_attrFuncName.TypedGet())) { throw new Exception("No matlab function specified"); } if (_matlab == null) { if (!TryFindMatlab()) { throw new Exception("No matlab instance found. Make sure to enable the automation server:\nenableservice('AutomationServer', true)"); } } _funcHeader = FindFunction(); if (_funcHeader == null) { throw new Exception($"Function {_attrFuncName.TypedGet()} not found or uses unsupported syntax in function header"); } foreach (var input in InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>()) { input.PrepareProcessing(); } foreach (var output in OutputPorts.OfType <NodeSystemLib2.FormatData1D.OutputPortData1D>()) { output.PrepareProcessing(); } }
public void AddOutputPortToNode(string name, Type type) { var conn = new Port(name, this, PortTypes.Output, type); OutputPortPanel.Children.Add(conn); OutputPorts.Add(conn); }
private new void AddOutputPort(Port portReference, Func <string> getCode, bool alsoAddToHierarchy = true) { var outputPort = new OutputPort(this, portReference, getCode); OutputPorts.Add(outputPort); OutputPortDictionary.Add(portReference, outputPort); if (alsoAddToHierarchy) { outputContainer.Add(portReference); } }
public override void Init() { base.Init(); Label = "Start Node"; NodePosition = new SVector2(960, 540); OutputPorts.Add(new PortBase() { Text = "Start", type = typeof(Object.Am_Text).ToString() }.Init()); }
public void AddOutputPortToNode(string name, Type type) { var conn = new Port(name, this, PortTypes.Output, type) { MultipleConnectionsAllowed = true }; OutputPortPanel.Children.Add(conn); OutputPorts.Add(conn); }
private void Node_PortRemoved(object sender, Node.PortChangedEventArgs e) { if (e.Port.FlowDirection == Port.Direction.Input) { RemovePort(InputPorts.ElementAt(e.Index)); } else { RemovePort(OutputPorts.ElementAt(e.Index)); } Parent.Parent.Invalidate(); }
private IntPtr WriteDataPort(IntPtr self, IntPtr args) { var argTuple = new PyTuple(new PyObject(args, false)); var data = new PyArray(argTuple.Get(0)); var portName = argTuple.Get(1).GetString(); var dataPort = OutputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.OutputPortData1D; var result = data.ToArrayDouble(); dataPort.Buffer.Write(result, 0, result.Length); return(new PyLong(1, false).Handle); }
private IntPtr SetSamplerate(IntPtr self, IntPtr args) { var argTuple = new PyTuple(new PyObject(args, false)); var portName = argTuple.Get(0).GetString(); var samplerate = argTuple.Get(1).GetDouble(); var dataPort = OutputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.OutputPortData1D; if (dataPort != null) { dataPort.Samplerate = (int)samplerate; return(new PyLong(1, false).Handle); } return(new PyLong(0, false).Handle); }
/// <summary> /// Adds OutputPort and sets Port as ICec object /// </summary> void AddOutputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType, object selector, ICec cecPort) { var portKey = string.Format("outputCard{0}--{1}", cardNum, portName); Debug.Console(2, this, "Adding output port '{0}'", portKey); var outputPort = new RoutingOutputPort(portKey, sigType, portType, selector, this); if (cecPort != null) { outputPort.Port = cecPort; } OutputPorts.Add(outputPort); }
/// <summary> /// /// </summary> public MockVC(DeviceConfig config) : base(config) { PropertiesConfig = JsonConvert.DeserializeObject <VideoCodec.MockVcPropertiesConfig>(config.Properties.ToString()); CodecInfo = new MockCodecInfo(); // Get favoritesw if (PropertiesConfig.Favorites != null) { CallFavorites = new CodecCallFavorites(); CallFavorites.Favorites = PropertiesConfig.Favorites; } DirectoryBrowseHistory = new List <CodecDirectory>(); // Debug helpers MuteFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Mute={0}", _IsMuted); PrivacyModeIsOnFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Privacy={0}", _PrivacyModeIsOn); SharingSourceFeedback.OutputChange += (o, a) => Debug.Console(1, this, "SharingSource={0}", _SharingSource); VolumeLevelFeedback.OutputChange += (o, a) => Debug.Console(1, this, "Volume={0}", _VolumeLevel); CurrentDirectoryResultIsNotDirectoryRoot = new BoolFeedback(() => DirectoryBrowseHistory.Count > 0); CurrentDirectoryResultIsNotDirectoryRoot.FireUpdate(); CodecOsdIn = new RoutingInputPort(RoutingPortNames.CodecOsd, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 0, this); InputPorts.Add(CodecOsdIn); HdmiIn1 = new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 1, this); InputPorts.Add(HdmiIn1); HdmiIn2 = new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, 2, this); InputPorts.Add(HdmiIn2); HdmiOut = new RoutingOutputPort(RoutingPortNames.HdmiOut, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, null, this); OutputPorts.Add(HdmiOut); CallHistory = new CodecCallHistory(); for (int i = 0; i < 10; i++) { var call = new CodecCallHistory.CallHistoryEntry(); call.Name = "Call " + i; call.Number = i + "@call.com"; CallHistory.RecentCalls.Add(call); } // eventually fire history event here SetupCameras(); SetIsReady(); }
private void Initialize(TesiraSwitcherControlBlockConfig config) { Type = ""; //DeviceManager.AddDevice(this); Debug.Console(2, this, "Adding SourceSelector '{0}'", Key); IsSubscribed = false; Label = config.Label; if (config.Type != null) { Type = config.Type; } Enabled = config.Enabled; if (config.SwitcherInputs != null) { foreach ( var input in from input in config.SwitcherInputs let inputPort = input.Value let inputPortKey = input.Key select input) { InputPorts.Add(new RoutingInputPort(input.Value.Label, eRoutingSignalType.Audio, eRoutingPortConnectionType.BackplaneOnly, input.Key, this)); } } if (config.SwitcherOutputs == null) { return; } foreach ( var output in from output in config.SwitcherOutputs let outputPort = output.Value let outputPortKey = output.Key select output) { OutputPorts.Add(new RoutingOutputPort(output.Value.Label, eRoutingSignalType.Audio, eRoutingPortConnectionType.BackplaneOnly, output.Key, this)); } }
/// <summary> /// 获取IO口 /// </summary> /// <typeparam name="T">Inputport或者OutputPort</typeparam> /// <param name="condition">IO口的no或者name</param> /// <returns>满足条件的Inputport或者OutputPort</returns> public T GetPort <T>(object condition) { object[] arrayObj = null; //先判断查找的是输入端口还是输出端口 if (typeof(T) == typeof(OutputPort)) { if (condition is int) { arrayObj = (object[])(OutputPorts.Where(x => x.bitno == (int)condition)); } else if (condition is string) { arrayObj = (object[])(OutputPorts.Where(x => x.name == (string)condition)); } //不满足条件 arrayObj还是为null } else if (typeof(T) == typeof(InputPort)) { if (condition is int) { arrayObj = InputPorts.Where(x => x.bitno == (int)condition).ToArray(); } else if (condition is string) { arrayObj = InputPorts.Where(x => x.name == (string)condition).ToArray(); } //不满足条件 arrayObj还是为null } if (arrayObj == null || arrayObj.Length == 0) //输入的T不符合要求arrayObj为null,condition没找到arrayObj长度为0,两种都是不满足要求 { return(default(T)); } if (arrayObj.Length > 1) { throw new Exception("Two or more ports was set to be port \"" + condition.ToString() + " !!!"); } return((T)arrayObj[0]); }
public override void Init() { base.Init(); Label = "Text Obj"; NodePosition = new SVector2(960, 540); InputPorts.Add(new PortBase() { Text = "Properties", type = typeof(Object.Am_Text).ToString() }.Init()); OutputPorts.Add(new PortBase() { Text = "Out", type = typeof(Object.Am_Text).ToString() }.Init()); ShowedPropertiesList.Add("Text"); ShowedPropertiesList.Add("Fill_Color"); }
public void AddOutput(OutputPort port, int index = -1) { if (OutputPorts.Any(i => i.Name == port.Name)) { throw new ArgumentException("Name of port ambiguous"); } port.OutputConnectionsChanged += Output_OutputConnectionsChanged; port.Parent = this; if (index > -1) { _outputs.Insert(index, port); } else { _outputs.Add(port); } PortAdded?.Invoke(this, new PortChangedEventArgs { Port = port, Index = index }); }
public CameraVisca(string key, string name, IBasicCommunication comm, CameraPropertiesConfig props) : base(key, name) { Presets = props.Presets; OutputPorts.Add(new RoutingOutputPort("videoOut", eRoutingSignalType.Video, eRoutingPortConnectionType.None, null, this, true)); // Default to all capabilties Capabilities = eCameraCapabilities.Pan | eCameraCapabilities.Tilt | eCameraCapabilities.Zoom | eCameraCapabilities.Focus; Communication = comm; var socket = comm as ISocketStatus; if (socket != null) { // This instance uses IP control socket.ConnectionChange += new EventHandler <GenericSocketStatusChageEventArgs>(socket_ConnectionChange); } else { // This instance uses RS-232 control } PortGather = new CommunicationGather(Communication, "\xFF"); Communication.BytesReceived += new EventHandler <GenericCommMethodReceiveBytesArgs>(Communication_BytesReceived); PowerIsOnFeedback = new BoolFeedback(() => { return(PowerIsOn); }); if (props.CommunicationMonitorProperties != null) { CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, props.CommunicationMonitorProperties); } else { CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 20000, 120000, 300000, "\x81\x09\x04\x00\xFF"); } DeviceManager.AddDevice(CommunicationMonitor); }
public void CleanPorts() { CodeGraph.Instance.InvalidateSaveButton(); var portsToRemove = new List <OutputPort>(); (from port in EventPorts let portConnections = port.PortReference.connections.ToList() where portConnections.Count == 0 select port).ToList() .ForEach(port => { outputContainer.Remove(port.PortReference); portsToRemove.Add(port); PortCount--; }); portsToRemove.ForEach(p => { OutputPorts.Remove(p); EventPorts.Remove(p); OutputPortDictionary.Remove(p.PortReference); p.PortReference = null; }); FixPortNames(); Refresh(); }
/// <summary> /// Constructs a ports /// </summary> /// <param name="layer">The brick layer</param> internal IOPorts(ChainLayer layer) { Layer = layer; OutputPort = new OutputPorts(layer); InputPort = new InputPorts(layer); }
private void GetPortDefs() { PyObject callResult = null; try { callResult = _ctx.Call("init", new PyObject[0]); DisplayPythonError(null); } catch (PyException e) { DisplayPythonError(e); Parent.Context.Notify(new GraphNotification(this, GraphNotification.NotificationType.Error, $"Python: While executing init function: {e.Message}")); return; } catch (EntryPointNotFoundException e) { Parent.Context.Notify(new GraphNotification(this, GraphNotification.NotificationType.Error, $"Python: While executing init function: {e.Message}")); return; } var existingInputs = InputPorts.ToList(); var existingOutputs = OutputPorts.ToList(); using (var portDefs = new PyDict(callResult)) { using (var portInDefs = new PyList(portDefs["in"])) { foreach (var item in portInDefs) { var tuple = new PyTuple(item); var portName = new PyString(tuple.Get(0).Handle, false).Value; var portType = new PyString(tuple.Get(1).Handle, false).Value; var existingPort = existingInputs.FirstOrDefault(p => p.Name == portName); try { switch (portType) { case "data": if (existingPort != null) { if (!existingPort.DataType.Equals(PortDataTypes.TypeIdSignal1D)) { RemovePort(existingPort); new NodeSystemLib2.FormatData1D.InputPortData1D(this, portName); } existingInputs.Remove(existingPort); } else { new NodeSystemLib2.FormatData1D.InputPortData1D(this, portName); } break; case "value": if (existingPort != null) { if (!existingPort.DataType.Equals(PortDataTypes.TypeIdValueDouble)) { RemovePort(existingPort); new NodeSystemLib2.FormatValue.InputPortValueDouble(this, portName); } existingInputs.Remove(existingPort); } else { new NodeSystemLib2.FormatValue.InputPortValueDouble(this, portName); } break; default: Parent.Context.Notify(new GraphNotification(this, GraphNotification.NotificationType.Error, $"Python: unknown port format '{portType}' for input port named {portName}")); break; } } catch (Exception e) { Parent.Context.Notify(new GraphNotification(this, GraphNotification.NotificationType.Error, $"Python: error while processing input port: {portName}: {e.Message}")); } } } foreach (var port in existingInputs) { RemovePort(port); } using (var portOutDefs = new PyList(portDefs["out"])) { foreach (var item in portOutDefs) { var tuple = new PyTuple(item); var portName = new PyString(tuple.Get(0).Handle, false).Value; var portType = new PyString(tuple.Get(1).Handle, false).Value; var existingPort = existingOutputs.FirstOrDefault(p => p.Name == portName); try { switch (portType) { case "data": if (existingPort != null) { if (!existingPort.DataType.Equals(PortDataTypes.TypeIdSignal1D)) { RemovePort(existingPort); new NodeSystemLib2.FormatData1D.OutputPortData1D(this, portName); } existingOutputs.Remove(existingPort); } else { new NodeSystemLib2.FormatData1D.OutputPortData1D(this, portName); } break; case "value": if (existingPort != null) { if (!existingPort.DataType.Equals(PortDataTypes.TypeIdValueDouble)) { RemovePort(existingPort); new NodeSystemLib2.FormatValue.OutputPortValueDouble(this, portName); } existingOutputs.Remove(existingPort); } else { new NodeSystemLib2.FormatValue.OutputPortValueDouble(this, portName); } break; default: Parent.Context.Notify(new GraphNotification(this, GraphNotification.NotificationType.Error, $"Python: unknown port format '{portType}' for output port named {portName}")); break; } } catch (Exception e) { Parent.Context.Notify(new GraphNotification(this, GraphNotification.NotificationType.Error, $"Python: error while processing output port: {portName}: {e.Message}")); } } } } }