private void OnConnectorsCollectionChanged(object sender, NotifyCollectionChangedEventArgs eventArgs) { switch (eventArgs.Action) { case NotifyCollectionChangedAction.Add: foreach (var c in eventArgs.NewItems.Cast <ConnectorViewModel>()) { AddConnector(c); } break; case NotifyCollectionChangedAction.Remove: foreach (var c in eventArgs.OldItems.Cast <ConnectorViewModel>()) { RemoveConnector(c); } break; case NotifyCollectionChangedAction.Reset: Inputs.Clear(); Outputs.Clear(); break; } RaisePropertyChanged(nameof(Height)); RaisePropertyChanged(nameof(Width)); }
public override void InitSequence() { Inputs.Clear(); Outputs.Clear(); _linearLayer.InitSequence(); _activationLayer.InitSequence(); }
public void SetOutput(NodeOutput op) { Outputs.Clear(); Output = op; Outputs.Add(op); TryAndProcess(); }
public void Learn() { Outputs.Clear(); var error = 0.0; double testError = 0.0; for (var i = 0; i < hiddenLayerOutputs.Count; i++) { _neuron.Inputs = hiddenLayerOutputs[i]; _neuron.CalculateOutput(); Train(hiddenLayerOutputs[i], SampleRepository.TrainSamples[i].ExpectedValues.First()); Outputs.Add(_neuron.Output); } for (int i = 0; i < hiddenLayerOutputs.Count; i++) { _neuron.Inputs = hiddenLayerOutputs[i]; _neuron.CalculateOutput(); error += _neuron.CalculateError(SampleRepository.TrainSamples[i].ExpectedValues.First()); } for (int i = 0; i < SampleRepository.TestSamples.Count; i++) { CalculateNetworkOutput(new SamplePoint(SampleRepository.TestSamples[i].Inputs)); testError += _neuron.CalculateError(SampleRepository.TestSamples[i].ExpectedValues.First()); } TotalErrors.Add(error / hiddenLayerOutputs.Count); TotalTestErrors.Add(testError / SampleRepository.TestSamples.Count); }
public void Reset() { Inputs.Clear(); Outputs.Clear(); TFOutputs.Clear(); Planning.Clear(); }
public void UpdateTraderPricesChart(SqlServerSavableEntity entity) { PrepareCon(); SqlCmd.CommandType = CommandType.StoredProcedure; string cmdText = "dbo.sp_" + entity.ElementName + "_update"; SqlCmd.CommandText = cmdText; foreach (KeyValuePair <string, object> pair in entity.Attributes) { SqlCmd.Parameters.AddWithValue(pair.Key, pair.Value); } Outputs.Clear(); foreach (int output in entity.OutputParameters) { SqlCmd.Parameters[output].Direction = ParameterDirection.Output; Outputs.Add(output, 0); } SqlCmd.ExecuteNonQuery(); foreach (int output in entity.OutputParameters) { Outputs[output] = SqlCmd.Parameters[output].Value; } CloseCon(); }
public override void FromJson(string data) { NodeData d = JsonConvert.DeserializeObject <NodeData>(data); SetBaseNodeDate(d); Output = new NodeOutput(NodeType.Color | NodeType.Gray, this); Outputs.Clear(); Outputs.Add(Output); }
public override void InitSequence() { Outputs.Clear(); _hPropVals.Clear(); _hNewVals.Clear(); _zVals.Clear(); _rVals.Clear(); Inputs.Clear(); ResetMemory(); }
public override void FromJson(Dictionary <string, Node> nodes, string data) { InputNodeData d = JsonConvert.DeserializeObject <InputNodeData>(data); SetBaseNodeDate(d); Output = new NodeOutput(NodeType.Color | NodeType.Gray, this); Outputs.Clear(); Outputs.Add(Output); }
/// <summary> /// Resets nodes to state when they are ready for new run of the builder. /// </summary> internal virtual void Reset() { Depth = int.MaxValue; SubTreeNodes.Clear(); Inputs.Clear(); Outputs.Clear(); SequenceOutputs.Clear(); SequenceInputs.Clear(); Collected = false; Preprocessed = false; }
/// <summary> /// Clear all observable collections /// </summary> private void ClearData() { InterNodes.Clear(); Connections.Clear(); Connectors.Clear(); Nodes.Clear(); Transitions.Clear(); Inputs.Clear(); Outputs.Clear(); NotInputs.Clear(); NotOutputs.Clear(); }
/// <summary> /// Closes and disposes all outputs added to this instance /// </summary> public void Kill() { foreach (TextWriter output in Outputs) { try { output.Close(); output.Dispose(); } catch { } } Outputs.Clear(); }
public void DoStuffer() { Outputs.Clear(); CalculateHiddenLayerOutputs(); KMeansAlgorithm.SamplePoints = SamplePoints; KMeansAlgorithm.AssignSamplePointsToNearestCentroids(); SamplePoints = KMeansAlgorithm.SamplePoints; for (var i = 0; i < hiddenLayerOutputs.Count; i++) { _neuron.Inputs = hiddenLayerOutputs[i]; _neuron.CalculateOutput(); Outputs.Add(_neuron.Output); } }
private void Transform() { if (Inputs.Count < 1) { return; } Outputs.Clear(); var now = DateTime.Now; var counter = CounterStart; foreach (var input in Inputs) { var name = Path.GetFileNameWithoutExtension(input); var ext = Path.GetExtension(input); var output = Path.Combine(OutputDirectory, RenamePattern + "." + Extension); ReplaceIfNeeded(ref output, "[N]", name); ReplaceIfNeeded(ref output, "[Y]", now.Year); ReplaceIfNeeded(ref output, "[M]", now.Month); ReplaceIfNeeded(ref output, "[D]", now.Day); ReplaceIfNeeded(ref output, "[h]", now.Hour); ReplaceIfNeeded(ref output, "[m]", now.Minute); ReplaceIfNeeded(ref output, "[s]", now.Second); ReplaceIfNeeded(ref output, "[E]", ext); ReplaceIfNeeded(ref output, "[C]", counter.ToString().PadLeft(CounterPadding, '0')); ReplaceIfNeeded(ref output, Search, Replace, Regex); counter += CounterIncrement; switch (CaseTransformMode) { case 0: break; case 1: output = output.ToUpper(); break; case 2: output = output.ToLower(); break; case 3: output = output.ToTitleCase(); break; } Outputs.Add(output); } }
internal void ReassignOutput(Node oldOutput, Node newOutput) { if (Outputs == null) { Inputs[0].ReassignOutput(this, newOutput); } else if (Outputs.Count == 1) { Outputs.Clear(); Outputs.Add(newOutput); } else if (Outputs.Count > 1) { Outputs.Remove(oldOutput); Outputs.Add(newOutput); } }
public List <double> DoStuffer() { List <double> outputs = new List <double>(); Outputs.Clear(); CalculateHiddenLayerOutputs(); for (var i = 0; i < _hiddenLayerOutputs.Count; i++) { _neuron.Inputs = _hiddenLayerOutputs[i]; _neuron.CalculateOutput(); outputs.Add(_neuron.Output); Outputs.Add(_neuron.Output); } return(outputs); }
/// <summary> /// 初始化 /// </summary> /// <param name="filePath">文件路径</param> public void Init(string filePath) { try { hDevProgram = new HDevProgram(filePath); hDevProgramCall = hDevProgram.CreateCall(); valueCount = hDevProgram.GetCtrlVarCount(); valueName = hDevProgram.GetCtrlVarNames().SArr; Outputs.Clear(); } catch (Exception) { throw; } }
/// <summary> /// 初始化 /// </summary> /// <param name="cogToolBlock">ToolBlock实例</param> /// <returns>结果</returns> private bool Init(CogToolBlock cogToolBlock) { if (cogToolBlock != null) { visionProDisplayControl.SetCogToolDisplayTool(cogToolBlock); visionProConfigControl.SetCogToolBlockEditSubject(cogToolBlock); Outputs.Clear(); for (int i = 0; i < cogToolBlock.Outputs.Count; i++) { Outputs.Add(new ItemBase(cogToolBlock.Outputs[i].Name, cogToolBlock.Outputs[i].Value, cogToolBlock.Outputs[i].ValueType, string.IsNullOrEmpty(cogToolBlock.Outputs[i].Description) ? cogToolBlock.Outputs[i].Name : cogToolBlock.Outputs[i].Description)); } return(true); } return(false); }
public VisionFrame() { //创建运行时/配置窗口控件 var runningSmartWindow = new HSmartWindowControlWPF(); runningSmartWindow.HInitWindow += RunningSmartWindow_HInitWindow; runningSmartWindow.Unloaded += RunningSmartWindow_Unloaded; RunningWindow = runningSmartWindow; ConfigWindow = runningSmartWindow; //var configSmartWindow = new HSmartWindowControlWPF(); //configSmartWindow.HInitWindow += ConfigSmartWindow_HInitWindow; //configSmartWindow.Unloaded += ConfigSmartWindow_Unloaded; //ConfigWindow = configSmartWindow; //配置输入参数 Inputs.Clear(); //配置输出参数 Outputs.Clear(); }
public void Split(int count) { Outputs.Clear(); int smallestPower = Context.GetSmallestPower(count); SplitIntoPower(smallestPower); //do the merging List <Output> finals = GetFinalOutputs(); List <Output> outputsToAdd = new List <Output>(); for (int i = 0; i < smallestPower - count; i++) { outputsToAdd.Add(finals[i]); } if (outputsToAdd.Count > 0) { Node oldInput = Inputs[0]; Merger merger = (oldInput as ICanInsertMergerAfter).InsertMergerAfter(); merger.AddInputsSafe(outputsToAdd); merger.OutputRate = oldInput.OutputRate + oldInput.OutputRate / count * (smallestPower - count); } }
public VisionOperation() { //创建运行时/配置窗口控件 var runningSmartWindow = new HSmartWindowControlWPF(); runningSmartWindow.HInitWindow += RunningSmartWindow_HInitWindow; runningSmartWindow.Unloaded += RunningSmartWindow_Unloaded; RunningWindow = runningSmartWindow; var configSmartWindow = new HSmartWindowControlWPF(); configSmartWindow.HInitWindow += ConfigSmartWindow_HInitWindow; configSmartWindow.Unloaded += ConfigSmartWindow_Unloaded; ConfigWindow = configSmartWindow; //配置输入参数 Inputs.Clear(); //配置输出参数 Outputs.Clear(); //Outputs.Add(new ItemBase("ItemCount", 0, typeof(int), "物料数量")); Outputs.Add(new ItemBase("ItemLocation", new Location[0], typeof(Location[]), "物料位置(数组)")); }
public VisionOperation() { //创建运行时/配置窗口控件 var runningSmartWindow = new HSmartWindowControlWPF(); runningSmartWindow.HInitWindow += RunningSmartWindow_HInitWindow; runningSmartWindow.Unloaded += RunningSmartWindow_Unloaded; RunningWindow = runningSmartWindow; var configSmartWindow = new HSmartWindowControlWPF(); configSmartWindow.HInitWindow += ConfigSmartWindow_HInitWindow; configSmartWindow.Unloaded += ConfigSmartWindow_Unloaded; ConfigWindow = configSmartWindow; //配置输入参数 Inputs.Clear(); Inputs.Add(new ItemBase("ModelPath", @"C:\Users\Public\Documents\MVTec\HALCON-17.12-Progress\examples\hdevelop\Matching\Deformable\brake_disk_bike.dxf", typeof(string), "模板文件(.dxf)路径")); //配置输出参数 Outputs.Clear(); Outputs.Add(new ItemBase("MatchCount", typeof(int), "匹配数量")); Outputs.Add(new ItemBase("Scores", typeof(double[]), "匹配分数(List列表)")); }
private bool disposedValue = false; // 要检测冗余调用 protected virtual void Dispose(bool disposing) { if (!disposedValue) { if (disposing) { // TODO: 释放托管状态(托管对象)。 } // TODO: 释放未托管的资源(未托管的对象)并在以下内容中替代终结器。 // TODO: 将大型字段设置为 null。 hImage?.Dispose(); hImage = null; RunningWindow = null; ConfigWindow = null; Inputs.Clear(); Outputs.Clear(); RunStatus = null; disposedValue = true; } }
public override void InitSequence() { Outputs.Clear(); }
public void ClearOutputs() => Outputs.Clear();
void Setup() { var inputsConnections = GetParentConnections(); var outputConnections = GetConnections(); List <NodeInput> previousInputs = new List <NodeInput>(); List <NodeOutput> previousOutputs = new List <NodeOutput>(); foreach (NodeInput inp in Inputs) { inp.Reference?.Remove(inp); previousInputs.Add(inp); } foreach (NodeOutput op in Outputs) { previousOutputs.Add(op); RemovedOutput(op); } Inputs.Clear(); Outputs.Clear(); int count = 0; if (GraphInst.InputNodes.Count > 0) { count = GraphInst.InputNodes.Count; for (int i = 0; i < count; ++i) { string id = GraphInst.InputNodes[i]; Node n; if (GraphInst.NodeLookup.TryGetValue(id, out n)) { InputNode inp = (InputNode)n; inp.Inputs.Clear(); NodeInput np = new NodeInput(NodeType.Color | NodeType.Gray, this, inp, inp.Name); Inputs.Add(np); inp.Inputs.Add(np); } } } if (GraphInst.OutputNodes.Count > 0) { count = GraphInst.OutputNodes.Count; for (int i = 0; i < count; ++i) { string id = GraphInst.OutputNodes[i]; Node n; if (GraphInst.NodeLookup.TryGetValue(id, out n)) { OutputNode op = (OutputNode)n; op.Outputs.Clear(); NodeOutput ot = new NodeOutput(NodeType.Color | NodeType.Gray, n, this, op.Name); Outputs.Add(ot); op.Outputs.Add(ot); } } } //name map used in parameter mapping for quicker lookup count = GraphInst.CustomParameters.Count; for (int i = 0; i < count; ++i) { var param = GraphInst.CustomParameters[i]; nameMap[param.Name] = param; } SetConnections(parentGraph.NodeLookup, outputConnections, true); //set individual input connections from parent node foreach (var con in inputsConnections) { Node n = null; if (parentGraph.NodeLookup.TryGetValue(con.parent, out n)) { n.SetConnection(this, con, true); } } count = Inputs.Count; for (int i = 0; i < count; ++i) { if (i < previousInputs.Count) { AddedInput(Inputs[i], previousInputs[i]); } else { AddedInput(Inputs[i]); } } if (count < previousInputs.Count) { for (int i = count; i < previousInputs.Count; ++i) { RemovedInput(previousInputs[i]); } } count = Outputs.Count; for (int i = 0; i < count; ++i) { if (i < previousOutputs.Count) { AddedOutput(Outputs[i], previousOutputs[i]); } else { AddedOutput(Outputs[i]); } } }
public void SetOutput(NodeOutput op) { Outputs.Clear(); Output = op; Outputs.Add(op); }
/// <summary> /// 执行 /// </summary> /// <param name="timeout">处理超时时间,若小于等于0,则无限等待.单位:毫秒</param> /// <param name="outputs">输出结果</param> public void Execute(int timeout, out ItemCollection outputs) { outputs = new ItemCollection(); //全局线程锁(静态),避免不同线程间同时调用VisionPro的资源 lock (globalThreadLock) { try { //线程锁,避免在不同线程中分别调用init和run,导致isInit变量冲突 lock (threadLock) { if (!IsInit) { throw new ArgumentException("VisionFrame is uninit"); } } if (cogToolBlock != null) { cogToolBlock.Run(); Outputs.Clear(); for (int i = 0; i < cogToolBlock.Outputs.Count; i++) { Outputs.Add(new ItemBase(cogToolBlock.Outputs[i].Name, cogToolBlock.Outputs[i].Value, cogToolBlock.Outputs[i].ValueType, string.IsNullOrEmpty(cogToolBlock.Outputs[i].Description) ? cogToolBlock.Outputs[i].Name : cogToolBlock.Outputs[i].Description)); } outputs = new ItemCollection(Outputs); EResult result = EResult.Accept; switch (cogToolBlock.RunStatus.Result) { case CogToolResultConstants.Accept: result = EResult.Accept; break; case CogToolResultConstants.Warning: result = EResult.Warning; break; case CogToolResultConstants.Reject: result = EResult.Reject; break; case CogToolResultConstants.Error: result = EResult.Error; break; default: break; } RunStatus = new RunStatus(cogToolBlock.RunStatus.ProcessingTime, result, cogToolBlock.RunStatus.Message, cogToolBlock.RunStatus.Exception); GC.Collect(); GC.WaitForPendingFinalizers(); } } catch (Exception) { throw; } } }
private void ClearOutputs() { outputContainer.Clear(); Outputs.Clear(); }
/// <summary> /// 执行 /// </summary> /// <param name="timeout">处理超时时间,若小于等于0,则无限等待.单位:毫秒</param> /// <param name="outputs">输出结果</param> public void Execute(int timeout, out ItemCollection outputs) { try { stopwatch.Restart(); if (runningWindow == null) { try { runningWindow = (RunningWindow as HSmartWindowControlWPF).HalconWindow; hDevEngine.SetHDevOperators(new HDevOpMultiWindowImpl(runningWindow)); } catch (Exception) { } } //执行程序 hDevProgramCall.Execute(); //拼接输出结果 Outputs.Clear(); foreach (var item in valueName) { HTuple valueTuple = hDevProgramCall.GetCtrlVarTuple(item); switch (valueTuple.Type) { case HTupleType.EMPTY: break; case HTupleType.INTEGER: Outputs.Add(new ItemBase(item, valueTuple.IArr, item)); break; case HTupleType.LONG: Outputs.Add(new ItemBase(item, valueTuple.LArr, item)); break; case HTupleType.DOUBLE: Outputs.Add(new ItemBase(item, valueTuple.DArr, item)); break; case HTupleType.STRING: Outputs.Add(new ItemBase(item, valueTuple.SArr, item)); break; case HTupleType.MIXED: break; default: break; } } stopwatch.Stop(); RunStatus = new RunStatus(stopwatch.Elapsed.TotalMilliseconds); outputs = new ItemCollection(Outputs); UpdatePart(runningWindow); } catch (Exception ex) { RunStatus = new RunStatus(0, EResult.Error, ex.Message, ex); throw; } }