Exemplo n.º 1
0
        public string LoadRecording()
        {
            if (String.IsNullOrWhiteSpace(CurrentFilePath))
            {
                return("Error:First select a file name from JobStorage.");
            }
            Recorder.Controller.PVTCache.Reset(); // TODO: Future: could append recordings.
            string header = "";
            string s      = Controller.PVTCache.LoadFromFile(CurrentFilePath, out header);

            if (!s.StartsWith("Error:"))
            {
                List <AxisProperties> apAry = AxisProperties.ConvertToProperties(header);
                if (!AxisProperties.WeakPartialCompareProperties(apAry, Recorder.AxisOptions))
                {
                    s = "Warning: read file "
                        + CurrentFilePath
                        + "\nIs not compatible with current axis options.";
                }
                else
                {
                    s = "Read:" + CurrentFilePath;
                }
                SetTitle();
            }
            return(s);
        }
Exemplo n.º 2
0
 private void SaveRecording_Click(object sender, RoutedEventArgs e)
 {
     if (String.IsNullOrWhiteSpace(CurrentFilePath))
     {
         Settings.BugReport("Select a file name first from JobStorage.");
         return;
     }
     if ((Recorder.RecorderMode == RecorderModeKinds.RecorderModeIdle) ||
         (Recorder.RecorderMode == RecorderModeKinds.RecorderModeIdleStopped) ||
         (Recorder.RecorderMode == RecorderModeKinds.RecorderModeRecordStopped))
     {
         if (Controller.PVTCache != null)
         {
             string header = AxisProperties.ConvertToHeader(Recorder.AxisOptions);
             string s      = Controller.PVTCache.DumpToFile(CurrentFilePath, true, header);
             if (s.StartsWith("Error:"))
             {
                 Settings.BugReport(s);
             }
             else
             {
                 Settings.BugReport("Saved:" + CurrentFilePath);
             }
         }
     }
     else
     {
         Settings.BugReport("Must be in Idle or Stopped mode to write.");
     }
 }
Exemplo n.º 3
0
 public bool WeakPartialCompare(AxisProperties a)
 {
     return(AxisKind == a.AxisKind &&
            AxisId == a.AxisId &&
            ParamIndex == a.ParamIndex &&
            DeviceNumber == a.DeviceNumber &&
            DeviceRank == a.DeviceRank);
 }
Exemplo n.º 4
0
 // Returns true if partially equal.
 // Does not compare Active or Show flags, or internal.
 public bool PartialCompare(AxisProperties a)
 {
     return(AxisKind == a.AxisKind &&
            AxisId == a.AxisId &&
            ParamIndex == a.ParamIndex &&
            DeviceNumber == a.DeviceNumber &&
            DeviceRank == a.DeviceRank &&
            MinusStop == a.MinusStop &&
            PlusStop == a.PlusStop &&
            DeviceId == a.DeviceId &&
            Description == a.Description);
 }
Exemplo n.º 5
0
        void AxisActive_CheckBox(object sender, RoutedEventArgs e)
        {
            CheckBox c = sender as CheckBox;

            if (c != null)
            {
                AxisProperties ap = AxisProperties.FindAxis(Recorder.AxisOptions, c.Name);
                if (ap != null)
                {
                    ap.Active = (c.IsChecked == true);
                }
            }
        }
Exemplo n.º 6
0
 public void UpdateAxisInfoState()
 {
     for (int k = 1; k <= 8; k++)
     {
         AxisProperties ap = AxisProperties.FindAxis(Recorder.AxisOptions, k);
         string         id = k.ToString();
         StackPanel     sp = Recorder.FindName("AxisInfo" + id) as StackPanel;
         if (sp != null)
         {
             sp.Visibility = ((ap == null) ? Visibility.Collapsed : Visibility.Visible);
         }
     }
 }
Exemplo n.º 7
0
 // Returns true if equal.
 // Does not compare internal.
 public bool Equals(AxisProperties a)
 {
     return(Active == a.Active &&
            Show == a.Show &&
            AxisKind == a.AxisKind &&
            AxisId == a.AxisId &&
            ParamIndex == a.ParamIndex &&
            DeviceNumber == a.DeviceNumber &&
            DeviceRank == a.DeviceRank &&
            MinusStop == a.MinusStop &&
            PlusStop == a.PlusStop &&
            DeviceId == a.DeviceId &&
            Description == a.Description);
 }
