Пример #1
0
 public SelectedDevice(string selectedTypeString, HardwareChannel.HardwareConstants.ChannelTypes channelType, int logicalID, LogicalChannel lc)
 {
     this.channelTypeString = selectedTypeString;
     this.channelType       = channelType;
     this.logicalID         = logicalID;
     this.lc = lc;
 }
Пример #2
0
        internal static TransientChannelTicket CreateTransientChannel(LogicalChannel logicalChannel)
        {
            DiagnosticUtility.DebugAssert(logicalChannel != null, "logical channel cannot be null");

            ChannelFactory factory       = null;
            IChannel       channel       = null;
            bool           channelOpened = false;

            try
            {
                factory       = ChannelManagerHelpers.CreateChannelFactory(logicalChannel.ConfigurationName, logicalChannel.ContractType);
                channel       = ChannelManagerHelpers.CreateChannel(logicalChannel.ContractType, factory, logicalChannel.CustomAddress);
                channelOpened = true;
            }
            finally
            {
                if (!channelOpened)
                {
                    if (channel != null)
                    {
                        ChannelManagerHelpers.CloseCommunicationObject(channel);
                    }
                    if (factory != null)
                    {
                        ChannelManagerHelpers.CloseCommunicationObject(factory);
                    }
                }
            }

            return(new TransientChannelTicket(channel, factory));
        }
Пример #3
0
        private void okButton_Click(object sender, EventArgs e)
        {
            // Construct the logical channel
            LogicalChannel lc = new LogicalChannel();

            lc.Name        = this.deviceNameText.Text;
            lc.Description = this.deviceDescText.Text;
            lc.AnalogChannelOutputNowUsesDwellWord = checkBox1.Checked;
            lc.TogglingChannel = togglingCheck.Checked;

            if (this.availableHardwareChanCombo.SelectedItem is HardwareChannel)
            {
                lc.HardwareChannel = (HardwareChannel)this.availableHardwareChanCombo.SelectedItem;
            }
            else
            {
                lc.HardwareChannel = HardwareChannel.Unassigned;
            }

            // Add to the appropriate collection
            selectedChannelCollection.AddChannel(lc);

            // Refresh the screen of the ChannelManager for visual feedback
            cm.RefreshLogicalDeviceDataGrid();

            // Close
            this.Close();
        }
Пример #4
0
        public DigitalOverride(LogicalChannel channel, int channelID) : this()
        {
            this.channel = channel;
            this.overrideCheck.Checked = channel.overridden;
            this.valueBox.Checked      = channel.digitalOverrideValue;
            if (this.overrideCheck.Checked)
            {
                this.valueBox.Enabled = true;
            }
            else
            {
                this.valueBox.Enabled = false;
            }

            this.label1.Text = channelID.ToString() + " " + channel.Name;
            toolTip1.SetToolTip(label1, channel.Description);
            if (channel.hotkeyChar != 0)
            {
                this.hotkeyLabel.Text = "{" + channel.hotkeyChar + "}";
            }

            if (channel.overrideHotkeyChar != 0)
            {
                this.overrideHotkeyLabel.Text = "{" + channel.overrideHotkeyChar + "}";
            }
        }
Пример #5
0
 public LogicalChannelBinding(LogicalChannel logicalChannel,
                              LogicalChannelBindingMethodDesc consumingBindingDesc,
                              LogicalChannelBindingMethodDesc consumingSignalBindingDesc)
 {
     LogicalChannel             = logicalChannel;
     ConsumingBindingDesc       = consumingBindingDesc;
     ConsumingSignalBindingDesc = consumingSignalBindingDesc;
 }
 public AnalogOverride(LogicalChannel channel, int channelID)
     : this()
 {
     this.channel                = channel;
     this.checkBox1.Checked      = channel.overridden;
     this.numericUpDown1.Value   = (decimal)channel.analogOverrideValue;
     this.numericUpDown1.Enabled = this.checkBox1.Checked;
     toolTip1.SetToolTip(label1, channel.Description);
     label1.Text = channelID.ToString() + " " + channel.Name;
 }
 public GroupChannelSelection()
 {
     InitializeComponent();
     groupChannelData    = new AnalogGroupChannelData(null, false, false);
     logicalChannel      = new LogicalChannel();
     logicalChannel.Name = "Placeholder Channel";
     this.commonWaveformSelector.Items.Add("Manual");
     this.commonWaveformSelector.SelectedItem = "Manual";
     this.setButtonAppearance();
 }
        public RS232GroupChannelSelection()
        {
            InitializeComponent();
            groupChannelData = new RS232GroupChannelData();
            logicalChannel   = new LogicalChannel();
            this.layout();

            foreach (RS232GroupChannelData.RS232DataType type in RS232GroupChannelData.allDataTypes)
            {
                this.dataTypeSelector.Items.Add(type);
            }
        }
