private static void RunQuery(Query query, Dictionary <int, TreeNode> treeByNode, int outputId) { if (query.Type == "0") { treeByNode[query.SecondNum] = new TreeNode { Value = query.SecondNum, Parent = treeByNode[query.FirstNum], }; } else if (query.Type == "1") { treeByNode.Remove(query.FirstNum); } else if (query.Type == "2") { var output = RunQuery(query.FirstNum, query.SecondNum, treeByNode); if (!Outputs.ContainsKey(outputId)) { Outputs[outputId] = output + "\n"; } else { Outputs[outputId] += output + "\n"; } } }
public override void WriteOutputSignal(string signalName, object value) { if (Outputs.ContainsKey(signalName)) { AdressValueInfo output = (AdressValueInfo)Outputs[signalName]; switch (output.valueType.ToString()) { case "System.UInt16": Write(output.adress, (ushort)value); break; case "System.UInt32": Write(output.adress, (uint)value); break; case "System.UInt64": Write(output.adress, (ulong)value); break; case "System.Int16": Write(output.adress, (short)value); break; case "System.Int32": Write(output.adress, (int)value); break; case "System.Int64": Write(output.adress, (long)value); break; case "System.Boolean": Write(output.adress, (bool)value); break; case "System.Byte": Write(output.adress, (byte)value); break; case "System.SByte": Write(output.adress, (sbyte)value); break; case "System.Double": Write(output.adress, (double)value); break; case "System.Single": Write(output.adress, (float)value); break; case "System.String": Write(output.adress, (string)value); break; } } }
public override void WriteOutputSignal(string signalName, object value) { if (Outputs.ContainsKey(signalName)) { AdressValueInfo output = (AdressValueInfo)Outputs[signalName]; S7Adress signalAdress = (S7Adress)output.adress; plc.Write((DataType)signalAdress.dataType, signalAdress.dbAdress, signalAdress.startAdress, value); } }
public void LoadModel() { model = (Kinematic)Activator.CreateInstance(selectedKinematic); foreach (string output in model.OutputNames) { if (!Outputs.ContainsKey(output)) { Outputs.Add(output, new ViewModel.OutputSignalViewModel(output)); } } }
public void AddOutput(LayerConstruct output, string alias = "default") { if (output == null) { throw new ArgumentNullException(nameof(output)); } if (Outputs.ContainsKey(alias)) { throw new ArgumentException($"Attempted to add duplicate input to construct {Name} with alias {alias}."); } Outputs.Add(alias, output); }
public void LoadModel() { model = (Kinematic)Activator.CreateInstance(selectedKinematic); foreach (string output in model.OutputNames) { if (!Outputs.ContainsKey(output)) { Outputs.Add(output, new ViewModel.OutputSignalViewModel(output)); } } Outputs.Add("EnableHaptics", new ViewModel.OutputSignalViewModel("Enable Haptics")); Outputs["EnableHaptics"].Value = 0; HapticsButton.Visibility = System.Windows.Visibility.Visible; }
public string GetOutput(SignalDataType signalDataType) { if (!Outputs.ContainsKey(signalDataType)) { throw new NullReferenceException("Key not exists"); } var vs = Outputs[signalDataType]; if (!vs.IsArray) { return(vs.Value.ToString()); } var s = "["; for (var i = 0; i < vs.Values.Length; i++) { var v = vs.Values[i]; s += v + (i + 1 != vs.Values.Length ? "; " : "]"); } return(s); }
public void Merge(TemplateData other) { foreach (var global in other.Globals) { if (!Globals.ContainsKey(global.Key)) { Globals[global.Key] = global.Value; } } foreach (var output in other.Outputs) { if (!Outputs.ContainsKey(output.Key)) { Outputs[output.Key] = output.Value; } } foreach (var parameter in other.Parameters) { if (!Parameters.ContainsKey(parameter.Key)) { Parameters[parameter.Key] = parameter.Value; } } foreach (var resource in other.Resources) { if (Resources.ContainsKey(resource.Key)) { Resources[resource.Key] = Resources[resource.Key].Merge(resource.Value); } else { Resources[resource.Key] = resource.Value; } } }