Example #1
0
        public void setRS232Group(RS232Group rs232Group)
        {
            if (rs232Group == null)
            {
                rs232Group = new RS232Group("Placehold RS232 group. Do not use.");
                replacementGroupSelector.Enabled = false;
            }
            else
            {
                replacementGroupSelector.Enabled = true;
            }

            this.rs232Group = rs232Group;


            previousObjectBackup = rs232Group;

            this.renameTextBox.Text = rs232Group.GroupName;
            fillSelectorCombobox();
            rs232GroupBeingChanged = true;
            this.rs232GroupSelector.SelectedItem = rs232Group;
            rs232GroupBeingChanged = false;
            layoutGroupChannelSelectors();
            layoutGraphCollection();
            waveformEditor1.setWaveform(null);
            descBox.Text = rs232Group.GroupDescription;
            replacementGroupSelector.SelectedItem = null;
        }
        private void rs232Selector_SelectedValueChanged(object sender, EventArgs e)
        {
            if (rs232Selector.SelectedItem.ToString() == "Continue")
            {
                rs232Selector.BackColor = Color.Green;
                toolTip1.SetToolTip(rs232Selector, "Continue previous RS232 group.");
            }
            else
            {
                rs232Selector.BackColor = Color.White;
            }

            if (stepData != null)
            {
                RS232Group gg = rs232Selector.SelectedItem as RS232Group;
                stepData.rs232Group = gg;
                if (updateGUI != null)
                {
                    updateGUI(sender, e);
                }
                if (gg != null)
                {
                    toolTip1.SetToolTip(rs232Selector, gg.GroupDescription);
                }
            }

            rs232SelectorBackupItem = rs232Selector.SelectedItem;
        }
Example #3
0
        private void button1_Click(object sender, EventArgs e)
        {
            RS232Group gg = new RS232Group("RS232 Group " + (Storage.sequenceData.RS232Groups.Count + 1));

            Storage.sequenceData.RS232Groups.Add(gg);
            setRS232Group(gg);
        }
        public void setRS232Group(RS232Group rs232Group)
        {
            if (rs232Group == null)
            {
                rs232Group = new RS232Group("Placehold RS232 group. Do not use.");
                replacementGroupSelector.Enabled = false;
            }
            else
                replacementGroupSelector.Enabled = true;

            this.rs232Group = rs232Group;

            previousObjectBackup = rs232Group;

            this.renameTextBox.Text = rs232Group.GroupName;
            fillSelectorCombobox();
            rs232GroupBeingChanged = true;
            this.rs232GroupSelector.SelectedItem = rs232Group;
            rs232GroupBeingChanged = false;
            layoutGroupChannelSelectors();
            layoutGraphCollection();
            waveformEditor1.setWaveform(null);
            descBox.Text = rs232Group.GroupDescription;
            replacementGroupSelector.SelectedItem = null;
        }
Example #5
0
 private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (!rs232GroupBeingChanged)
     {
         previousObjectBackup = rs232GroupSelector.SelectedItem;
         RS232Group gg = rs232GroupSelector.SelectedItem as RS232Group;
         setRS232Group(gg);
     }
 }
Example #6
0
        private void renameButton_Click(object sender, EventArgs e)
        {
            RS232Group temp = this.rs232Group;

            if (rs232Group != null)
            {
                rs232Group.GroupName = renameTextBox.Text;
                this.rs232GroupSelector.SelectedItem = null;
                this.rs232GroupSelector.SelectedItem = temp;
            }
        }
Example #7
0
        public void updateRunOrderPanel()
        {
            if (runOrderLabels != null)
            {
                foreach (Label lab in runOrderLabels)
                {
                    runOrderPanel.Controls.Remove(lab);
                    lab.Dispose();
                }
                runOrderLabels.Clear();
                runOrderLabelGroups.Clear();
            }
            else
            {
                runOrderLabels      = new List <Label>();
                runOrderLabelGroups = new Dictionary <Label, RS232Group>();
            }

            int xPos = label2.Location.X + label2.Width;

            if (Storage.sequenceData != null)
            {
                if (Storage.sequenceData.TimeSteps != null)
                {
                    foreach (TimeStep step in Storage.sequenceData.enabledTimeSteps())
                    {
                        if (step.rs232Group != null)
                        {
                            RS232Group rg  = step.rs232Group;
                            Label      lab = new Label();
                            lab.Text         = rg.ToString();
                            lab.BorderStyle  = BorderStyle.FixedSingle;
                            lab.AutoSize     = false;
                            lab.Width        = 80;
                            lab.TextAlign    = ContentAlignment.MiddleCenter;
                            lab.AutoEllipsis = true;
                            lab.Location     = new Point(xPos, label2.Location.Y);
                            lab.Click       += new EventHandler(runOrderLabelClick);
                            runOrderLabelGroups.Add(lab, rg);
                            runOrderLabels.Add(lab);



                            this.toolTip1.SetToolTip(lab, "Timestep: " + step.StepName + ", Duration: " + step.StepDuration.ToString());

                            xPos += lab.Width + 10;
                        }
                    }
                }
            }

            runOrderPanel.Controls.AddRange(runOrderLabels.ToArray());
        }