Пример #9
0
        public GpibGroupChannelSelection()
        {
            InitializeComponent();
            groupChannelData = new GPIBGroupChannelData();
            logicalChannel   = new LogicalChannel();
            this.layout();

            foreach (GPIBGroupChannelData.GpibChannelDataType type in GPIBGroupChannelData.GpibChannelDataType.allTypes)
            {
                this.dataTypeSelector.Items.Add(type);
            }
        }
Пример #10
0
        internal static void ApplyLogicalChannelContext(LogicalChannel logicalChannel)
        {
            Fx.Assert(OperationContext.Current != null, "Can be called within a valid OperationContext Scope");

            WorkflowTrace.Host.TraceEvent(TraceEventType.Verbose, 0,
                                          "ChannelManagerService: updating context associated with logical channel {0}",
                                          logicalChannel.InstanceId);

            if (logicalChannel.Context != null)
            {
                new ContextMessageProperty(logicalChannel.Context).AddOrReplaceInMessageProperties(OperationContext.Current.OutgoingMessageProperties);
            }
        }
        public GroupChannelSelection(LogicalChannel logicalChannel, AnalogGroupChannelData groupChannelData, int channelID) : this()
        {
            this.groupChannelData = groupChannelData;
            setCommonWaveforms();
            layout();


            this.logicalChannel = logicalChannel;
            this.toolTip1.SetToolTip(channelNameLabel, logicalChannel.Description);


            channelNameLabel.Text = channelID.ToString() + " " + logicalChannel.Name;
        }
Пример #12
0
        internal static void UpdateLogicalChannelContext(LogicalChannel logicalChannel)
        {
            Fx.Assert(OperationContext.Current != null, "Can be called from valid OperationContextScope");

            WorkflowTrace.Host.TraceEvent(TraceEventType.Verbose, 0,
                                          "ChannelManagerService: updating context associated with logical channel {0}",
                                          logicalChannel.InstanceId);

            ContextMessageProperty contextMessageProperty;
            MessageProperties      properties = OperationContext.Current.IncomingMessageProperties;

            if (properties != null && ContextMessageProperty.TryGet(properties, out contextMessageProperty))
            {
                logicalChannel.Context = contextMessageProperty.Context;
            }
        }
        /// <summary>
        /// Based on the current state of the logicalDevicesDataGridView, determines the appropriate LogicalChannel
        /// object that is in "focus". This result is wrapped in the SelectedDevice class.
        ///
        /// If there is nothing selected in the logicalDevicesDataGrid, then we return null.
        /// </summary>
        private SelectedDevice DetermineSelectedLogicalChannelFromGrid()
        {
            if (logicalDevicesDataGridView.SelectedRows.Count == 0) // Do we actually have something selected?
            {
                return(null);
            }

            string selectedTypeString = logicalDevicesDataGridView.SelectedRows[0].Cells[0].Value.ToString();

            HardwareChannel.HardwareConstants.ChannelTypes selectedType = HardwareChannel.HardwareConstants.ParseChannelTypeFromString(selectedTypeString);

            int selectedLogicalID = int.Parse(logicalDevicesDataGridView.SelectedRows[0].Cells[1].Value.ToString());

            LogicalChannel lc = Storage.settingsData.logicalChannelManager.GetDeviceCollection(selectedType).Channels[selectedLogicalID];

            return(new SelectedDevice(selectedTypeString, selectedType, selectedLogicalID, lc));
        }
        public RS232GroupChannelSelection(LogicalChannel logicalChannel, RS232GroupChannelData groupChannelData) : this()
        {
            this.groupChannelData = groupChannelData;
            this.logicalChannel   = logicalChannel;

            this.toolTip1.SetToolTip(channelNameLabel, logicalChannel.Description);

            this.layout();

            this.dataTypeSelector.Items.Clear();
            foreach (RS232GroupChannelData.RS232DataType type in RS232GroupChannelData.allDataTypes)
            {
                this.dataTypeSelector.Items.Add(type);
            }
            //this.dataTypeSelector.Items.AddRange(GPIBGroupChannelData.GpibChannelDataType.allTypes);
            this.dataTypeSelector.SelectedItem = groupChannelData.DataType;
            this.rawStringTextBox.Text         = groupChannelData.RawString;
        }
        private void okButton_Click(object sender, EventArgs e)
        {
            // Construct the logical channel
            LogicalChannel lc = new LogicalChannel();

            lc.Name        = this.deviceNameText.Text;
            lc.Description = this.deviceDescText.Text;
            lc.AnalogChannelOutputNowUsesDwellWord = checkBox1.Checked;
            lc.TogglingChannel = togglingCheck.Checked;
            int ID = selectedChannelCollection.GetNextSuggestedKey();

            lc.OrderingGroup = orderingGroups.SelectedItem as String;
            //If turnOffBox is checked, add this channel to the set of channels to be turned off
            //if the analog input check fails
            if (turnOffBox.Checked)
            {
                if (!Storage.settingsData.ChannelsToTurnOff[lc.HardwareChannel.ChannelType].ContainsKey(ID))
                {
                    Storage.settingsData.ChannelsToTurnOff[lc.HardwareChannel.ChannelType].Add(ID, lc);
                }
            }
            else
            {
                Storage.settingsData.ChannelsToTurnOff[lc.HardwareChannel.ChannelType].Remove(ID);
            }

            if (this.availableHardwareChanCombo.SelectedItem is HardwareChannel)
            {
                lc.HardwareChannel = (HardwareChannel)this.availableHardwareChanCombo.SelectedItem;
            }
            else
            {
                lc.HardwareChannel = HardwareChannel.Unassigned;
            }

            // Add to the appropriate collection
            selectedChannelCollection.AddChannel(lc);

            // Refresh the screen of the ChannelManager for visual feedback
            cm.RefreshLogicalDeviceDataGrid();

            // Close
            this.Close();
        }
