public TimestepEditor()
        {
            InitializeComponent();
            stepData = new TimeStep();
            analogSelector.Items.Add("Continue");
            analogSelector.SelectedItem = "Continue";

            gpibSelector.Items.Add("Continue");
            gpibSelector.SelectedItem = "Continue";

            rs232Selector.Items.Add("Continue");
            rs232Selector.SelectedItem = "Continue";

            // If we are using Windows 7,
            // then the combo boxes must have a non-default
            // style in order to support background colors
            if (WordGenerator.GlobalInfo.usingWindows7)
            {
                analogSelector.FlatStyle = FlatStyle.Popup;
                gpibSelector.FlatStyle = FlatStyle.Popup;
                rs232Selector.FlatStyle = FlatStyle.Popup;
            }

            durationEditor.setMinimumAllowableManualValue(0);

            this.Width = TimestepEditorWidth;
            this.Height = TimestepEditorHeight;
        }
예제 #2
0
 /// <summary>
 /// Duplicate creation constructor for Timesteps. Creates an independently editable copy of the timestep
 /// </summary>
 /// <param name="duplicateMe"></param>
 public TimeStep(TimeStep duplicateMe)
     : this()
 {
     this.AnalogGroup = duplicateMe.AnalogGroup;
     foreach (int id in duplicateMe.DigitalData.Keys)
     {
         this.DigitalData.Add(id, new DigitalDataPoint(duplicateMe.DigitalData[id]));
     }
     this.GpibGroup = duplicateMe.GpibGroup;
     this.rs232Group = duplicateMe.rs232Group;
     this.StepDuration = new DimensionedParameter(duplicateMe.stepDuration);
     this.StepEnabled = duplicateMe.StepEnabled;
     this.StepHidden = duplicateMe.StepHidden;
     this.StepName = "Copy of " + duplicateMe.StepName;
     this.MyTimestepGroup = duplicateMe.MyTimestepGroup;
     this.Description = duplicateMe.Description;
     this.LoopCopy = duplicateMe.LoopCopy;
     this.RetriggerOptions = new RetriggerOptions(duplicateMe.RetriggerOptions);
 }
        public SingleOutputFrame getSingleOutputFrameAtEndOfTimestep(TimeStep step, SettingsData settings, bool outputAnalogDwellValues)
        {
            int analogStepID;
            if (outputAnalogDwellValues)
            {
                analogStepID = TimeSteps.IndexOf(dwellWord());
            }
            else
            {
                analogStepID = TimeSteps.IndexOf(step);
            }

            TimeStep analogStep = TimeSteps[analogStepID];

            int timeStepID = TimeSteps.IndexOf(step);

            SingleOutputFrame ans = new SingleOutputFrame();

            foreach (int analogID in settings.logicalChannelManager.Analogs.Keys)
            {
                if (settings.logicalChannelManager.Analogs[analogID].TogglingChannel)
                {
                    ans.analogValues.Add(analogID, 0);
                }
                else if (settings.logicalChannelManager.Analogs[analogID].overridden)
                {
                    ans.analogValues.Add(analogID, settings.logicalChannelManager.Analogs[analogID].analogOverrideValue);
                }
                else
                {
                    if (settings.logicalChannelManager.Analogs[analogID].AnalogChannelOutputNowUsesDwellWord)
                    {
                        ans.analogValues.Add(analogID, getAnalogValueAtEndOfTimestep(TimeSteps.IndexOf(dwellWord()), analogID, Variables));
                    }
                    else
                    {
                        ans.analogValues.Add(analogID, getAnalogValueAtEndOfTimestep(analogStepID, analogID, Variables));
                    }
                }
            }

            foreach (int digitalID in settings.logicalChannelManager.Digitals.Keys)
            {
                bool val = false;
                if (settings.logicalChannelManager.Digitals[digitalID].TogglingChannel) {
                    val = false;
                }
                else if (settings.logicalChannelManager.Digitals[digitalID].overridden)
                {
                    val = settings.logicalChannelManager.Digitals[digitalID].digitalOverrideValue;
                }
                else
                {
                    if (step.DigitalData.ContainsKey(digitalID))
                    {
                        DigitalDataPoint dp = step.DigitalData[digitalID];
                        if (!dp.DigitalContinue)
                        {
                            val = step.DigitalData[digitalID].getValue();
                        }
                        else  // this digital value is a "continue" value, so, we have to go backwards in time until we find
                        // what value to continue from
                        {
                            int checkStep = timeStepID - 1;
                            val = false; // if we hunt all the way to the first timestep with no answer, the default answer is false
                            while (checkStep >= 0)
                            {
                                if (TimeSteps[checkStep].StepEnabled)
                                {
                                    if (TimeSteps[checkStep].DigitalData.ContainsKey(digitalID))
                                    {
                                        if (TimeSteps[checkStep].DigitalData[digitalID].DigitalContinue)
                                        {
                                            checkStep--; // timestep had another continue keep hunting backwards...
                                        }
                                        else
                                        {
                                            val = TimeSteps[checkStep].DigitalData[digitalID].getValue();
                                            break;
                                        }
                                    }
                                    else
                                    {
                                        break;
                                    }
                                }
                                else
                                {
                                    checkStep--; // timestep was disabled, keep looking
                                }
                            }
                        }

                    }
                }
                ans.digitalValues.Add(digitalID, val);
            }

            return ans;
        }
 public int getSamplesAtTimestep(TimeStep step, double timeStepSize)
 {
     int count = 0;
     double remainderTime = 0;
     foreach (TimeStep ts in TimeSteps)
     {
         if (ts == step)
             return count;
         if (ts.StepEnabled)
         {
             int temp = 0;
             computeNSamplesAndRemainderTime(ref temp, ref remainderTime, ts.StepDuration.getBaseValue(), timeStepSize);
             count += temp;
         }
     }
     return -1;
 }
