public ConvertToHsv() { _input = new InputPin("Input", PinMediaType.Image); AddPin(_input); _output = new OutputPin("HSV", PinMediaType.Image); AddPin(_output); }
/// <summary> /// /// </summary> /// <param name="InPins"></param> /// <returns></returns> public static string GetSimulationResult(bool[] InPins) { string Result = string.Empty; Result = "Simulation Result:\n"; PrivtFieldName(ref Result); // 設定input value至input pins,並輸出input value for (int i = 1; i < InPins.Length; i++) { iPins[i].iPins = InPins[i]; Result += Convert.ToInt32(InPins[i]) + " "; } // 輸出結果 Result += "|"; foreach (OPin OutputPin in oPins) { Result += (" " + Convert.ToInt32(OutputPin.GetOutput())); } Result += ("\n"); return(Result); }
private void OnChangedCountOfCopies(object obj) { if (!(obj is int)) { return; } int copies = (int)obj; if (_outputs.Count == copies) { return; } lock (_outputs) { foreach (IPin outputPin in _outputs) { outputPin.Disconnect(); RemovePin(outputPin); } _outputs.Clear(); for (uint i = 0; i < copies; i++) { var outputPin = new OutputPin("Copy № " + (i + 1), PinMediaType.Image); _outputs.Add(outputPin); AddPin(outputPin); } } }
public DynamicAdder(int bits) { fullAdders = new FullAdder[bits]; var inputPinSeriesA = new InputPin[bits]; var inputPinSeriesB = new InputPin[bits]; var outputPinSeriesSum = new OutputPin[bits]; FullAdder previousFullAdder = null; for (var i = 0; i < bits; i++) { var fullAdder = new FullAdder(); if (previousFullAdder != null) { previousFullAdder.CarryOver.ConnectTo(fullAdder.CarryIn); } fullAdders[i] = fullAdder; inputPinSeriesA[i] = fullAdder.InputA; inputPinSeriesB[i] = fullAdder.InputB; outputPinSeriesSum[i] = fullAdder.Sum; previousFullAdder = fullAdder; } Overflow = previousFullAdder.CarryOver; InputA = new InputPinSeries(inputPinSeriesA); InputB = new InputPinSeries(inputPinSeriesB); Sum = new OutputPinSeries(outputPinSeriesSum); }
public void SetOutput(OutputPin outputPin, double voltage, double vRef) { byte control = LoadA | LoadB; switch (outputPin) { case OutputPin.DAC0: control |= SelectA; break; case OutputPin.DAC1: control |= SelectB; break; default: throw new ArgumentOutOfRangeException(nameof(outputPin), outputPin, null); } ushort volt16Bit = Get16BitVoltage(voltage, vRef); byte[] data = { control, (byte)(volt16Bit >> 8), (byte)(volt16Bit & 0xff) }; SpiComm.Operate(spiDevice => spiDevice.Write(data)); }
public void ChangeCircutState(OutputPin pin) { LogHelper.LogMessage("GpioInterface ChangeCircutState invoked: {0} - {1}", DateTime.Now, pin); var connectorPin = MapOutputPin(pin); gpioConnection.Blink(connectorPin, BlinkDurationMilis); }
public Not() { _input = new InputPin("Input", PinMediaType.Image); AddPin(_input); _output = new OutputPin("Not", PinMediaType.Image); AddPin(_output); }
public override void _Process(float delta) { if (LastInputPinPressed != null && LastOutputPinPressed != null) { LastInputPinPressed.ConnectedPin = LastOutputPinPressed; LastInputPinPressed = null; LastOutputPinPressed = null; } }
private void ChangePortState(OutputPin outputPin, PortStates portState) { var gpioPinValue = PortStateToGpioPinValue(portState); if (gpioPinValue.HasValue) { outputPin.GpioPinValue = gpioPinValue.Value; } }
public MSER() { var mserDetector = new MSERDetector(); _deltaProperty = new IntegerProperty("Delta", 1, 100, 1) { Value = mserDetector.Delta }; _maxAreaProperty = new IntegerProperty("MaxArea", 10, 288000, 250) { Value = mserDetector.MaxArea }; _minAreaProperty = new IntegerProperty("MinArea", 1, 16000, 100) { Value = mserDetector.MinArea }; _maxVariationProperty = new FloatProperty("MaxVariation", 0, 1, (decimal)0.01f, 2) { Value = mserDetector.MaxVariation }; _minDiversityProperty = new FloatProperty("MinDiversity", 0, 1, (decimal)0.01f, 2) { Value = mserDetector.MinDiversity }; _maxEvolutionProperty = new IntegerProperty("MaxEvolution", 0, 1000, 1) { Value = mserDetector.MaxEvolution }; _areaThresholdProperty = new FloatProperty("AreaThreshold", 0, 5, (decimal)0.01f, 2) { Value = (float)mserDetector.AreaThreshold }; _minMarginProperty = new FloatProperty("MinMargin", 0, 1, (decimal)0.001f, 3) { Value = (float)mserDetector.MinMargin }; _edgeBlurSizeProperty = new IntegerProperty("EdgeBlurSize", 0, 100, 1) { Value = mserDetector.EdgeBlurSize }; AddProperty(_deltaProperty); AddProperty(_maxAreaProperty); AddProperty(_minAreaProperty); AddProperty(_maxVariationProperty); AddProperty(_minDiversityProperty); AddProperty(_maxEvolutionProperty); AddProperty(_areaThresholdProperty); AddProperty(_minMarginProperty); AddProperty(_edgeBlurSizeProperty); _input = new InputPin("Image", PinMediaType.Image); _output = new OutputPin("Contours", PinMediaType.ContoursArray); AddPin(_input); AddPin(_output); }
public Clone() { _countProperty = new IntegerProperty("Count of copies", 0, 10, 1); _countProperty.OnValueChanged += OnChangedCountOfCopies; AddProperty(_countProperty); _input = new InputPin("Input", PinMediaType.Image); AddPin(_input); _originalOutput = new OutputPin("Original", PinMediaType.Image); AddPin(_originalOutput); }
public FastNlMeansDenoisingColored() { _areaSizeProperty = new IntegerProperty("Area size", 0, 10, 1); AddProperty(_areaSizeProperty); _input = new InputPin("Input 0", PinMediaType.Image); AddPin(_input); _output = new OutputPin("And", PinMediaType.Image); AddPin(_output); }
public Merge() { _output = new OutputPin("Output", PinMediaType.Image); _inputB = new InputPin("B", PinMediaType.Image); _inputG = new InputPin("G", PinMediaType.Image); _inputR = new InputPin("R", PinMediaType.Image); AddPin(_output); AddPin(_inputR); AddPin(_inputG); AddPin(_inputB); }
public FullSubtracter() { InputA = halfSubtracter1.InputA; InputB = halfSubtracter1.InputB; halfSubtracter1.Sub.ConnectTo(halfSubtracter2.InputA); CarryIn = halfSubtracter2.InputB; or.InputA.ConnectTo(halfSubtracter1.CarryOver); or.InputB.ConnectTo(halfSubtracter2.CarryOver); CarryOver = or.Output; Sub = halfSubtracter2.Sub; }
public SourceFileImage() { _filepathProperty = new Property("FilePath", FilterPropertyType.String) { Value = "filename.png" }; AddProperty(_filepathProperty); _outputPin = new OutputPin("Image", PinMediaType.Image); AddPin(_outputPin); }
public SplitRgb() { _input = new InputPin("Input", PinMediaType.Image); _outputB = new OutputPin("B", PinMediaType.Image); _outputG = new OutputPin("G", PinMediaType.Image); _outputR = new OutputPin("R", PinMediaType.Image); AddPin(_input); AddPin(_outputR); AddPin(_outputG); AddPin(_outputB); }
public Or() { _input0 = new InputPin("Input 0", PinMediaType.Image); AddPin(_input0); _input1 = new InputPin("Input 1", PinMediaType.Image); AddPin(_input1); _output = new OutputPin("Or", PinMediaType.Image); AddPin(_output); }
public SplitHsv() { _input = new InputPin("Input", PinMediaType.Image); _outputH = new OutputPin("H", PinMediaType.Image); _outputS = new OutputPin("S", PinMediaType.Image); _outputV = new OutputPin("V", PinMediaType.Image); AddPin(_input); AddPin(_outputH); AddPin(_outputS); AddPin(_outputV); }
public FullAdder() { InputA = halfAdder1.InputA; InputB = halfAdder1.InputB; halfAdder1.Sum.ConnectTo(halfAdder2.InputA); CarryIn = halfAdder2.InputB; or.InputA.ConnectTo(halfAdder1.CarryOver); or.InputB.ConnectTo(halfAdder2.CarryOver); CarryOver = or.Output; Sum = halfAdder2.Sum; }
private ConnectorPin MapOutputPin(OutputPin outputPin) { var pin = _outputPins.SingleOrDefault(ip => ip.Item1 == outputPin); if (pin == null) { var errMsg = $"Invalid value: {outputPin}"; throw new ArgumentOutOfRangeException(errMsg); } return(pin.Item2); }
public InRange() { _minProperty = new IntegerProperty("Min value", 0, 255, 1); AddProperty(_minProperty); _maxProperty = new IntegerProperty("Max value", 0, 255, 1); AddProperty(_maxProperty); _input = new InputPin("Input", PinMediaType.Image); AddPin(_input); _output = new OutputPin("Filtered", PinMediaType.Image); AddPin(_output); }
/// <summary> /// Versucht den DVB.NET Datenstrom direkt mit dem zugehörigen Decoder zu verbinden. /// </summary> /// <param name="decoder">Ein manuell angelegter Decoder.</param> /// <param name="source">Der zu verwendende Ausgang.</param> /// <param name="mediaType">Das verwendete Format.</param> /// <returns>Gesetzt, wenn die Verbindung aufgebaut wurde.</returns> private bool TryDirectConnect(TypedComIdentity <IBaseFilter> decoder, OutputPin source, MediaType mediaType) { // In normal cases we should directly connect to the filter so try var connected = false; // Try manual connect decoder.InspectAllPins(p => p.QueryDirection() == PinDirection.Input, pin => { // Skip on error try { // Get the raw interface for the media type var type = mediaType.GetReference(); // Process using (var iFace = ComIdentity.Create <IPin>(pin)) source.Connect(iFace.Interface, type); // Did it connected = true; } catch (Exception) { } // First pin only - even if it can not be used! return(false); }); // Failed if (!connected) { return(false); } // Find the output of the decoder and render it decoder.InspectAllPins(p => p.QueryDirection() == PinDirection.Output, pin => { // Create helper using (var pinWrapper = ComIdentity.Create <IPin>(pin)) DirectShowObject.Render(pinWrapper.Interface); // Did it return(false); }); // Report return(connected); }
public override void Process() { FireProcessingStateChanged(ProcessingState.Started); var frame = (IImage)_input.GetData(); lock (_outputs) { for (int index = 0; index < _outputs.Count; index++) { OutputPin outputPin = _outputs[index]; object clone = frame.Clone(); outputPin.SetData(clone); FireProcessingProgressChanged((index + 1) / (double)_outputs.Count); } } _originalOutput.SetData(frame); FireProcessingStateChanged(ProcessingState.Finished); }
private static void Main(string[] args) { var pin11 = new OutputPin(GpioPinNumber.Gpio11); var pin2 = new OutputPin(GpioPinNumber.Gpio17); Console.WriteLine("Press ESC to stop"); while (!(Console.KeyAvailable && Console.ReadKey(true).Key == ConsoleKey.Escape)) { pin11.Write(State.Low); pin2.Write(State.High); Thread.Sleep(750); pin11.Write(State.High); pin2.Write(State.Low); Thread.Sleep(750); } pin11.Cleanup(); pin2.Cleanup(); }
public async Task SET(OutputPin Pin) { if (GPIOCOM != null) { if ((Pin.GPIOBitmask & OutputRegister) == 0) { await GPIOIOLock.WaitAsync(); var resp = await GPIOCOM.GPIOWriteAsync(GPIOStation, Flag.GetIOInPut, null); if (resp != null) { InputRegister = BitConverter.ToUInt16(resp, 3); OutputRegister = BitConverter.ToUInt16(resp, 5); OutputRegister |= (Pin.GPIOBitmask); await GPIOCOM.GPIOWriteAsync(GPIOStation, Flag.SetIOOutput, BitConverter.GetBytes(OutputRegister)); } GPIOIOLock.Release(); } } }
private void CreateAppendAndConfigure(IEnumerable <PinConfiguration> pinConfigurations, RaspyberryPiPort[] raspyberryPiPorts) { foreach (var pinConfiguration in pinConfigurations) { var port = raspyberryPiPorts.First(p => p.PinId == pinConfiguration.PinId); switch (pinConfiguration.PortType) { case PortTypes.Switch: _outputPins.Add(OutputPin.CreateSwitch(pinConfiguration.PinId)); break; case PortTypes.Pulse: var defaultGpioValue = PortStateToGpioPinValue(port.DefaultPortState); _outputPins.Add(OutputPin.CreatePulse(pinConfiguration.PinId, defaultGpioValue.Value, port.PulseLength)); break; } _pinConfigurations.Add(pinConfiguration); ChangePortState(port.PortName, port.PortState); } }
public Subtracter8Bit() { InputA = new InputPinSeries(fullSubtracter1.InputA, fullSubtracter2.InputA, fullSubtracter3.InputA, fullSubtracter4.InputA, fullSubtracter5.InputA, fullSubtracter6.InputA, fullSubtracter7.InputA, fullSubtracter8.InputA); InputB = new InputPinSeries(fullSubtracter1.InputB, fullSubtracter2.InputB, fullSubtracter3.InputB, fullSubtracter4.InputB, fullSubtracter5.InputB, fullSubtracter6.InputB, fullSubtracter7.InputB, fullSubtracter8.InputB); Sub = new OutputPinSeries(fullSubtracter1.Sub, fullSubtracter2.Sub, fullSubtracter3.Sub, fullSubtracter4.Sub, fullSubtracter5.Sub, fullSubtracter6.Sub, fullSubtracter7.Sub, fullSubtracter8.Sub); fullSubtracter1.CarryOver.ConnectTo(fullSubtracter2.CarryIn); fullSubtracter2.CarryOver.ConnectTo(fullSubtracter3.CarryIn); fullSubtracter3.CarryOver.ConnectTo(fullSubtracter4.CarryIn); fullSubtracter4.CarryOver.ConnectTo(fullSubtracter5.CarryIn); fullSubtracter5.CarryOver.ConnectTo(fullSubtracter6.CarryIn); fullSubtracter6.CarryOver.ConnectTo(fullSubtracter7.CarryIn); fullSubtracter7.CarryOver.ConnectTo(fullSubtracter8.CarryIn); Overflow = fullSubtracter8.CarryOver; }
/// <summary> /// Versucht den DVB.NET Datenstrom direkt mit dem zugehörigen Decoder zu verbinden. /// </summary> /// <param name="decoder">Ein manuell angelegter Decoder.</param> /// <param name="source">Der zu verwendende Ausgang.</param> /// <param name="mediaType">Das verwendete Format.</param> /// <returns>Gesetzt, wenn die Verbindung aufgebaut wurde.</returns> private bool TryDirectConnect( TypedComIdentity<IBaseFilter> decoder, OutputPin source, MediaType mediaType ) { // In normal cases we should directly connect to the filter so try var connected = false; // Try manual connect decoder.InspectAllPins( p => p.QueryDirection() == PinDirection.Input, pin => { // Skip on error try { // Get the raw interface for the media type var type = mediaType.GetReference(); // Process using (var iFace = ComIdentity.Create<IPin>( pin )) source.Connect( iFace.Interface, type ); // Did it connected = true; } catch (Exception) { } // First pin only - even if it can not be used! return false; } ); // Failed if (!connected) return false; // Find the output of the decoder and render it decoder.InspectAllPins( p => p.QueryDirection() == PinDirection.Output, pin => { // Create helper using (var pinWrapper = ComIdentity.Create<IPin>( pin )) DirectShowObject.Render( pinWrapper.Interface ); // Did it return false; } ); // Report return connected; }
public static NodeGraphManager BuildGraph(GraphEditorViewModel graph) { List <VisualNodeViewModel> visualExecutionNodes = new List <VisualNodeViewModel>(); foreach (var graphComponent in graph.VisualNodes) { VisualNodeViewModel visualNode = graphComponent as VisualNodeViewModel; if (visualNode != null && visualNode.ExecutionInputs.Count > 0) { visualExecutionNodes.Add(visualNode); } } // Begin to build our graph NodeGraphManager graphManager = new NodeGraphManager(); Dictionary <VisualNodeViewModel, GraphNode> functionNodes = new Dictionary <VisualNodeViewModel, GraphNode>(); List <VisualConstantNodeViewModel> constantNodes = new List <VisualConstantNodeViewModel>(); foreach (dynamic visualNode in graph.VisualNodes) { if (visualNode is VisualNodeViewModel) { functionNodes.Add(visualNode, new GraphNode(visualNode.NodeType, graphManager)); } else if (visualNode is VisualConstantNodeViewModel) { constantNodes.Add(visualNode as VisualConstantNodeViewModel); } } // Wire up constant nodes foreach (var constantNode in constantNodes) { List <ConnectionViewModel> connections = GetPinConnections(constantNode.OutputPin, graph); // Lookup each input pin that the constant node is connecting to and add it in our graph manager foreach (var connection in connections) { foreach (var functionNode in functionNodes) { if (functionNode.Key.Inputs.Contains(connection.InputPin)) { // Get pin index int pindex = ((NodePinViewModel)connection.InputPin).Index; IDataTypeContainer valueToSet; // Get value to set if (constantNode.OutputPin.DataType == typeof(DataTypes.Numeric)) { valueToSet = new DataTypes.Numeric(Double.Parse(constantNode.Value)); } else if (constantNode.OutputPin.DataType == typeof(DataTypes.Boolean)) { valueToSet = new DataTypes.Boolean(Boolean.Parse(constantNode.Value)); } else if (constantNode.OutputPin.DataType == typeof(DataTypes.String)) { valueToSet = new DataTypes.String(constantNode.Value); } else { throw new Exception("Data type could not be determined."); } OutputPin pinConnection = new OutputPin( ((NodePinViewModel)connection.InputPin).DataType, null) { OutputValue = valueToSet, OutputRealised = true }; graphManager.AddConnection(pinConnection, functionNode.Value.NodeInputs[pindex]); } } } } // Wire up functional nodes foreach (var functionNode in functionNodes) { int outputPindex = 0; // Check each output pin on the node foreach (var output in functionNode.Key.Outputs) { List <ConnectionViewModel> connections = GetPinConnections(output, graph); foreach (var connection in connections) { // Wire up non-execution pins foreach (var targetFunctionNode in functionNodes) { if (targetFunctionNode.Key.Inputs.Contains(connection.InputPin)) { int pindex = ((NodePinViewModel)connection.InputPin).Index; graphManager.AddConnection( functionNodes[functionNode.Key].NodeOutputs[outputPindex], targetFunctionNode.Value.NodeInputs[pindex]); } } } } // Wire up execution pins foreach (var executionOutput in functionNode.Key.ExecutionOutputs) { List <ConnectionViewModel> connections = GetPinConnections(executionOutput, graph); if (connections.Count == 0) { graphManager.AddNode(functionNode.Value); } foreach (var connection in connections) { foreach (var targetFunctionNode in functionNodes) { if (targetFunctionNode.Key.ExecutionInputs.Contains(connection.InputPin)) { int pindex = ((NodePinViewModel)connection.OutputPin).Index; graphManager.AddConnection(functionNode.Value, pindex, targetFunctionNode.Value); } } } } } graphManager.RealiseNodeOutputs(); return(graphManager); }
/// <summary> /// Sets input and output PinTarget for this connection</summary> public void SetPinTarget() { if (InputPin != null) { bool isInputElementRef = InputElement.DomNode.Is <IReference <DomNode> >(); if (InputPin.Is <GroupPin>()) { if (isInputElementRef) { var pinTarget = InputPin.Cast <GroupPin>().PinTarget; InputPinTarget = new PinTarget(pinTarget.LeafDomNode, pinTarget.LeafPinIndex, InputElement.DomNode); } else { InputPinTarget = InputPin.Cast <GroupPin>().PinTarget; } } else { if (isInputElementRef) { var reference = InputElement.As <IReference <DomNode> >(); InputPinTarget = new PinTarget(reference.Target, InputPin.Index, InputElement.DomNode); } else { InputPinTarget = new PinTarget(InputElement.DomNode, InputPin.Index, null); } } Debug.Assert(InputPinTarget != null, "sanity check"); } if (OutputPin != null) { bool isOutputElementRef = OutputElement.DomNode.Is <IReference <DomNode> >(); if (OutputPin.Is <GroupPin>()) { if (isOutputElementRef) { var pinTarget = OutputPin.Cast <GroupPin>().PinTarget; OutputPinTarget = new PinTarget(pinTarget.LeafDomNode, pinTarget.LeafPinIndex, OutputElement.DomNode); } else { OutputPinTarget = OutputPin.Cast <GroupPin>().PinTarget; } } else { if (isOutputElementRef) { var reference = OutputElement.Cast <IReference <DomNode> >(); OutputPinTarget = new PinTarget(reference.Target, OutputPin.Index, OutputElement.DomNode); } else { OutputPinTarget = new PinTarget(OutputElement.DomNode, OutputPin.Index, null); } } Debug.Assert(OutputPinTarget != null, "sanity check"); } }
public void addPins(ActionNode an, XElement node) { foreach (XElement pins in node.Elements()) { if (pins.Name.LocalName == "argument") { MascaretApplication.Instance.VRComponentFactory.Log("ARGUMENT PIN ################################"); XAttribute att = pins.Attribute("{http://www.omg.org/spec/XMI/20131001}type"); if (att == null) att = pins.Attribute("{http://schema.omg.org/spec/XMI/2.1}type"); if (att != null) MascaretApplication.Instance.VRComponentFactory.Log(att.Value); if (att != null && att.Value == "uml:ValuePin") { ValuePin valuePin = new ValuePin(); XAttribute attID = pins.Attribute("{http://schema.omg.org/spec/XMI/2.1}id"); if (attID == null) attID = pins.Attribute("{http://www.omg.org/spec/XMI/20131001}id"); string id = attID.Value; string name = pins.Attribute("name").Value; MascaretApplication.Instance.VRComponentFactory.Log("Pin Name : " + name); valuePin.Id = id; valuePin.name = name; string strType = ""; XElement typeNode = pins.Element("type"); if (typeNode == null) { // Check if it's an attribute string typeId = pins.Attribute("type").Value; if (_primitiveTypes.ContainsKey(typeId)) strType = _primitiveTypes[typeId]; } else { XAttribute attr = (XAttribute)typeNode.Attribute("href"); if (attr != null) strType = attr.Value.Substring(attr.Value.IndexOf("#") + 1); } MascaretPrimitiveType attributeType = model.getBasicType(strType.ToLower()); valuePin.ResourceType = attributeType; string strValue = ""; XElement valueNode = pins.Element("value"); XAttribute attrV = (XAttribute)valueNode.Attribute("value"); if (attrV != null) strValue = attrV.Value; MascaretApplication.Instance.VRComponentFactory.Log("Valeur : " + strValue); valuePin.ValueSpec = attributeType.createValueFromString(strValue); /*Classifier ressourceType = getObjectNodeType(pins); if(ressourceType != null) valuePin.ResourceType = ressourceType;*/ an.Action.ValuePins.Add(valuePin); _objectNodes.Add(valuePin.Id, valuePin); } else { InputPin inputPin = new InputPin(); inputPin.Id = pins.Attribute("{http://schema.omg.org/spec/XMI/2.1}id").Value; if (inputPin.Id == null) inputPin.Id = pins.Attribute("{http://www.omg.org/spec/XMI/20131001}id").Value; inputPin.name = pins.Attribute("name").Value; Classifier ressourceType = getObjectNodeType(pins); if (ressourceType != null) inputPin.ResourceType = ressourceType; //Debug.Log(" AN : " + an); an.Action.InputPins.Add(inputPin); _objectNodes.Add(inputPin.Id, inputPin); } } else if (pins.Name.LocalName == "result") { OutputPin outputPin = new OutputPin(); outputPin.Id = pins.Attribute("id").Value; outputPin.name = pins.Attribute("name").Value; Classifier ressourceType = getObjectNodeType(pins); if (ressourceType != null) outputPin.ResourceType = ressourceType; an.Action.OutputPins.Add(outputPin); _objectNodes.Add(outputPin.Id, outputPin); } } }
public Gate(string name = null) { Name = name; Output = new OutputPin(this, Operation); }