Пример #16
0
        public void LoadOldGpibTest()
        {
            SettingsData gpibTestSettings = (SettingsData)
                                            SharedTestFunctions.loadTestFile("OldGpibAddressSettings.set", typeof(SettingsData),
                                                                             true,
                                                                             new Common.GpibBinderFix());

            Assert.AreEqual(5, gpibTestSettings.logicalChannelManager.GPIBs.Count);
            for (int i = 0; i < gpibTestSettings.logicalChannelManager.GPIBs.Count; i++)
            {
                LogicalChannel chan = gpibTestSettings.logicalChannelManager.GPIBs[i];
                Assert.AreEqual(HardwareChannel.HardwareConstants.ChannelTypes.gpib, chan.HardwareChannel.ChannelType);
                Assert.AreEqual("test description " + i, chan.HardwareChannel.ChannelDescription);
                Assert.AreEqual("test channel " + i, chan.HardwareChannel.ChannelName);
                Assert.AreEqual("test device " + i, chan.HardwareChannel.DeviceName);
//                Assert.AreEqual(i, chan.HardwareChannel.GpibAddress.PrimaryAddress);     //  These asserts are expected to fail
//                Assert.AreEqual(i, chan.HardwareChannel.GpibAddress.SecondaryAddress);   //  due to incompatibility in deserializing
                //  old gpib channel addresses
            }
        }
Пример #17
0
        internal PooledChannelTicket TakeChannel(Guid workflowId, LogicalChannel logicalChannel)
        {
            if (this.closed)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR2.GetString(SR2.Error_CannotProvideChannel_ServiceStopped, logicalChannel.ConfigurationName, logicalChannel.CustomAddress)));
            }

            if (workflowId == Guid.Empty)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("workflowId",
                                                                             SR2.GetString(SR2.Error_Cache_InvalidWorkflowId));
            }

            if (logicalChannel == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("logicalChannel");
            }

            WorkflowTrace.Host.TraceEvent(TraceEventType.Information, 0, "ChannelManagerService: get channel for workflow instance {0}, logical channel {1}", new object[] { workflowId, logicalChannel.InstanceId });

            string endpointName  = logicalChannel.ConfigurationName;
            Type   contractType  = logicalChannel.ContractType;
            string customAddress = logicalChannel.CustomAddress;

            ChannelPoolKey channelKey;

            ChannelManager.PooledChannel channel = this.channelManager.TakeChannel(endpointName, contractType, customAddress, out channelKey);
            if (channel == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(
                          new InvalidOperationException(SR2.GetString(SR2.Error_CannotProvideChannel, logicalChannel.ConfigurationName, logicalChannel.CustomAddress)));
            }

            PooledChannelTicket pooledChannel = new PooledChannelTicket(this, channel, channelKey, workflowId, logicalChannel.InstanceId);

            return(pooledChannel);
        }