Example #8
0
        private void replaceGroupButton_Click(object sender, EventArgs e)
        {
            RS232Group replacementGroup = replacementGroupSelector.SelectedItem as RS232Group;

            if (replacementGroup != null)
            {
                if (replacementGroup != this.rs232Group)
                {
                    DialogResult result = MessageBox.Show("This will permanently replace all occurences of the currently edited group with the group selected near the Replace button. Are you sure you want to proceed?", "Replace analog group?", MessageBoxButtons.YesNo);
                    if (result == DialogResult.Yes)
                    {
                        Storage.sequenceData.replaceRS232Group(rs232Group, replacementGroup);
                        WordGenerator.MainClientForm.instance.RefreshSequenceDataToUI();
                    }
                }
            }
        }
        public override bool outputRS232Group(RS232Group rs232Group, SettingsData settings)
        {
            lock (remoteLockObj)
            {

                try
                {
                    messageLog(this, new MessageEvent("Received an output rs232 group request."));

                    if (rs232Group == null)
                    {
                        messageLog(this, new MessageEvent("Received a null output object. Unable to comply."));
                        displayError();
                        return false;
                    }

                    if (!stopAndCleanupTasks())
                        return false;

                    if (!setSettings(settings))
                        return false;

                    foreach (int channelID in usedRS232Channels.Keys)
                    {
                        if (rs232Group.channelEnabled(channelID))
                        {
                            HardwareChannel hc = usedRS232Channels[channelID];
                            RS232GroupChannelData channelData = rs232Group.ChannelDatas[channelID];
                            if (channelData.DataType == RS232GroupChannelData.RS232DataType.Raw)
                            {
                                NationalInstruments.VisaNS.SerialSession ss = getSerialSession(hc);
                                ss.Write(RS232Task.AddNewlineCharacters(channelData.RawString));
                                messageLog(this, new MessageEvent("Wrote rs232 command " + channelData.RawString));
                            }
                            else if (channelData.DataType == RS232GroupChannelData.RS232DataType.Parameter)
                            {
                                if (channelData.StringParameterStrings != null)
                                {
                                    foreach (StringParameterString sps in channelData.StringParameterStrings)
                                    {
                                        NationalInstruments.VisaNS.SerialSession ss = getSerialSession(hc);
                                        string rawCommand = sps.ToString();
                                        string command = RS232Task.AddNewlineCharacters(rawCommand);
                                        ss.Write(command);
                                        messageLog(this, new MessageEvent("Wrote rs232 command " + rawCommand));
                                    }
                                }
                            }
                            else
                            {
                                messageLog(this, new MessageEvent("Skipping output on channel " + channelID + ", output now not enabled for data of type " + channelData.DataType.ToString()));
                            }
                        }
                    }

                    return true;
                }
                catch (Exception e)
                {
                    messageLog(this, new MessageEvent("Caught exception when attempting output of single rs232 group: " + e.Message + e.StackTrace));
                    displayError();
                    return false;
                }

                return true;
            }
        }
        /// <summary>
        /// Replaces all occurences in sequence of RS232 group ReplaceMe with group Withme, then
        /// removes ReplaceMe from list of groups.
        /// </summary>
        /// <param name="replaceMe"></param>
        /// <param name="withMe"></param>
        public void replaceRS232Group(RS232Group replaceMe, RS232Group withMe)
        {
            foreach (TimeStep step in TimeSteps)
            {
                if (step.rs232Group == replaceMe)
                {
                    step.rs232Group = withMe;
                }
            }

            if (rs232Groups.Contains(replaceMe))
                rs232Groups.Remove(replaceMe);
        }
 public override bool outputRS232Group(RS232Group rs232Group, SettingsData settings)
 {
     return(true);
 }
 public ServerActionStatus outputRS232GroupOnConnectedServers(RS232Group rs232Group, SettingsData settings, EventHandler<MessageEvent> messageLog)
 {
     return runNamedMethodOnConnectedServers("outputRS232Group", new object[] { rs232Group, settings }, 4000, messageLog);
 }
 public void activateRS232GroupEditor(RS232Group rg)
 {
     this.rS232GroupEditor1.setRS232Group(rg);
     this.mainTab.SelectedIndex = 3;
 }
 /// <summary>
 /// Outputs a single rs232 Group. (evaluated at the beginning of the group.)
 /// </summary>
 /// <param name="rs232Group"></param>
 /// <param name="settings"></param>
 /// <returns></returns>
 public abstract bool outputRS232Group(RS232Group rs232Group, SettingsData settings);
 public override bool outputRS232Group(RS232Group rs232Group, SettingsData settings)
 {
     return true;
 }
 private void button1_Click(object sender, EventArgs e)
 {
     RS232Group gg = new RS232Group("RS232 Group " + (Storage.sequenceData.RS232Groups.Count + 1));
     Storage.sequenceData.RS232Groups.Add(gg);
     setRS232Group(gg);
 }