Ejemplo n.º 1
0
        public void onDpMessage(DpMessage msg)
        {
            switch (msg.type)
            {
            case DpMessageType.DP_MSG_DPINFO:
                lock (this)
                {
                    if (currDpInfoListener != null)
                    {
                        currDpInfoListener((DpInfo)msg);
                        currentTempOnDp = ((DpInfo)msg).CurrentTemp;
                        Monitor.Pulse(this);
                        currDpInfoListener = null;
                    }
                }

                break;

            case DpMessageType.DP_MSG_LICENSE_ACK:
                lock (this)
                {
                    if (licenseAckListener != null)
                    {
                        licenseAckListener((LicenseAck)msg);
                        Monitor.Pulse(this);
                        licenseAckListener = null;
                    }
                }
                break;

            default:
                break;
            }
        }
Ejemplo n.º 2
0
        public bool SendDpLicense(byte[] license, int timeout, LicenseAckListener listener)
        {
            lock (this)
            {
                byte[] data = new byte[API_MSG_DP_BASIC_MASSEGE_LENGTH + license.Length];
                data[0] = API_MSG_PREAMBLE;
                data[1] = (byte)data.Count();
                data[2] = API_MSG_DP_SEND_LICENSE;  //opcode


                Array.Copy(license, 0, data, API_MSG_DP_BASIC_MASSEGE_LENGTH - 1, license.Count());

                licenseAckListener = listener;

                data[data.Count() - 1] = CheckCum(data, data.Count());
                SerialPortInstanse.Send(data, data.Count());

                bool res = Monitor.Wait(this, timeout);

                if (!res)
                {
                    listener(null);
                    licenseAckListener = null;
                }

                _gui.UpdateTraceInfo("Dp write calib. point " + res + "\r\n");
                return(res);
            }
        }