Exemple #1
0
        /// <summary>
        /// Process a chip object table message from the server.
        /// </summary>
        /// <param name="copyData">received message</param>
        /// <remarks>
        /// Returns the message contents to the client application by callback.
        /// </remarks>
        private void ProcessChipObjectTable(ref CopyData copyData)
        {
            // debug info
            OutputDebugString("processChipObjectTable");

            // message parsing variables
            byte[] buffer = null;
            buffer = this.GetBufferFromCopyData(ref copyData);
            int index = 0;

            // message format:
            // byte: flag: operation succeeded
            // then: multiple instances of the following:
            //       ushort: object type
            //       ushort: object start position
            //       ushort: object size
            //       ushort: number of object instances
            //       ushort: number of report IDs per instance

            // parse message
            byte operationSucceeded = this.GetByte(ref buffer, ref index);

            // parse operation success/failure from message payload
            bool operationSucceededFlag = false;
            if (operationSucceeded == 0)
            {
                operationSucceededFlag = true;
            }

            // calculate number of object table elements in the received data
            int bufferSize = buffer.Length;
            int numObjectTableElements = (bufferSize - 1) / ObjectTableElement.OBJECT_TABLE_ELEMENT_SIZE;

            // create object table
            ObjectTableElement[] objectTable = new ObjectTableElement[numObjectTableElements];

            // parse object table from message
            for (int i = 0; i < numObjectTableElements; i++)
            {
                // build object table element
                ObjectTableElement objectTableElement = new ObjectTableElement();
                objectTableElement.type = this.GetUshort(ref buffer, ref index);
                objectTableElement.start_position = this.GetUshort(ref buffer, ref index);
                objectTableElement.size = this.GetUshort(ref buffer, ref index);
                objectTableElement.instances = this.GetUshort(ref buffer, ref index);
                objectTableElement.num_report_ids_per_instance = this.GetUshort(ref buffer, ref index);

                // save object table element
                objectTable[i] = objectTableElement;
            }

            // trigger chip object table event
            this.NotifyChipObjectTable(operationSucceededFlag, ref objectTable);
        }
Exemple #2
0
        /// <summary>
        /// Handler for client receiving a chip object table message.
        /// </summary>
        /// <param name="operation_succeeded">flag: the operation succeeded</param>
        /// <param name="objectTable">the chip object table</param>
        private void Client_chipObjectTable(bool operation_succeeded, ref ObjectTableElement[] objectTable)
        {
            if (operation_succeeded == true)
            {
                this.textBoxInfo.AppendText("chip object table");
                this.textBoxInfo.AppendText(Environment.NewLine);

                // display object info for all objects
                for (int i = 0; i < objectTable.Length; i++)
                {
                    // display object number
                    this.textBoxInfo.AppendText("\tObject ");
                    this.textBoxInfo.AppendText(i.ToString());
                    this.textBoxInfo.AppendText(":");
                    this.textBoxInfo.AppendText(Environment.NewLine);

                    // display object info
                    this.textBoxInfo.AppendText("\t\tType ");
                    this.textBoxInfo.AppendText(objectTable[i].type.ToString());
                    this.textBoxInfo.AppendText(Environment.NewLine);
                    this.textBoxInfo.AppendText("\t\tStart position ");
                    this.textBoxInfo.AppendText(objectTable[i].start_position.ToString());
                    this.textBoxInfo.AppendText(Environment.NewLine);
                    this.textBoxInfo.AppendText("\t\tSize ");
                    this.textBoxInfo.AppendText(objectTable[i].size.ToString());
                    this.textBoxInfo.AppendText(Environment.NewLine);
                    this.textBoxInfo.AppendText("\t\tInstances ");
                    this.textBoxInfo.AppendText(objectTable[i].instances.ToString());
                    this.textBoxInfo.AppendText(Environment.NewLine);
                    this.textBoxInfo.AppendText("\t\tReport IDs per instance ");
                    this.textBoxInfo.AppendText(objectTable[i].num_report_ids_per_instance.ToString());
                    this.textBoxInfo.AppendText(Environment.NewLine);
                }
            }
            else
            {
                this.textBoxInfo.AppendText("chip get object table: failed");
                this.textBoxInfo.AppendText(Environment.NewLine);
            }
        }
Exemple #3
0
 /// <summary>
 /// handle chip object table events
 /// </summary>
 /// <param name="operationSucceeded">flag: the operation succeeded</param>
 /// <param name="objectTable">the chip object table</param>
 private void NotifyChipObjectTable(bool operationSucceeded, ref ObjectTableElement[] objectTable)
 {
     if (this.chipObjectTable != null)
     {
         this.chipObjectTable(operationSucceeded, ref objectTable);
     }
 }