private void InitWriters() { foreach (var input in InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>().Where(c => c.Connection != null)) { var path = GetFilename(input, "bin"); var writer = new Stream1DWriter( new System.IO.BinaryWriter( File.Open(path, FileMode.Create) ) ); _writers.Add(input, new WriterObject { Path = path, Writer = writer }); } foreach (var input in InputPorts.OfType <NodeSystemLib2.FormatValue.InputPortValueDouble>().Except(new[] { _portEn }).Where(c => c.Connection != null)) { var path = GetFilename(input, "csv"); var writer = new Stream2DWriter( File.CreateText(path), ',' ); _writers.Add(input, new WriterObject { Path = path, Writer = writer }); } }
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 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(); } }
private void Recorder2_PortConnectionChanged(object sender, ConnectionModifiedEventArgs e) { if (changingConnections) { return; } changingConnections = true; UpdateInputPorts(); var dataInputs = InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>(); if (dataInputs.All(d => d.Connection != null)) { var p = new NodeSystemLib2.FormatData1D.InputPortData1D(this, $"DIn {dataInputs.Count() + 1}"); AddPort(p, EnablePortIndex); } var valueInputs = InputPorts.OfType <NodeSystemLib2.FormatValue.InputPortValueDouble>().Except(new [] { _portEn }); if (valueInputs.All(d => d.Connection != null)) { var p = new NodeSystemLib2.FormatValue.InputPortValueDouble(this, $"VIn {valueInputs.Count() + 1}"); AddPort(p, EnablePortIndex); } changingConnections = false; }
private void Textbox_TextChanged(object sender, TextChangedEventArgs e) { var stextBox = sender as RichTextBox; var textBox = new TextRange(stextBox.Document.ContentStart, stextBox.Document.ContentEnd); if (textBox != null) { if (textBox.Text != "") { expression = new Expression(textBox.Text); var paras = GetParametersInExpression(textBox.Text).Distinct().ToList(); if (paras.Any()) { RemoveAllInputPortsFromNode(paras); var filteredParas = paras.Where(parameter => InputPorts.All(p => p.Name != parameter)).ToList(); foreach (var parameter in filteredParas) { AddInputPortToNode(parameter, typeof(object)); } } } else { expression = null; RemoveAllInputPortsFromNode(); } } Calculate(); }
void Init() { PortGather = new CommunicationGather(Communication, '\x0d'); PortGather.LineReceived += this.Port_LineReceived; CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "\x02QPW\x03"); // Query Power InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.CompositeIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Composite, new Action(InputVideo1), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, new Action(InputVga), this)); VolumeLevelFeedback = new IntFeedback(() => { return(_VolumeLevel); }); MuteFeedback = new BoolFeedback(() => _IsMuted); // new BoolCueActionPair(CommonBoolCue.Menu, b => { if(b) Send(MenuIrCmd); }), // new BoolCueActionPair(CommonBoolCue.Up, b => { if(b) Send(UpIrCmd); }), // new BoolCueActionPair(CommonBoolCue.Down, b => { if(b) Send(DownIrCmd); }), // new BoolCueActionPair(CommonBoolCue.Left, b => { if(b) Send(LeftIrCmd); }), // new BoolCueActionPair(CommonBoolCue.Right, b => { if(b) Send(RightIrCmd); }), // new BoolCueActionPair(CommonBoolCue.Select, b => { if(b) Send(SelectIrCmd); }), // new BoolCueActionPair(CommonBoolCue.Exit, b => { if(b) Send(ExitIrCmd); }), //}; }
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); }
/// <summary> /// Intial logic to set up instance /// </summary> void Init() { // Will gather to the specified delimiter PortGather = new CommunicationGather(Communication, '\x03'); PortGather.LineReceived += this.Port_LineReceived; // Constuct the CommunicationMonitor CommunicationMonitor = new GenericCommunicationMonitor(this, Communication, 30000, 120000, 300000, "\x02QPW\x03\x02QMI\x03"); // Query Power // Define the input ports InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn1, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, new Action(InputHdmi1), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.HdmiIn2, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, new Action(InputHdmi2), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.DviIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Dvi, new Action(InputDvi1), this)); InputPorts.Add(new RoutingInputPort(RoutingPortNames.VgaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Vga, new Action(InputVga), this)); // Define the feedback Funcs VolumeLevelFeedback = new IntFeedback(() => { return(_VolumeLevel); }); MuteFeedback = new BoolFeedback(() => _IsMuted); InputNumberFeedback = new IntFeedback(() => { Debug.Console(2, this, "CHange Input number {0}", InputNumber); return(InputNumber); }); // Set the warmup time WarmupTime = 17000; }
public void AddInputPortToNode(string name, Type type) { var conn = new Port(name, this, PortTypes.Input, type); InputPortPanel.Children.Add(conn); conn.DataChanged += conn_DataChanged; InputPorts.Add(conn); }
/// <summary> /// Adds InputPort /// </summary> void AddInputPortWithDebug(uint cardNum, string portName, eRoutingSignalType sigType, eRoutingPortConnectionType portType) { var portKey = string.Format("inputCard{0}--{1}", cardNum, portName); Debug.Console(2, this, "Adding input port '{0}'", portKey); var inputPort = new RoutingInputPort(portKey, sigType, portType, cardNum, this); InputPorts.Add(inputPort); }
public override void OnSelectionChanged(object sender, EventArgs e) { base.OnSelectionChanged(sender, e); foreach (var conn in InputPorts.Concat(OutputPorts).SelectMany(port => port.ConnectedConnectors)) { conn.IsSelected = IsSelected; } }
private IntPtr ReadDataPort(IntPtr self, IntPtr args) { var argTuple = new PyTuple(new PyObject(args, false)); var portName = argTuple.Get(0).GetString(); var dataPort = InputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.InputPortData1D; var buffer = dataPort.Read(); return(new PyArray(buffer.Data.Take(buffer.Available).ToArray(), false).Object.Handle); }
/// <summary> /// /// </summary> void UpdateInputFb(byte b) { var newInput = InputPorts.FirstOrDefault(i => i.FeedbackMatchObject.Equals(b)); if (newInput != null && newInput != _CurrentInputPort) { _CurrentInputPort = newInput; CurrentInputFeedback.FireUpdate(); } }
public void RemoveInputPortFromNode(Port conn) { foreach (var connector in conn.ConnectedConnectors) { connector.RemoveFromCanvas(); } InputPortPanel.Children.Remove(conn); conn.DataChanged -= conn_DataChanged; InputPorts.Remove(conn); }
private new void AddInputPort(Port portReference, Func <string> requestCode, bool alsoAddToHierarchy = true) { var inputPort = new InputPort(this, portReference, requestCode); InputPorts.Add(inputPort); InputPortDictionary.Add(portReference, inputPort); if (alsoAddToHierarchy) { inputContainer.Add(portReference); } }
private void RemoveLastUnusedInputPortOf <T>() where T : InputPort { foreach (var p in InputPorts.OfType <T>().Reverse()) { if (p.Connection == null) { RemovePort(p); break; } } }
public void RemoveInputPortFromNode(Port port) { foreach (var connector in port.ConnectedConnectors) { connector.RemoveFromCanvas(); } InputPortPanel.Children.Remove(port); port.DataChanged -= port_DataChanged; InputPorts.Remove(port); }
public void AddInputPortToNode(string name, Type type, bool multipleConnectionsAllowed = false) { var port = new Port(name, this, PortTypes.Input, type) { MultipleConnectionsAllowed = multipleConnectionsAllowed }; InputPortPanel.Children.Add(port); port.DataChanged += port_DataChanged; InputPorts.Add(port); }
public override (float rawDuration, float duration) CalculateDuration() { float rawDuration = 0f, duration = 0f; InputPorts.ForEach(p => { duration += p.Link.OutputPort.Node.Duration * p.Weight; rawDuration += p.Link.OutputPort.Node.RawDuration * p.Weight; }); return(rawDuration, duration); }
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(); }
protected override Playable OnCreatePlayable(PlayableGraph playableGraph) { AnimationMixerPlayable playable = AnimationMixerPlayable.Create(playableGraph); playable.SetInputCount(InputPorts.Count); InputPorts.ForEach(inputPort => { inputPort.Weight = inputPort.Weight; }); return(playable); }
public NodeInputPort CreateInputPort(float weight = 1f) { NodeInputPort port = new NodeInputPort { Node = this, Index = InputPorts.Count, Weight = weight }; Playable.SetInputCount(Playable.GetInputCount() + 1); Playable.SetInputWeight(port.Index, weight); InputPorts.Add(port); return(port); }
private void AddConns(int connNumber) { if (connNumber == 1) { RemoveInputPortFromNode(InputPorts.Last()); } else { for (var i = 0; i < connNumber - 2; i++) { AddInputPortToNode("Item" + (i + 1), typeof(object)); } } }
public Blendspace1DNodeInputPort CreateInputPort(float threshold) { Blendspace1DNodeInputPort port = new Blendspace1DNodeInputPort { Node = this, Index = InputPorts.Count, Threshold = threshold }; Playable.SetInputCount(Playable.GetInputCount() + 1); InputPorts.Add(port); RecalculateWeights(); return(port); }
void EndRecording() { if (_recording) { System.Diagnostics.Debug.WriteLine("End recording"); var record = new Record(); foreach (var input in InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>().Where(c => c.Connection != null)) { var writer = _writers[input]; var line = new RecordLineStream1D( DateTime.Now, writer.FirstWritten, writer.LastWritten, GetRelativePath(writer.Path, WorkingDirectory), input.Samplerate ); record.Lines.Add(line); } foreach (var input in InputPorts.OfType <NodeSystemLib2.FormatValue.InputPortValueDouble>().Where(c => c.Connection != null && c != _portEn)) { var writer = _writers[input]; var line = new RecordLineStream2D( DateTime.Now, writer.FirstWritten, writer.LastWritten, GetRelativePath(writer.Path, WorkingDirectory) ); record.Lines.Add(line); } _set.AddRecord(record); RecordSetWriter.WriteToFile(_set, System.IO.Path.Combine(WorkingDirectory, "index.lst")); foreach (var writer in _writers.Values.Select(v => v.Writer).OfType <IDisposable>()) { writer.Dispose(); } _writers.Clear(); _recording = false; } }
/// <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 IntPtr GetSamplerate(IntPtr self, IntPtr args) { var argTuple = new PyTuple(new PyObject(args, false)); var portName = argTuple.Get(0).GetString(); var dataPort = InputPorts.First(port => port.Name == portName) as NodeSystemLib2.FormatData1D.InputPortData1D; double samplerate = 0; if (dataPort != null) { samplerate = dataPort.Samplerate; } return(new PyFloat(samplerate, false).Handle); }
private void UpdateInputPorts() { var dataInputs = InputPorts.OfType <NodeSystemLib2.FormatData1D.InputPortData1D>().ToArray(); var valueInputs = InputPorts.OfType <NodeSystemLib2.FormatValue.InputPortValueDouble>().Except(new [] { _portEn }).ToArray(); var changed = true; while (changed) { changed = false; for (int i = 0; i < dataInputs.Length - 1; i++) { if (dataInputs[i].Connection == null && dataInputs[i + 1].Connection != null) { var output = dataInputs[i + 1].Connection; Parent.Disconnect(dataInputs[i + 1].Connection, dataInputs[i + 1]); Parent.Connect(output, dataInputs[i]); changed = true; } } } changed = true; while (changed) { changed = false; for (int i = 0; i < valueInputs.Length - 1; i++) { if (valueInputs[i].Connection == null && valueInputs[i + 1].Connection != null) { var output = valueInputs[i + 1].Connection; Parent.Disconnect(valueInputs[i + 1].Connection, valueInputs[i + 1]); Parent.Connect(output, valueInputs[i]); changed = true; } } } for (int i = InputPorts.Count - 1; i >= 0; i--) { if (InputPorts[i].Connection == null) { if (InputPorts[i] != _firstValueIn && InputPorts[i] != _firstDataIn && InputPorts[i] != _portEn) { RemovePort(InputPorts[i]); } } } }
public AirMediaController(string key, string name, AmX00 device, DeviceConfig dc, AirMediaPropertiesConfig props) : base(key, name, device) { AirMedia = device; DeviceConfig = dc; PropertiesConfig = props; InputPorts.Add(new RoutingInputPort(DmPortName.Osd, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.None, new Action(SelectPinPointUxLandingPage), this)); InputPorts.Add(new RoutingInputPort(DmPortName.AirMediaIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Streaming, new Action(SelectAirMedia), this)); InputPorts.Add(new RoutingInputPort(DmPortName.HdmiIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.Hdmi, new Action(SelectHdmiIn), this)); InputPorts.Add(new RoutingInputPort(DmPortName.AirBoardIn, eRoutingSignalType.Video, eRoutingPortConnectionType.None, new Action(SelectAirboardIn), this)); if (AirMedia is Am300) { InputPorts.Add(new RoutingInputPort(DmPortName.DmIn, eRoutingSignalType.Audio | eRoutingSignalType.Video, eRoutingPortConnectionType.DmCat, new Action(SelectDmIn), this)); } AirMedia.AirMedia.AirMediaChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(AirMedia_AirMediaChange); IsInSessionFeedback = new BoolFeedback(new Func <bool>(() => AirMedia.AirMedia.StatusFeedback.UShortValue == 0)); ErrorFeedback = new IntFeedback(new Func <int>(() => AirMedia.AirMedia.ErrorFeedback.UShortValue)); NumberOfUsersConnectedFeedback = new IntFeedback(new Func <int>(() => AirMedia.AirMedia.NumberOfUsersConnectedFeedback.UShortValue)); LoginCodeFeedback = new IntFeedback(new Func <int>(() => AirMedia.AirMedia.LoginCodeFeedback.UShortValue)); ConnectionAddressFeedback = new StringFeedback(new Func <string>(() => AirMedia.AirMedia.ConnectionAddressFeedback.StringValue)); HostnameFeedback = new StringFeedback(new Func <string>(() => AirMedia.AirMedia.HostNameFeedback.StringValue)); // TODO: Figure out if we can actually get the TSID/Serial SerialNumberFeedback = new StringFeedback(new Func <string>(() => "unknown")); AirMedia.DisplayControl.DisplayControlChange += new Crestron.SimplSharpPro.DeviceSupport.GenericEventHandler(DisplayControl_DisplayControlChange); VideoOutFeedback = new IntFeedback(new Func <int>(() => Convert.ToInt16(AirMedia.DisplayControl.VideoOutFeedback))); AutomaticInputRoutingEnabledFeedback = new BoolFeedback(new Func <bool>(() => AirMedia.DisplayControl.EnableAutomaticRoutingFeedback.BoolValue)); AirMedia.HdmiIn.StreamChange += new Crestron.SimplSharpPro.DeviceSupport.StreamEventHandler(HdmiIn_StreamChange); HdmiVideoSyncDetectedFeedback = new BoolFeedback(new Func <bool>(() => AirMedia.HdmiIn.SyncDetectedFeedback.BoolValue)); }
public override void Calculate() { // Define the Input for the Script var parameters = InputPorts.Select(port => port.Data).ToList(); switch (scriptingControl.HighlightingComboBox.SelectedItem.ToString()) { case "C#": OutputPorts[0].Data = mScriptCompiler.Value.Run(parameters.ToArray()); break; case "Python": StartPythonCompilation(null, null); break; } }