Ejemplo n.º 1
0
        /// <summary>
        /// Here we read out the datapoints and add the description to the dataGridView
        /// </summary>
        public void readDatapointDescriptions(Connector connector)
        {
            try
            {
                // change mouse cursor to busy
                this.Cursor = Cursors.WaitCursor;

                // get datapoint description
                BaosDatapointDescriptions baosDatapointDescriptions = new BaosDatapointDescriptions(connector);
                baosDatapointDescriptions.readFromDevice();
                List <BaosDatapointDescription> descriptions = baosDatapointDescriptions.getDescriptions();

                foreach (BaosDatapointDescription desc in descriptions)
                {
                    BaosDatapoint datapoint = new BaosDatapoint(connector, desc.getId());

                    String size = desc.isBitType() ? string.Format("{0} Bits", desc.getValueTypeSizeBits()) :
                                  string.Format("{0} Bytes", desc.getValueTypeSizeBytes());
                    dataGridView.Rows.Add(datapoint.getId(), datapoint.getDescription(), size);
                }
            }
            catch (kdrive.KdriveException exception)
            {
                MessageBox.Show(exception.Message, "Exception",
                                MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
            finally
            {
                // reset mouse cursor
                this.Cursor = Cursors.Default;
            }
        }
Ejemplo n.º 2
0
        static void readDatapointDescriptions(Connector connector)
        {
            try
            {
                BaosDatapointDescriptions baosDatapointDescriptions = new BaosDatapointDescriptions(connector);
                baosDatapointDescriptions.readFromDevice();
                List <BaosDatapointDescription> descriptions = baosDatapointDescriptions.getDescriptions();

                Console.WriteLine("{0} items found", descriptions.Count);

                foreach (BaosDatapointDescription desc in descriptions)
                {
                    String size = desc.isBitType() ? string.Format("{0} Bits", desc.getValueTypeSizeBits()) :
                                  string.Format("{0} Bytes", desc.getValueTypeSizeBytes());

                    Console.WriteLine("");
                    Console.WriteLine("Datapoint id {0}", desc.getId());
                    Console.WriteLine("Datapoint type: {0}, Size: {1}", desc.getDatapointType(), size);
                }
            }
            catch (kdrive.KdriveException exception)
            {
                Console.WriteLine(exception.Message);
            }
        }