Exemple #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;
 }
Exemple #2
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);
 }
Exemple #3
0
        /// <summary>
        /// Emits all devices in Storage.settingsData.logicalChannelManager that have the particular ChannelType ct
        /// to the GridView in the "Logical devices" tab of the ChannelManager form. It makes use of EmitLogicalDeviceToGrid
        /// method which is responsible for emitting a single logical device to the grid.
        /// </summary>
        private void EmitLogicalDeviceDictToGrid(HardwareChannel.HardwareConstants.ChannelTypes ct)
        {
            ChannelCollection selectedDeviceDict =
                Storage.settingsData.logicalChannelManager.GetDeviceCollection(ct);

            foreach (int logicalID in selectedDeviceDict.Channels.Keys)
            {
                EmitLogicalDeviceToGrid(ct, logicalID, selectedDeviceDict.Channels[logicalID]);
            }
        }
 public HardwareChannel(string serverName, string deviceName, string channelName, string channelDescription, HardwareChannel.HardwareConstants.ChannelTypes ct)
 {
     gpibMasquerade = false;
     myGpibMasqueradeType = GpibMasqueradeType.NONE;
     this.serverName = serverName;
     this.deviceName = deviceName;
     this.channelName = channelName;
     this.channelDescription = channelDescription;
     this.channelType = ct;
     this.isUnAssigned = false;
     this.gpibAddress = new DataStructures.Gpib.Address();
     this.gpibDeviceType = HardwareConstants.GPIBDeviceType.Unknown;
 }
 public HardwareChannel(string serverName, string deviceName, string channelName, string channelDescription, HardwareChannel.HardwareConstants.ChannelTypes ct)
 {
     gpibMasquerade          = false;
     myGpibMasqueradeType    = GpibMasqueradeType.NONE;
     this.serverName         = serverName;
     this.deviceName         = deviceName;
     this.channelName        = channelName;
     this.channelDescription = channelDescription;
     this.channelType        = ct;
     this.isUnAssigned       = false;
     this.gpibAddress        = new DataStructures.Gpib.Address();
     this.gpibDeviceType     = HardwareConstants.GPIBDeviceType.Unknown;
 }
        /// <summary>
        /// Emits all devices in Storage.settingsData.logicalChannelManager that have the particular ChannelType ct
        /// to the GridView in the "Logical devices" tab of the ChannelManager form. It makes use of EmitLogicalDeviceToGrid
        /// method which is responsible for emitting a single logical device to the grid.
        /// </summary>
        private void EmitLogicalDeviceDictToGrid(HardwareChannel.HardwareConstants.ChannelTypes ct)
        {
            ChannelCollection selectedDeviceDict =
                Storage.settingsData.logicalChannelManager.GetDeviceCollection(ct);
            List <KeyValuePair <int, LogicalChannel> > channels = new List <KeyValuePair <int, LogicalChannel> >(selectedDeviceDict.Channels);

            if (orderChannelsCheckBox.Checked)
            {
                OrderLogicalChannels(orderChannels.SelectedItem as String, channels);
            }

            foreach (KeyValuePair <int, LogicalChannel> channel in channels)
            {
                EmitLogicalDeviceToGrid(ct, channel.Key, channel.Value);
            }
        }
        /// <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));
        }
        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;
            }
        }