예제 #5
0
 public TimeStep getLoopCopy(int loopNum, int totalLoops)
 {
     TimeStep ans = new TimeStep(this);
     ans.LoopCopy = true;
     ans.loopOriginalCopy = this;
     ans.StepName = this.StepName + " Loop #" + loopNum + "/" + totalLoops;
     return ans;
 }
예제 #6
0
 /// <summary>
 /// Returns false if step is null.
 /// </summary>
 /// <param name="step"></param>
 /// <returns></returns>
 public static bool isEnabled(TimeStep step)
 {
     if (step == null)
         return false;
     return step.StepEnabled;
 }
예제 #7
0
 public void scrollToTimestep(TimeStep step)
 {
     foreach (Control con in timeStepsFlowPanel.Controls)
     {
         TimestepEditor ed = con as TimestepEditor;
         if (ed != null)
         {
             if (ed.StepData == step)
             {
                 timeStepsPanel.ScrollControlIntoView(ed);
                 forceUpdateAllScrollbars();
                 return;
             }
         }
     }
 }
        /// <summary>
        /// Used to register timestep hotkeys. Ctrl + key.
        /// 
        /// returns true if successful,
        /// false if key was already in use
        /// </summary>
        /// <param name="key"></param>
        /// <param name="timeStep"></param>
        public bool registerTimestepHotkey(char key, TimeStep timeStep)
        {
            if (hotKeyBindings == null)
                hotKeyBindings = new List<object>();

            if (usedTimestepHotkeys == null)
                usedTimestepHotkeys = new List<char>();

            if (usedTimestepHotkeys.Contains(key))
                return false;

            // convert the character to a Keys enum element. This is weird but necessary.
            string keyStr = "" + char.ToUpper(key);

            Keys myKey = (Keys)Enum.Parse(typeof(Keys), keyStr);

            RegisterHotKey(Handle, hotKeyBindings.Count, KeyModifiers.Control, myKey);
            hotKeyBindings.Add(timeStep);

            return false;
        }
 private void updateDescriptionTooltip(TimeStep stepData)
 {
     toolTip1.SetToolTip(this.timeStepNumber, stepData.Description);
     toolTip1.SetToolTip(this.timestepName, stepData.Description);
 }
        public TimestepEditor(TimeStep stepData, int timeStepNumber)
            : this()
        {
            if (stepData!=null)
                this.stepData = stepData;

            updateDescriptionTooltip(stepData);
            descriptionTextBox.Text = stepData.Description;

            this.stepNumber = timeStepNumber;

            timestepName.Text = stepData.StepName;

            this.durationEditor.setParameterData(stepData.StepDuration);
            redrawStepNumberLabel();

            analogSelector.Items.AddRange(Storage.sequenceData.AnalogGroups.ToArray());
            gpibSelector.Items.AddRange(Storage.sequenceData.GpibGroups.ToArray());
            rs232Selector.Items.AddRange(Storage.sequenceData.RS232Groups.ToArray());

            if (stepData.AnalogGroup != null)
            {
                this.analogSelector.SelectedItem = stepData.AnalogGroup;
                this.analogSelector.BackColor = Color.White;
                this.analogSelector.Visible = true;
            }
            else
            {
                this.analogSelector.SelectedItem = "Continue";
                this.analogSelector.BackColor = Color.Green;
            }

            if (stepData.GpibGroup != null)
            {
                this.gpibSelector.SelectedItem = stepData.GpibGroup;
                this.gpibSelector.BackColor = Color.White;
                this.gpibSelector.Visible = true;
            }
            else
            {
                this.gpibSelector.SelectedItem = "Continue";
                this.gpibSelector.BackColor = Color.Green;
            }

            if (stepData.rs232Group != null)
            {
                rs232Selector.SelectedItem = stepData.rs232Group;
                rs232Selector.BackColor = Color.White;
                this.rs232Selector.Visible = true;
            }
            else
            {
                rs232Selector.SelectedItem = "Continue";
                rs232Selector.BackColor = Color.Green;
            }

            this.negativeRetriggerEdgeOrValueToolStripMenuItem.Checked = stepData.RetriggerOptions.RetriggerOnNegativeValueOrEdge;
            this.edgeRetriggerToolStripMenuItem.Checked = stepData.RetriggerOptions.RetriggerOnEdge;

            layoutEnableButton();
            layoutShowhideButton();
            updatePulsesIndicator();
            layoutGroupIndicatorLabel();
            updateWaitForRetriggerIndicator();
        }
        private void insertTimestepBeforeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TimeStep newStep = new TimeStep("New timestep.");
            Storage.sequenceData.TimeSteps.Insert(stepNumber-1, newStep );
            Storage.sequenceData.populateWithChannels(Storage.settingsData);
            Storage.sequenceData.timestepsInsertedOrMoved();

            TimestepEditor te = new TimestepEditor(newStep, stepNumber);

            WordGenerator.MainClientForm.instance.sequencePage.insertTimestepEditor(te, stepNumber - 1);

            //    WordGenerator.mainClientForm.instance.RefreshSequenceDataToUI(Storage.sequenceData);
            //    WordGenerator.mainClientForm.instance.sequencePage1.scrollToTimestep(newStep);
        }
        private void insertTimestepAfterToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TimeStep newStep = new TimeStep("New timestep.");
            Storage.sequenceData.TimeSteps.Insert(stepNumber, newStep);
            Storage.sequenceData.populateWithChannels(Storage.settingsData);
            Storage.sequenceData.timestepsInsertedOrMoved();

            WordGenerator.MainClientForm.instance.sequencePage.insertTimestepEditor(
                new TimestepEditor(newStep, stepNumber + 1), stepNumber);
        }
        private void duplicateToolStripMenuItem_Click(object sender, EventArgs e)
        {
            TimeStep newStep = new TimeStep(this.stepData);
            Storage.sequenceData.TimeSteps.Insert(stepNumber, newStep);
            Storage.sequenceData.timestepsInsertedOrMoved();

            WordGenerator.MainClientForm.instance.sequencePage.insertTimestepEditor(
                new TimestepEditor(newStep, stepNumber + 1), stepNumber);
        }
        private void redrawStepNumberLabel(TimeStep stepData, int timeStepNumber)
        {
            this.timeStepNumber.Text = timeStepNumber.ToString();

            if (stepData.HotKeyCharacter != 0)
                this.timeStepNumber.Text += " {" + char.ToUpper(stepData.HotKeyCharacter) + "}";
        }
 public double getTimeAtTimestep(TimeStep step)
 {
     if (!TimeSteps.Contains(step))
         return 0;
     double ans = 0;
     foreach (TimeStep st in TimeSteps)
     {
         if (st == step)
             return ans;
         if (st.StepEnabled)
         {
             ans += st.StepDuration.getBaseValue();
         }
     }
     return ans;
 }
