public void SerializeOptions(XmlNode node, bool isSerialize) { XmlNode options = Project.GetChildNode(node, "options"); if (options == null) { return; } XmlNode chart = Project.GetChildNode(options, "chart"); if (chart != null) { } XmlNode general = Project.GetChildNode(options, "general"); if (general != null) { TextBox tb = Recorder.FindName("LockPassword") as TextBox; if (isSerialize) { Project.SetNodeAttributeValue(general, "lockpassword", (tb == null) ? "" : tb.Text); } else { if (tb != null) { tb.Text = Project.GetNodeAttributeValue(general, "lockpassword", ""); } ; } } }
// Collects together properties of enabled and valid axes. public static List <AxisProperties> CollectProperties(RecorderControl recorder) { int k, n, i; List <string> devices = new List <string>(); for (k = 1; k <= 4; k++) { string id = k.ToString(); ComboBox di = recorder.FindName("DeviceId" + id) as ComboBox; if (di != null && !String.IsNullOrWhiteSpace(di.Text)) { devices.Add(di.Text); } else { devices.Add("None"); } } List <AxisProperties> properties = new List <AxisProperties>(); for (k = 1; k <= 8; k++) { string id = k.ToString(); CheckBox cba = recorder.FindName("AxisActive" + id) as CheckBox; CheckBox cbs = recorder.FindName("AxisShow" + id) as CheckBox; CheckBox cbe = recorder.FindName("AxisEnable" + id) as CheckBox; ComboBox cb = recorder.FindName("AxisKind" + id) as ComboBox; TextBox tb = recorder.FindName("AxisDescription" + id) as TextBox; IntegerUpDown iudad = recorder.FindName("AxisDevice" + id) as IntegerUpDown; IntegerUpDown iud = recorder.FindName("AxisIndex" + id) as IntegerUpDown; IntegerUpDown iudh = recorder.FindName("AxisDeviceRank" + id) as IntegerUpDown; IntegerUpDown iudma = recorder.FindName("AxisMinusStopMajor" + id) as IntegerUpDown; IntegerUpDown iudmb = recorder.FindName("AxisMinusStopMinor" + id) as IntegerUpDown; IntegerUpDown iudpa = recorder.FindName("AxisPlusStopMajor" + id) as IntegerUpDown; IntegerUpDown iudpb = recorder.FindName("AxisPlusStopMinor" + id) as IntegerUpDown; if (cbe == null || !cbe.IsChecked.Value) { continue; } n = (iudad == null) ? 1 : iudad.Value.Value; i = (iud == null) ? 0 : iud.Value.Value; if (i < 1 || n < 1 || n > 4 || devices[n - 1].Equals("None")) { continue; } /* Debug: could have multiple axes on same device. * bool inUse = false; * for (int j = 0; j < properties.Count; j++) { * if (properties[j].DeviceNumber == n) { * inUse = true; * break; * } * } * if (inUse) continue; */ AxisProperties ap = new AxisProperties(); ap.DeviceNumber = n; ap.DeviceId = devices[n - 1]; ap.ParamIndex = i; ap.DeviceRank = (iudh == null) ? 0 : iudh.Value.Value; ap.AxisId = k; ap.SeriesIndex = 2 * (k - 1); ap.Show = (cbs == null) ? false : cbs.IsChecked.Value; ap.Active = (cba == null) ? false : cba.IsChecked.Value; try { if (cb == null || String.IsNullOrWhiteSpace(cb.Text)) { ap.AxisKind = AxisKinds.Angular; } else { ap.AxisKind = (AxisKinds)Enum.Parse(typeof(AxisKinds), cb.Text); } } catch (Exception) { ap.AxisKind = AxisKinds.Angular; } int minusmajor = (iudma == null) ? 0 : iudma.Value.Value; int minusminor = (iudmb == null) ? 0 : iudmb.Value.Value; int plusmajor = (iudpa == null) ? 0 : iudpa.Value.Value; int plusminor = (iudpb == null) ? 0 : iudpb.Value.Value; if (ap.AxisKind == AxisKinds.Angular) { ap.MinusStop = minusmajor + ((float)minusminor / 360.0f); ap.PlusStop = plusmajor + ((float)plusminor / 360.0f); } else { ap.MinusStop = minusmajor + ((float)minusminor / 1000.0f); ap.PlusStop = plusmajor + ((float)plusminor / 1000.0f); } string s = tb.Text; if (String.IsNullOrWhiteSpace(s)) { s = "Axis " + id; } ap.Description = s; properties.Add(ap); } return(properties); }
// Collects together properties of enabled and valid triggers. public static List <TriggerProperties> CollectProperties(RecorderControl recorder) { int k; List <TriggerProperties> properties = new List <TriggerProperties>(); for (k = 1; k <= 4; k++) { string id = k.ToString(); CheckBox cbe = recorder.FindName("TriggerEnable" + id) as CheckBox; CheckBox cbahi = recorder.FindName("TriggerActiveHighInput" + id) as CheckBox; CheckBox cbaho = recorder.FindName("TriggerActiveHighOutput" + id) as CheckBox; CheckBox cbpi = recorder.FindName("TriggerPlayInput" + id) as CheckBox; CheckBox cbpo = recorder.FindName("TriggerPlayOutput" + id) as CheckBox; CheckBox cbri = recorder.FindName("TriggerRecordInput" + id) as CheckBox; CheckBox cbro = recorder.FindName("TriggerRecordOutput" + id) as CheckBox; CheckBox cbsi = recorder.FindName("TriggerSignalInput" + id) as CheckBox; CheckBox cbso = recorder.FindName("TriggerSignalOutput" + id) as CheckBox; IntegerUpDown iudds = recorder.FindName("TriggerDelaySeconds" + id) as IntegerUpDown; IntegerUpDown iuddf = recorder.FindName("TriggerDelayFrames" + id) as IntegerUpDown; IntegerUpDown iudidm = recorder.FindName("TriggerInputDeviceId" + id) as IntegerUpDown; IntegerUpDown iudibm = recorder.FindName("TriggerInputBitMask" + id) as IntegerUpDown; IntegerUpDown iudodm = recorder.FindName("TriggerOutputDeviceMask" + id) as IntegerUpDown; IntegerUpDown iudobm = recorder.FindName("TriggerOutputBitMask" + id) as IntegerUpDown; DecimalUpDown dudl = recorder.FindName("TriggerPulseLength" + id) as DecimalUpDown; DecimalUpDown dudc = recorder.FindName("TriggerPulseCycle" + id) as DecimalUpDown; IntegerUpDown iudr = recorder.FindName("TriggerRepeat" + id) as IntegerUpDown; TextBox tb = recorder.FindName("TriggerDescription" + id) as TextBox; // if (cbe == null || !cbe.IsChecked.Value) { continue; } TriggerProperties tp = new TriggerProperties(); tp.TriggerId = k; tp.ActiveHighInput = (cbahi == null) ? false : cbahi.IsChecked.Value; tp.ActiveHighOutput = (cbaho == null) ? false : cbaho.IsChecked.Value; tp.PlayInput = (cbpi == null) ? false : cbpi.IsChecked.Value; tp.PlayOutput = (cbpo == null) ? false : cbpo.IsChecked.Value; tp.RecordInput = (cbri == null) ? false : cbri.IsChecked.Value; tp.RecordOutput = (cbro == null) ? false : cbro.IsChecked.Value; tp.SignalInput = (cbsi == null) ? false : cbsi.IsChecked.Value; tp.SignalOutput = (cbso == null) ? false : cbso.IsChecked.Value; tp.DelaySeconds = (uint)((iudds == null) ? 0 : iudds.Value.Value); tp.DelayFrames = (uint)((iuddf == null) ? 0 : iuddf.Value.Value); tp.InputDeviceId = (iudidm == null) ? 0 : iudidm.Value.Value; tp.InputBitMask = (iudibm == null) ? 0 : iudibm.Value.Value; tp.OutputDeviceMask = (iudodm == null) ? 0 : iudodm.Value.Value; tp.OutputBitMask = (iudobm == null) ? 0 : iudobm.Value.Value; tp.PulseLength = (dudl == null) ? 0.0f : (float)(dudl.Value.Value); tp.PulseCycle = (dudc == null) ? 0.0f : (float)(dudc.Value.Value); tp.PulseRepeat = (iudr == null) ? 0 : iudr.Value.Value; string s = tb.Text; if (String.IsNullOrWhiteSpace(s)) { s = "Trigger " + id; } tp.Description = s; tp.InputEnabled = tp.PlayInput || tp.RecordInput || tp.SignalInput; tp.OutputEnabled = tp.PlayOutput || tp.RecordOutput || tp.SignalOutput; if (tp.SignalInput) { foreach (AxisPortProperties app in recorder.Controller.AxisPorts) { if (app.DeviceNumber == tp.InputDeviceId) { tp.AxisPort = app; break; } } if (tp.AxisPort == null) { continue; } } if (tp.InputEnabled && tp.OutputEnabled) // Note: must have defined an input & output. { properties.Add(tp); } } return(properties); }
public void InitializeControls() { Controller = Recorder.Controller; Recorder.RecorderAction.SelectionChanged += new SelectionChangedEventHandler(RecorderAction_SelectionChanged); Recorder.RecorderAction.SelectedIndex = 0; Recorder.FramesPerSecond.SelectionChanged += new SelectionChangedEventHandler(FramesPerSecond_SelectionChanged); Recorder.FramesPerSecond.SelectedIndex = 0; Recorder.GotoRPM.ValueChanged += new RoutedPropertyChangedEventHandler <object>(HomeRPM_ValueChanged); Recorder.ZeroButton.Click += new RoutedEventHandler(Zero_Click); Recorder.HomeButton.Click += new RoutedEventHandler(Home_Click); Recorder.ReverseTimeLineButton.Click += new RoutedEventHandler(Reverse_TimeLine_Click); Recorder.PlayTimeLineButton.Click += new RoutedEventHandler(Play_TimeLine_Click); Recorder.RecordTimeLineButton.Click += new RoutedEventHandler(Record_TimeLine_Click); Recorder.PauseTimeLineButton.Click += new RoutedEventHandler(Pause_TimeLine_Click); Recorder.StopTimeLineButton.Click += new RoutedEventHandler(Stop_TimeLine_Click); Recorder.GotoButton.Click += new RoutedEventHandler(Goto_Click); Recorder.PrimeTimeLineButton.Click += new RoutedEventHandler(Prime_TimeLine_Click); Recorder.LockButton.Click += new RoutedEventHandler(Lock_Click); for (int k = 1; k <= 8; k++) { CheckBox c; c = Recorder.FindName("AxisShow" + k.ToString()) as CheckBox; if (c != null) { c.Checked += new RoutedEventHandler(AxisShow_CheckBox); c.Unchecked += new RoutedEventHandler(AxisShow_CheckBox); } c = Recorder.FindName("AxisActive" + k.ToString()) as CheckBox; if (c != null) { c.Checked += new RoutedEventHandler(AxisActive_CheckBox); c.Unchecked += new RoutedEventHandler(AxisActive_CheckBox); } Button b = Recorder.FindName("AxisState" + k.ToString()) as Button; if (b != null) { b.Click += new RoutedEventHandler(AxisState_Click); } } for (int k = 1; k <= 4; k++) { Button b = Recorder.FindName("TriggerState" + k.ToString()) as Button; if (b != null) { b.Click += new RoutedEventHandler(TriggerState_Click); } } }
public void SerializeAxes(XmlNode node, bool isSerialize) { XmlNode axes = Project.GetChildNode(node, "axes"); if (axes == null) { return; } int k; for (k = 1; k <= 4; k++) { string id = k.ToString(); XmlNode a = Project.GetChildNode(axes, "device", id); if (a != null) { ComboBox di = Recorder.FindName("DeviceId" + id) as ComboBox; if (isSerialize) { Project.SetNodeAttributeValue(a, "id", (di == null) ? "None" : di.Text); } else { if (di != null) { di.Text = Project.GetNodeAttributeValue(a, "id", "None"); } } } } for (k = 1; k <= 8; k++) { string id = k.ToString(); XmlNode a = Project.GetChildNode(axes, "axis", id); if (a != null) { CheckBox cbe = Recorder.FindName("AxisEnable" + id) as CheckBox; ComboBox cb = Recorder.FindName("AxisKind" + id) as ComboBox; IntegerUpDown iudad = Recorder.FindName("AxisDevice" + id) as IntegerUpDown; IntegerUpDown iud = Recorder.FindName("AxisIndex" + id) as IntegerUpDown; IntegerUpDown iudh = Recorder.FindName("AxisDeviceRank" + id) as IntegerUpDown; IntegerUpDown iudma = Recorder.FindName("AxisMinusStopMajor" + id) as IntegerUpDown; IntegerUpDown iudmb = Recorder.FindName("AxisMinusStopMinor" + id) as IntegerUpDown; IntegerUpDown iudpa = Recorder.FindName("AxisPlusStopMajor" + id) as IntegerUpDown; IntegerUpDown iudpb = Recorder.FindName("AxisPlusStopMinor" + id) as IntegerUpDown; TextBox tb = Recorder.FindName("AxisDescription" + id) as TextBox; if (isSerialize) { Project.SetNodeAttributeValue(a, "enable", (cbe == null) ? "false" : cbe.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "kind", (cb == null) ? "Angular" : cb.Text); Project.SetNodeAttributeValue(a, "device", (iudad == null) ? "1" : iudad.Text); Project.SetNodeAttributeValue(a, "index", (iud == null) ? ("36") : iud.Text); Project.SetNodeAttributeValue(a, "rank", (iudh == null) ? "0" : iudh.Text); Project.SetNodeAttributeValue(a, "minusstopmajor", (iudma == null) ? "0" : iudma.Text); Project.SetNodeAttributeValue(a, "minusstopminor", (iudmb == null) ? "0" : iudmb.Text); Project.SetNodeAttributeValue(a, "plusstopmajor", (iudpa == null) ? "0" : iudpa.Text); Project.SetNodeAttributeValue(a, "plusstopminor", (iudpb == null) ? "0" : iudpb.Text); Project.SetNodeAttributeValue(a, "description", (tb == null) ? id : tb.Text); } else { bool result = false; Boolean.TryParse(Project.GetNodeAttributeValue(a, "enable", "false"), out result); if (cbe != null) { cbe.IsChecked = result; } if (cb != null) { cb.Text = Project.GetNodeAttributeValue(a, "kind", "Angular"); } if (iudad != null) { iudad.Text = Project.GetNodeAttributeValue(a, "device", "1"); } if (iud != null) { iud.Text = Project.GetNodeAttributeValue(a, "index", ("36")); } if (iudh != null) { iudh.Text = Project.GetNodeAttributeValue(a, "rank", "0"); } if (iudma != null) { iudma.Text = Project.GetNodeAttributeValue(a, "minusstopmajor", "0"); } if (iudmb != null) { iudmb.Text = Project.GetNodeAttributeValue(a, "minusstopminor", "0"); } if (iudpa != null) { iudpa.Text = Project.GetNodeAttributeValue(a, "plusstopmajor", "0"); } if (iudpb != null) { iudpb.Text = Project.GetNodeAttributeValue(a, "description", "0"); } if (tb != null) { tb.Text = Project.GetNodeAttributeValue(a, "description", id); } } } } }
public void SerializeTriggers(XmlNode node, bool isSerialize) { XmlNode triggers = Project.GetChildNode(node, "triggers"); if (triggers == null) { return; } int k; for (k = 1; k <= 4; k++) { string id = k.ToString(); XmlNode a = Project.GetChildNode(triggers, "trigger", id); if (a != null) { CheckBox cbe = Recorder.FindName("TriggerEnable" + id) as CheckBox; CheckBox cbahi = Recorder.FindName("TriggerActiveHighInput" + id) as CheckBox; CheckBox cbaho = Recorder.FindName("TriggerActiveHighOutput" + id) as CheckBox; CheckBox cbpi = Recorder.FindName("TriggerPlayInput" + id) as CheckBox; CheckBox cbpo = Recorder.FindName("TriggerPlayOutput" + id) as CheckBox; CheckBox cbri = Recorder.FindName("TriggerRecordInput" + id) as CheckBox; CheckBox cbro = Recorder.FindName("TriggerRecordOutput" + id) as CheckBox; CheckBox cbsi = Recorder.FindName("TriggerSignalInput" + id) as CheckBox; CheckBox cbso = Recorder.FindName("TriggerSignalOutput" + id) as CheckBox; IntegerUpDown iudds = Recorder.FindName("TriggerDelaySeconds" + id) as IntegerUpDown; IntegerUpDown iuddf = Recorder.FindName("TriggerDelayFrames" + id) as IntegerUpDown; IntegerUpDown iudidm = Recorder.FindName("TriggerInputDeviceId" + id) as IntegerUpDown; IntegerUpDown iudibm = Recorder.FindName("TriggerInputBitMask" + id) as IntegerUpDown; IntegerUpDown iudodm = Recorder.FindName("TriggerOutputDeviceMask" + id) as IntegerUpDown; IntegerUpDown iudobm = Recorder.FindName("TriggerOutputBitMask" + id) as IntegerUpDown; DecimalUpDown dudl = Recorder.FindName("TriggerPulseLength" + id) as DecimalUpDown; DecimalUpDown dudc = Recorder.FindName("TriggerPulseCycle" + id) as DecimalUpDown; IntegerUpDown iudr = Recorder.FindName("TriggerRepeat" + id) as IntegerUpDown; TextBox tb = Recorder.FindName("TriggerDescription" + id) as TextBox; if (isSerialize) { Project.SetNodeAttributeValue(a, "enable", (cbe == null) ? "false" : cbe.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "activehighinput", (cbahi == null) ? "false" : cbahi.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "activehighoutput", (cbaho == null) ? "false" : cbaho.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "playinput", (cbpi == null) ? "false" : cbpi.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "playoutput", (cbpo == null) ? "false" : cbpo.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "recordinput", (cbri == null) ? "false" : cbri.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "recordoutput", (cbro == null) ? "false" : cbro.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "signalinput", (cbsi == null) ? "false" : cbsi.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "signaloutput", (cbso == null) ? "false" : cbso.IsChecked.Value.ToString()); Project.SetNodeAttributeValue(a, "inputdeviceid", (iudidm == null) ? "1" : iudidm.Text); Project.SetNodeAttributeValue(a, "inputbitmask", (iudibm == null) ? "1" : iudibm.Text); Project.SetNodeAttributeValue(a, "outputdevicemask", (iudodm == null) ? "1" : iudodm.Text); Project.SetNodeAttributeValue(a, "outputbitmask", (iudobm == null) ? "1" : iudobm.Text); Project.SetNodeAttributeValue(a, "delayseconds", (iudds == null) ? "0" : iudds.Text); Project.SetNodeAttributeValue(a, "delayframes", (iuddf == null) ? "0" : iuddf.Text); Project.SetNodeAttributeValue(a, "pulselength", (dudl == null) ? "1.0" : dudl.Text); Project.SetNodeAttributeValue(a, "repeat", (iudr == null) ? "1" : iudr.Text); Project.SetNodeAttributeValue(a, "cycle", (dudc == null) ? "0.0" : dudc.Text); Project.SetNodeAttributeValue(a, "description", (tb == null) ? id : tb.Text); } else { bool result = false; Boolean.TryParse(Project.GetNodeAttributeValue(a, "enable", "false"), out result); if (cbe != null) { cbe.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "activehighinput", "false"), out result); if (cbahi != null) { cbahi.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "activehighoutput", "false"), out result); if (cbaho != null) { cbaho.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "playinput", "false"), out result); if (cbpi != null) { cbpi.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "playoutput", "false"), out result); if (cbpo != null) { cbpo.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "recordinput", "false"), out result); if (cbri != null) { cbri.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "recordoutput", "false"), out result); if (cbro != null) { cbro.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "signalinput", "false"), out result); if (cbsi != null) { cbsi.IsChecked = result; } Boolean.TryParse(Project.GetNodeAttributeValue(a, "signaloutput", "false"), out result); if (cbso != null) { cbso.IsChecked = result; } if (iudidm != null) { iudidm.Text = Project.GetNodeAttributeValue(a, "inputdeviceid", "1"); } if (iudibm != null) { iudibm.Text = Project.GetNodeAttributeValue(a, "inputbitmask", "1"); } if (iudodm != null) { iudodm.Text = Project.GetNodeAttributeValue(a, "outputdevicemask", "1"); } if (iudobm != null) { iudobm.Text = Project.GetNodeAttributeValue(a, "outputbitmask", "1"); } if (iudds != null) { iudds.Text = Project.GetNodeAttributeValue(a, "delayseconds", "0"); } if (iuddf != null) { iuddf.Text = Project.GetNodeAttributeValue(a, "delayframes", "0"); } if (dudl != null) { dudl.Text = Project.GetNodeAttributeValue(a, "pulselength", "1.0"); } if (iudr != null) { iudr.Text = Project.GetNodeAttributeValue(a, "repeat", "1"); } if (dudc != null) { dudc.Text = Project.GetNodeAttributeValue(a, "cycle", "0.0"); } if (tb != null) { tb.Text = Project.GetNodeAttributeValue(a, "description", id); } } } } }