Beispiel #1
0
        public MSG_ADD_ACCESSSPEC_RESPONSE ADD_ACCESSSPEC(MSG_ADD_ACCESSSPEC msg, out MSG_ERROR_MESSAGE msg_err, int time_out)
        {
            msg_err = null;
            //Add your code here
            _event_ADD_ACCESSSPEC_RESPONSE = new ClientManualResetEvent(false);
            _event_ADD_ACCESSSPEC_RESPONSE.msg_id = msg.MSG_ID;
            _event_ERROR_MESSAGE = new ClientManualResetEvent(false);

            WaitHandle[] waitHandles = new WaitHandle[] { _event_ADD_ACCESSSPEC_RESPONSE.evt, _event_ERROR_MESSAGE.evt };

            bool[] bit_array = msg.ToBitArray();
            byte[] data = Util.ConvertBitArrayToByteArray(bit_array);

            cI.Send(data);

            int wait_result = WaitHandle.WaitAny(waitHandles, time_out, false);

            int cursor = 0;
            int length;
            BitArray bArr;

            try
            {
                switch (wait_result)
                {
                    case 0:
                        bArr = Util.ConvertByteArrayToBitArray(_event_ADD_ACCESSSPEC_RESPONSE.data);
                        length = bArr.Count;
                        MSG_ADD_ACCESSSPEC_RESPONSE msg_rsp = MSG_ADD_ACCESSSPEC_RESPONSE.FromBitArray(ref bArr, ref cursor, length);
                        if (msg_rsp.MSG_ID != msg.MSG_ID) return null;
                        else
                            return msg_rsp;
                    case 1:
                        bArr = Util.ConvertByteArrayToBitArray(_event_ERROR_MESSAGE.data);
                        length = bArr.Count;
                        msg_err = MSG_ERROR_MESSAGE.FromBitArray(ref bArr, ref cursor, length);
                        return null;
                    default:
                        return null;
                }
            }
            catch
            {
                return null;
            }
        }
Beispiel #2
0
        public void ENABLE_EVENTS_AND_REPORTS(MSG_ENABLE_EVENTS_AND_REPORTS msg, out MSG_ERROR_MESSAGE msg_err, int time_out)
        {
            msg_err = null;
            _event_ERROR_MESSAGE = new ClientManualResetEvent(false);

            bool[] bit_array = msg.ToBitArray();
            byte[] data = Util.ConvertBitArrayToByteArray(bit_array);

            cI.Send(data);

            bool wait_result = _event_ERROR_MESSAGE.evt.WaitOne(time_out, false);
            if (wait_result)
            {
                BitArray bArr = Util.ConvertByteArrayToBitArray(_event_ENABLE_EVENTS_AND_REPORTS.data);
                int cursor = 0;
                int length = bArr.Count;
                msg_err = MSG_ERROR_MESSAGE.FromBitArray(ref bArr, ref cursor, length);
                return;
            }
        }