Пример #18
0
        internal static ChannelTicket Take(ActivityExecutionContext executionContext, Guid workflowId, LogicalChannel logicalChannel)
        {
            if (executionContext == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("executionContext");
            }

            if (workflowId == Guid.Empty)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgument("workflowId",
                                                                             SR2.GetString(SR2.Error_Cache_InvalidWorkflowId));
            }

            if (logicalChannel == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("logicalChannel");
            }

            ChannelManagerService channelManager = executionContext.GetService <ChannelManagerService>();

            ChannelTicket channel;

            if (channelManager != null)
            {
                channel = channelManager.TakeChannel(workflowId, logicalChannel);
            }
            else
            {
                channel = ChannelManagerService.CreateTransientChannel(logicalChannel);
            }

            return(channel);
        }
Пример #19
0
        public void setSettings(SettingsData settings)
        {
            if (MainClientForm.instance != null)
            {
                MainClientForm.instance.cursorWait();
            }
            try
            {
                if (digitalOverrides == null)
                {
                    digitalOverrides = new List <DigitalOverride>();
                }
                foreach (DigitalOverride dov in digitalOverrides)
                {
                    digitalOverridePanel.Controls.Remove(dov);
                    dov.unRegsiterHotkey();
                    dov.Dispose();
                }
                digitalOverrides.Clear();

                List <int> digitalIDs = new List <int>(settings.logicalChannelManager.Digitals.Keys);
                digitalIDs.Sort();
                int counter = 0;
                foreach (int id in digitalIDs)
                {
                    LogicalChannel  chan = settings.logicalChannelManager.Digitals[id];
                    DigitalOverride dov  = new DigitalOverride(chan, id);
                    dov.Location = new Point(digitalOverridePlaceholder.Location.X,
                                             digitalOverridePlaceholder.Location.Y + counter * (digitalOverridePlaceholder.Height - 4));
                    digitalOverrides.Add(dov);
                    dov.registerHotkey();
                    dov.BackColor = Storage.settingsData.DigitalGridColors[counter % Storage.settingsData.DigitalGridColors.Count];
                    counter++;
                }
                digitalOverridePanel.Controls.AddRange(digitalOverrides.ToArray());

                if (analogOverrides == null)
                {
                    analogOverrides = new List <AnalogOverride>();
                }
                foreach (AnalogOverride ao in analogOverrides)
                {
                    analogOverridePanel.Controls.Remove(ao);
                    ao.Dispose();
                }
                analogOverrides.Clear();

                List <int> analogIDs = new List <int>(settings.logicalChannelManager.Analogs.Keys);
                analogIDs.Sort();
                counter = 0;
                foreach (int id in analogIDs)
                {
                    LogicalChannel chan = settings.logicalChannelManager.Analogs[id];
                    AnalogOverride ao   = new AnalogOverride(chan, id);
                    ao.Location = new Point(analogOverridePlaceholder.Location.X, analogOverridePlaceholder.Location.Y + counter * analogOverridePlaceholder.Height);
                    analogOverrides.Add(ao);
                    counter++;
                }
                analogOverridePanel.Controls.AddRange(analogOverrides.ToArray());
            }
            finally
            {
                if (MainClientForm.instance != null)
                {
                    MainClientForm.instance.cursorWaitRelease();
                }
            }
        }
        private void EmitLogicalDeviceToGrid(HardwareChannel.HardwareConstants.ChannelTypes ct, int logicalID, LogicalChannel lc)
        {
            //ToDo: Edit to include channel's ordering group
            string[] row = { ct.ToString(),
                             logicalID.ToString(),
                             lc.Name,
                             lc.Description,
                             lc.HardwareChannel.ToString(),
                             lc.OrderingGroup };
            logicalDevicesDataGridView.Rows.Add(row);

            //Change row's color if the channel is one that is supposed to turn off if AI check fails
            int rowNum = logicalDevicesDataGridView.Rows.Count - 1;

            if (Storage.settingsData.ChannelsToTurnOff[ct].ContainsKey(logicalID))
            {
                logicalDevicesDataGridView.Rows[rowNum].DefaultCellStyle.BackColor = System.Drawing.Color.LightSlateGray;
            }
        }
Пример #21
0
 private void EmitLogicalDeviceToGrid(HardwareChannel.HardwareConstants.ChannelTypes ct, int logicalID, LogicalChannel lc)
 {
     string[] row = { ct.ToString(),
                      logicalID.ToString(),
                      lc.Name,
                      lc.Description,
                      lc.HardwareChannel.ToString() };
     logicalDevicesDataGridView.Rows.Add(row);
 }