Esempio n. 1
0
        private void UITestConfigUseCurrentParamConfigCheck_CheckedChanged(object sender, EventArgs e)
        {
            CheckBox cb = (CheckBox)sender;

            if (activeTestConfiguration.IsRunning)
            {
                return;
            }

            ClearObservableParameterList();

            if (cb.Checked)
            {
                activeTestConfiguration.setParameterControlTemplate(Program.app.autoParamControlTemplate);
                SetObservableParameterList(Program.app.autoParamControlTemplate.GetCollection());
            }
            else
            {
                ParameterControlTemplate selectedItem = GetSelectedParameterControlTemplate();
                activeTestConfiguration.ParameterControlTemplate = null;

                if (selectedItem != null)
                {
                    activeTestConfiguration.setParameterControlTemplate(selectedItem);
                    SetObservableParameterList(selectedItem.GetCollection());
                }
            }
        }
        private void UIParameterTemplateDeleteBtn_Click(object sender, EventArgs e)
        {
            if (UIParameterControlTemplateList.SelectedIndex > -1)
            {
                DialogResult confirm = MessageBox.Show("Do you want to delete this template?\nThis action cannot be undone.", "Confirm delete", MessageBoxButtons.YesNo);

                if (confirm == DialogResult.Yes)
                {
                    ParameterControlTemplate template = templateList[UIParameterControlTemplateList.SelectedIndex];

                    using (LiteDatabase db = new LiteDatabase(db_path))
                    {
                        LiteCollection <ParameterControlTemplate> collection = db.GetCollection <ParameterControlTemplate>(collection_name);

                        if (collection.Delete(template.Id))
                        {
                            UIParameterControlTemplateList.Items.RemoveAt(UIParameterControlTemplateList.SelectedIndex);
                            templateList.Remove(template);
                        }
                    }
                }
            }
            else
            {
                MessageBox.Show("You have to select a template to delete first.");
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Constructor
        /// </summary>
        public TestConfiguration()
        {
            internalReceiver         = new DataReceiver();
            ParameterControlTemplate = new ParameterControlTemplate();
            instructionEntries       = new List <InstructionEntry>();
            instructionEntryQueue    = new Queue <InstructionEntry>();

            // Possible copy all instructions into instructionEntries if loaded from DB
        }
Esempio n. 4
0
        private void UIParameterControlInput_CellValidating(object sender, DataGridViewCellValidatingEventArgs e)
        {
            // Implement better UI response to error handling so that user understands when an invalid input is entered
            UIParameterControlInput.CurrentCell.ErrorText = "";

            if (activeParameterControlTemplate == null)
            {
                activeParameterControlTemplate = new ParameterControlTemplate();
            }

            if (UIParameterControlInput.Rows[e.RowIndex].IsNewRow)
            {
                return;
            }

            if (!double.TryParse(e.FormattedValue.ToString(), out double numericValue) && e.ColumnIndex > 0)
            {
                UIParameterControlInput.CurrentCell.ErrorText = "The value must be a number";
            }
            else
            {
                DataGridViewCell current = UIParameterControlInput.CurrentCell;
                string           tag     = current.OwningRow.Tag.ToString();

                if (dataReceiver.ObservedValues.ContainsLabel(tag))
                {
                    IObservableNumericValue obsValue = dataReceiver.ObservedValues[tag];

                    object castNumericValue = Convert.ChangeType(numericValue, obsValue.type);

                    if (current.OwningColumn.Name == "ParamMin")
                    {
                        if (obsValue.PlotAnnotationMinLine != null)
                        {
                            RemovePlotAnnotationLine(obsValue.PlotAnnotationMinLine);
                        }

                        obsValue.Min = castNumericValue;
                        obsValue.PlotAnnotationMinLine = AddPlotAnnotationLine(Convert.ToDouble(numericValue), tag, OxyColors.Red);
                    }
                    else if (current.OwningColumn.Name == "ParamMax")
                    {
                        if (obsValue.PlotAnnotationMaxLine != null)
                        {
                            RemovePlotAnnotationLine(obsValue.PlotAnnotationMaxLine);
                        }
                        obsValue.Max = castNumericValue;
                        obsValue.PlotAnnotationMaxLine = AddPlotAnnotationLine(Convert.ToDouble(numericValue), tag, OxyColors.Red);
                    }
                }
            }
        }
        private void UIParameterControlTemplateList_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (UIParameterControlTemplateList.SelectedIndex > -1)
            {
                ParameterControlTemplate template = templateList[UIParameterControlTemplateList.SelectedIndex];

                if (template != null)
                {
                    UIParameterTemplateNameInput.Text = template.Name;
                    UIParameterControlTemplateDescriptionInput.Text = template.Description;
                }
            }
        }
        private void UITemplateLoadButton_Click(object sender, EventArgs e)
        {
            if (UIParameterControlTemplateList.SelectedIndex > -1)
            {
                ParameterControlTemplate template = templateList[UIParameterControlTemplateList.SelectedIndex];

                if (template != null)
                {
                    Program.app.LoadParameterControlTemplate(template);
                    Close();
                }
                else
                {
                    MessageBox.Show("Cannot load template");
                }
            }
        }
Esempio n. 7
0
        private void UITestConfigParameterTemplateSelect_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (activeTestConfiguration.IsRunning)
            {
                MessageBox.Show("Cannot modify control parameters when test is running");
                return;
            }

            ParameterControlTemplate selectedItem = GetSelectedParameterControlTemplate();

            activeTestConfiguration.ParameterControlTemplate = null;

            if (selectedItem != null)
            {
                activeTestConfiguration.setParameterControlTemplate(selectedItem);
                SetObservableParameterList(selectedItem.GetCollection());
            }
        }
        private void UITemplateSaveButton_Click(object sender, EventArgs e)
        {
            string name = UIParameterTemplateNameInput.Text;

            if (name.Length > 0)
            {
                using (LiteDatabase db = new LiteDatabase(db_path))
                {
                    ObservableNumericValueCollection          observedValues = Program.app.DataReceiver.ObservedValues;
                    LiteCollection <ParameterControlTemplate> collection     = db.GetCollection <ParameterControlTemplate>(collection_name);

                    if (UIParameterControlTemplateList.SelectedIndex == -1)
                    {
                        ParameterControlTemplate template = new ParameterControlTemplate(observedValues);
                        template.Name        = UIParameterTemplateNameInput.Text;
                        template.Description = UIParameterControlTemplateDescriptionInput.Text;

                        collection.Insert(template);
                    }
                    else
                    {
                        ParameterControlTemplate template = templateList[UIParameterControlTemplateList.SelectedIndex];
                        template.Name        = UIParameterTemplateNameInput.Text;
                        template.Description = UIParameterControlTemplateDescriptionInput.Text;
                        template.SetCollection(observedValues);

                        if (!collection.Update(template.Id, template))
                        {
                            Debug.Log("Update failed");
                        }
                        else
                        {
                            Debug.Log("Update OK");
                        }
                    }
                }

                Close();
            }
            else
            {
                MessageBox.Show("Cannot save, no name given");
            }
        }