예제 #16
0
 public TimestepEditor getTimestepEditor(TimeStep timeStep)
 {
     foreach (Control con in timeStepsFlowPanel.Controls)
     {
         TimestepEditor editor = con as TimestepEditor;
         if (editor != null)
         {
             if (editor.StepData == timeStep)
             {
                 return editor;
             }
         }
     }
     return null;
 }
        public string insertSequence(SequenceData insertMe, TimeStep insertAfter)
        {
            int index = -1;
            for (int i=0; i<TimeSteps.Count; i++) {
                if (insertAfter == TimeSteps[i]) {
                    index = i;
                    break;
                }
            }

            return insertSequence(insertMe, index + 1);
        }
        /// <summary>
        /// outputs the editor's timestep. set silent to true if no message logs should be generated.
        /// </summary>
        /// <param name="silent"></param>
        /// <returns></returns>
        public bool outputTimestepNow(TimeStep timeStep, bool silent, bool showErrorDialog)
        {
            List<string> unconnectedServers = Storage.settingsData.unconnectedRequiredServers();

            if (!Storage.sequenceData.Lists.ListLocked)
            {
                WordGenerator.MainClientForm.instance.variablesEditor.tryLockLists();
            }
            if (!Storage.sequenceData.Lists.ListLocked)
            {
                if (!silent)
                    messageLog(this, new MessageEvent("Unable to output timestep, lists not locked."));
                if (showErrorDialog)
                {
                    MessageBox.Show("Unable to output timestep, lists not locked.");
                }
                return false;
            }

            if (unconnectedServers.Count == 0)
            {

                WordGenerator.MainClientForm.instance.cursorWait();
                ServerManager.ServerActionStatus actionStatus;
                try
                {

                    actionStatus = Storage.settingsData.serverManager.outputSingleTimestepOnConnectedServers(
                        Storage.settingsData,
                        Storage.sequenceData.getSingleOutputFrameAtEndOfTimestep(timeStep, Storage.settingsData, Storage.settingsData.OutputAnalogDwellValuesOnOutputNow),
                        messageLog);
                }
                finally
                {
                    WordGenerator.MainClientForm.instance.cursorWaitRelease();
                }

                if (actionStatus == ServerManager.ServerActionStatus.Success)
                {
                    if (!silent)
                        messageLog(this, new MessageEvent("Successfully output timestep " + timeStep.ToString()));
                    WordGenerator.MainClientForm.instance.CurrentlyOutputtingTimestep = timeStep;
                    return true;
                }
                else
                {

                    if (!silent)
                        messageLog(this, new MessageEvent("Communication or server error attempting to output this timestep: " + actionStatus.ToString()));
                    if (showErrorDialog)
                    {
                        MessageBox.Show("Communication or server error attempting to output this timestep: " + actionStatus.ToString());
                    }
                }
            }
            else
            {
                string missingServerList = ServerManager.convertListOfServersToOneString(unconnectedServers);
                if (!silent)
                    messageLog(this, new MessageEvent("Unable to output this timestep. The following required servers are not connected: " + missingServerList));

                if (showErrorDialog)
                {
                    MessageBox.Show("Unable to output this timestep. The following required servers are not connected: " + missingServerList);
                }
            }
            return false;
        }