Exemplo n.º 8
0
        void AxisShow_CheckBox(object sender, RoutedEventArgs e)
        {
            CheckBox c = sender as CheckBox;

            if (c != null)
            {
                AxisProperties ap = AxisProperties.FindAxis(Recorder.AxisOptions, c.Name);
                if (ap != null)
                {
                    ap.Show = (c.IsChecked == true);
                    Recorder.RecorderScope.SetAxisVisibility(ap);
                }
            }
        }
Exemplo n.º 9
0
        void AxisState_Click(object sender, RoutedEventArgs e)
        {
            Button b = sender as Button;

            if (b != null)
            {
                AxisProperties ap = AxisProperties.FindAxis(Recorder.AxisOptions, b.Name);
                if (ap != null)
                {
                    Controller.IssueCommand(ap.AxisPortPropertiesIndex, AxesController.AXIS_CMD_RESET, 1,
                                            (byte)ap.DeviceRank, 0);
                }
            }
        }
Exemplo n.º 10
0
        public void CheckAxesConfiguration()
        {
            // Check if Axis options have changed.
            List <AxisProperties> newAxisOptions = AxisProperties.CollectProperties(this);

            if (!AxisProperties.PartialCompareProperties(AxisOptions, newAxisOptions))
            {
                JobStorageTab.ClearTitle();
                Controller.SetupAxesConfiguration(newAxisOptions);
                MotionTab.UpdateAxisInfoState();
                RecorderScope.SetupSeriesConfiguration();
                Controller.IssueSetStopsCommand();
                Controller.IssueISOPVTMonitorSwitchOff();
                Controller.CheckMonitoringActive(true);
            }
        }
Exemplo n.º 11
0
 public void SetAxisVisibility(AxisProperties ap)
 {
     if (ap != null)
     {
         Series s = null;
         try {
             s = ap.ActualSeries;
             if (s != null)
             {
                 s.IsVisible = ap.Show;
             }
         } catch (Exception) { }
         try {
             s = ap.TargetSeries;
             if (s != null)
             {
                 s.IsVisible = ap.Show;
             }
         } catch (Exception) { }
     }
 }
Exemplo n.º 12
0
        // 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);
        }
Exemplo n.º 13
0
        public static List <AxisProperties> ConvertToProperties(string header)
        {
            List <AxisProperties> ap = new List <AxisProperties>();

            char[] axesSeps  = { ',' };
            char[] propsSeps = { ':' };
            bool   isFirst   = true;

            if (!String.IsNullOrWhiteSpace(header))
            {
                string[] axesAry = header.Split(axesSeps);
                foreach (string s in axesAry)
                {
                    if (isFirst)   // Skip time field.
                    {
                        isFirst = false;
                        continue;
                    }
                    AxisProperties p = new AxisProperties();
                    if (!String.IsNullOrWhiteSpace(s))
                    {
                        string[] propsAry = s.Split(propsSeps);
                        int      v, k = 0, n = propsAry.Length;
                        if (k < n)
                        {
                            if (int.TryParse(propsAry[k++], out v))
                            {
                                p.AxisId = v;
                            }
                        }
                        if (k < n)
                        {
                            try {
                                p.AxisKind = (AxisKinds)Enum.Parse(typeof(AxisKinds), propsAry[k++]);
                            } catch (Exception) {
                                p.AxisKind = AxisKinds.Angular;
                            }
                        }
                        if (k < n)
                        {
                            if (int.TryParse(propsAry[k++], out v))
                            {
                                p.ParamIndex = v;
                            }
                        }
                        if (k < n)
                        {
                            if (int.TryParse(propsAry[k++], out v))
                            {
                                p.DeviceNumber = v;
                            }
                        }
                        if (k < n)
                        {
                            if (int.TryParse(propsAry[k++], out v))
                            {
                                p.DeviceRank = v;
                            }
                        }
                        p.Description = "Axis " + p.AxisId;
                    }
                    ap.Add(p);
                }
            }
            return(ap);
        }
Exemplo n.º 14
0
 public void SetAxisVisibility(int axisId)
 {
     SetAxisVisibility(AxisProperties.FindAxis(Recorder.AxisOptions, axisId));
 }