Exemplo n.º 1
0
        public void CheckTriggerConfiguration()
        {
            // Check if Trigger options have changed.
            List <TriggerProperties> newTriggerOptions = TriggerProperties.CollectProperties(this);

            if (!TriggerProperties.PartialCompareProperties(TriggerOptions, newTriggerOptions))
            {
                Controller.SetupTriggersConfiguration(newTriggerOptions);
                MotionTab.UpdateTriggerInfoState();
            }
        }
Exemplo n.º 2
0
 public void UpdateTriggerInfoState()
 {
     for (int k = 1; k <= 4; k++)
     {
         TriggerProperties tp = TriggerProperties.FindTrigger(Recorder.TriggerOptions, k);
         string            id = k.ToString();
         Button            b  = Recorder.FindName("TriggerState" + id) as Button;
         if (b != null)
         {
             b.Visibility = ((tp == null) ? Visibility.Collapsed : Visibility.Visible);
         }
     }
 }
Exemplo n.º 3
0
        void TriggerState_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                TriggerProperties tp = TriggerProperties.FindTrigger(Recorder.TriggerOptions, b.Name);
                if (tp != null)
                {
                    //Toggle trigger state. Send to all devices in deviceMask.
                    if (Controller != null)
                    {
                        Controller.ToggleTriggerOutput(tp);
                    }
                }
            }
        }
Exemplo n.º 4
0
 public void UpdateTriggerState(TriggerProperties tp)
 {
     if (Application.Current.Dispatcher.CheckAccess())
     {
         if (!IsClosing)
         {
             Button b = this.FindName("TriggerState" + tp.TriggerId.ToString()) as Button;
             if (b != null)
             {
                 b.Background = TriggerStateBrushes[tp.IsOn ? 1 : 0];
             }
         }
     }
     else
     {
         Application.Current.Dispatcher.Invoke((Action)(() => { UpdateTriggerState(tp); }));
     }
 }
Exemplo n.º 5
0
 // Returns true if partially equal.
 // Does not compare internal.
 public bool PartialCompare(TriggerProperties t)
 {
     return(ActiveHighInput == t.ActiveHighInput &&
            ActiveHighOutput == t.ActiveHighOutput &&
            PlayInput == t.PlayInput &&
            PlayOutput == t.PlayOutput &&
            RecordInput == t.RecordInput &&
            RecordOutput == t.RecordOutput &&
            SignalInput == t.SignalInput &&
            SignalOutput == t.SignalOutput &&
            DelaySeconds == t.DelaySeconds &&
            DelayFrames == t.DelayFrames &&
            InputDeviceId == t.InputDeviceId &&
            InputBitMask == t.InputBitMask &&
            OutputDeviceMask == t.OutputDeviceMask &&
            OutputBitMask == t.OutputBitMask &&
            PulseLength == t.PulseLength &&
            PulseCycle == t.PulseCycle &&
            PulseRepeat == t.PulseRepeat &&
            TriggerId == t.TriggerId);
 }
Exemplo n.º 6
0
        // 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);
        }
Exemplo n.º 7
0
 // Returns true if equal.
 // Does not compare internal.
 public bool Equals(TriggerProperties t)
 {
     return(PartialCompare(t) &&
            Description == t.Description);
 }