Exemple #9
0
        /// <summary>
        /// In the small AddDevice form, everything begins as soon as the user specifies which ChannelType is to
        /// be modified.
        /// </summary>
        private void deviceTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Point to the correct DeviceCollection
            string selectedTypeString = this.deviceTypeCombo.SelectedItem.ToString();

            selectedChannelType       = HardwareChannel.HardwareConstants.ParseChannelTypeFromString(selectedTypeString);
            selectedChannelCollection = Storage.settingsData.logicalChannelManager.GetDeviceCollection(selectedChannelType);

            // Initialize and enable the Name, Description text entries and the HardwareChannel drop-down list
            this.deviceNameText.Enabled = true;
            this.deviceDescText.Enabled = true;

            refreshHardwareChanCombo();
            this.availableHardwareChanCombo.Enabled = true;

            // Indicate the logical ID to be used
            this.logicalIDText.Text = selectedChannelCollection.GetNextSuggestedKey().ToString();

            okButton.Enabled = true; // Now we can allow the OK button

            if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog)
            {
                checkBox1.Visible = true;
            }
            else
            {
                checkBox1.Visible = false;
            }

            if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog ||
                selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.digital)
            {
                togglingCheck.Visible = true;
            }
            else
            {
                togglingCheck.Visible = false;
            }
        }
        /// <summary>
        /// The following method is responsible for appropriately updating the main logicalDevicesDataGridView with the entries
        /// that correspond to the current deviceTypeCombo selection.
        /// </summary>
        public void RefreshLogicalDeviceDataGrid()
        {
            // Clear the DataGridView
            logicalDevicesDataGridView.Rows.Clear();

            // Treat the "Show all" selection separately from the others
            if (this.deviceTypeCombo.SelectedIndex != 0) // Not "Show all"
            {
                string selectedTypeString = this.deviceTypeCombo.SelectedItem.ToString();
                HardwareChannel.HardwareConstants.ChannelTypes selectedChannelType = HardwareChannel.HardwareConstants.ParseChannelTypeFromString(selectedTypeString);

                EmitLogicalDeviceDictToGrid(selectedChannelType);
            }
            else // We are in the "Show all" case
            {
                // Emit all devices to the grid
                foreach (HardwareChannel.HardwareConstants.ChannelTypes ct in HardwareChannel.HardwareConstants.allChannelTypes)
                {
                    EmitLogicalDeviceDictToGrid(ct);
                }
            }
        }
        /// <summary>
        /// In the small AddDevice form, everything begins as soon as the user specifies which ChannelType is to 
        /// be modified. 
        /// </summary>
        private void deviceTypeCombo_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Point to the correct DeviceCollection
            string selectedTypeString = this.deviceTypeCombo.SelectedItem.ToString();
            selectedChannelType = HardwareChannel.HardwareConstants.ParseChannelTypeFromString(selectedTypeString);
            selectedChannelCollection = Storage.settingsData.logicalChannelManager.GetDeviceCollection(selectedChannelType);

            // Initialize and enable the Name, Description text entries and the HardwareChannel drop-down list
            this.deviceNameText.Enabled = true;
            this.deviceDescText.Enabled = true;

            refreshHardwareChanCombo();
            this.availableHardwareChanCombo.Enabled = true;

            // Indicate the logical ID to be used
            this.logicalIDText.Text = selectedChannelCollection.GetNextSuggestedKey().ToString();

            okButton.Enabled = true; // Now we can allow the OK button

            if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog)
            {
                checkBox1.Visible = true;
            }
            else
            {
                checkBox1.Visible = false;
            }

            if (selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.analog ||
                selectedChannelType == HardwareChannel.HardwareConstants.ChannelTypes.digital)
            {
                togglingCheck.Visible = true;
            }
            else
            {
                togglingCheck.Visible = false;
            }
        }
 public ChannelCollection GetDeviceCollection(HardwareChannel.HardwareConstants.ChannelTypes ct)
 {
     return(channelCollections[ct]);
 }
 public HardwareChannel(string serverName, string deviceName, string channelName, string channelDescription, HardwareChannel.HardwareConstants.ChannelTypes ct, DataStructures.Gpib.Address gpibAddress, HardwareChannel.HardwareConstants.GPIBDeviceType gpibDeviceType)
     : this(serverName, deviceName, channelName, channelDescription, ct)
 {
     if (this.ChannelType != HardwareConstants.ChannelTypes.gpib)
     {
         throw new Exception("Do not call gpib channel constructor for a non gpib device.");
     }
     this.gpibAddress    = gpibAddress;
     this.gpibDeviceType = gpibDeviceType;
 }
 public HardwareChannel(string serverName, string deviceName, string channelName, HardwareChannel.HardwareConstants.ChannelTypes ct)
     : this(serverName, deviceName, channelName, "", ct)
 {
 }