public bool DPgetDpInfoSync(int timeout, DpInfoListener listener) { lock (this) { _gui.UpdateTraceInfo("Send get info \r\n"); Console.Write("Send get info \r\n"); byte[] data = new byte[API_MSG_DP_BASIC_MASSEGE_LENGTH]; data[0] = API_MSG_PREAMBLE; data[1] = (byte)data.Count(); data[2] = API_MSG_DP_GET_DP_INFO; //opcode data[data.Count() - 1] = CheckCum(data, data.Count()); currDpInfoListener = listener; SerialPortInstanse.Send(data, data.Count()); bool res = Monitor.Wait(this, timeout); if (!res) { listener(null); currDpInfoListener = null; } _gui.UpdateTraceInfo("Dp get info " + res + "\r\n"); return(res); } }
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; } }
public bool DpWritePressurePointToDeviceSync(float tempUnderTest, byte TempN, float extPressure, byte PreesureN, int waitTime, DpInfoListener listener) { lock (this) { currDpInfoListener = listener; _gui.UpdateTraceInfo("Send calibration point to device " + tempUnderTest + " " + TempN + " " + extPressure + " " + PreesureN + "\r\n"); DpWritePressurePointToDevice(tempUnderTest, TempN, extPressure, PreesureN); bool res = Monitor.Wait(this, waitTime); if (!res) { listener(null); currDpInfoListener = null; } return(res); } }