Esempio n. 9
0
        public void LoadParameterControlTemplate(ParameterControlTemplate template)
        {
            activeParameterControlTemplate = template;

            UIParameterControlInput.Rows.Clear();
            UIObservedValuesOuputGrid.Rows.Clear();
            DataReceiver.ObservedValues.Clear();

            foreach (IObservableNumericValue v in template.Collection)
            {
                DataReceiver.ObservedValues.Add(v);
                ObservedDataRow row = new ObservedDataRow
                {
                    name  = v.Label,
                    value = v.Value.ToString(),
                    min   = v.Min.ToString(),
                    max   = v.Max.ToString()
                };
                AddParameterControlRow(row);
            }
        }
Esempio n. 10
0
        public void loadParameterControlTemplate(ParameterControlTemplate template, DataStream stream)
        {
            Debug.Log("Load parameter control template");
            ParameterControlTemplate = template;

            if (template.Collection != null)
            {
                internalReceiver.ObservedValues.Clear();

                // Clear subscriptions?
                internalReceiver.UnsubscribeAll(stream);

                foreach (IObservableNumericValue n in ParameterControlTemplate.Collection)
                {
                    internalReceiver.ObservedValues.Add(n);
                    internalReceiver.Subscribe(stream, n.Label, n.type.ToString());
                }

                internalReceiver.Observe = true;
            }
        }
Esempio n. 11
0
        public SatStatMainForm()
        {
            InitializeComponent();

            instruction_list = new JObject();

            PopulateRecentConnect();

            parameterControlTemplates = ParameterControlTemplate.GetListFromDb();
            autoParamControlTemplate  = new ParameterControlTemplate
            {
                Name = "Auto generated parameter control template"
            };

            Program.serial          = new SerialHandler();
            Program.streamSimulator = new StreamSimulator();
            Program.socketHandler   = new SocketHandler();

            Program.serial.OnConnected(OnStreamConnected);
            Program.streamSimulator.OnConnected(OnStreamConnected);
            Program.socketHandler.OnConnected(OnStreamConnected);

            Program.serial.OnDisconnected(OnStreamDisconnected);
            Program.streamSimulator.OnDisconnected(OnStreamDisconnected);
            Program.socketHandler.OnDisconnected(OnStreamDisconnected);

            activeStreams = new Dictionary <string, DataStream>();
            activeStreams.Add("serial", Program.serial);
            activeStreams.Add("streamSimulator", Program.streamSimulator);
            activeStreams.Add("socketHandler", Program.socketHandler);

            dataReceiver = new DataReceiver {
                Observe = true
            };
            dataReceiver.OnPayloadReceived(ReceivePayload);
            dataReceiver.OnObservedvalueChanged(ObservedValueChanged);

            sensorListReceiver = new DataReceiver();
            sensorListReceiver.OnPayloadReceived(ReceiveSensorList);
            sensorListReceiver.Subscribe(Program.serial, "available_data", "JObject");

            instructionListReceiver = new DataReceiver();
            instructionListReceiver.OnPayloadReceived(ReceiveInstructionList);
            instructionListReceiver.Subscribe(Program.serial, "available_instructions", "JObject");

            startTime = DateTime.Now;
            xAxis     = new DateTimeAxis {
                Key               = "xAxis",
                Position          = AxisPosition.Bottom,
                Title             = "Time",
                Minimum           = DateTimeAxis.ToDouble(startTime),
                Maximum           = DateTimeAxis.ToDouble(DateTime.Now.AddMinutes(1)),
                MinorIntervalType = DateTimeIntervalType.Minutes
            };

            yAxis = new LinearAxis {
                Key          = "yAxis",
                Position     = AxisPosition.Left,
                Title        = "Value",
                MinimumRange = 10
            };

            plotModel = new PlotModel {
                Title = "Live data view"
            };

            plotModel.Axes.Add(xAxis);
            plotModel.Axes.Add(yAxis);
            oxPlot.Model = plotModel;

            DiscoverComDevices();
        }
Esempio n. 12
0
 public void setParameterControlTemplate(ParameterControlTemplate template)
 {
     ParameterControlTemplate = template;
 }