public void Show(CommInterface com) { frmI2CS frm = new frmI2CS(); frm.Attach(com); frm.ShowDialog(); }
public void Attach(CommInterface com) { CommObj = com; }
public void Show(CommInterface com) { frmI2CIO6R2G5V1 frm = new frmI2CIO6R2G5V1(); frm.Attach(com); frm.ShowDialog(); }
public void Show(CommInterface com) { I2CADC frm = new I2CADC(); frm.Attach(com); frm.ShowDialog(); }
protected override void OnActionCompleted(CommunicationAction action, bool success) { #if LOG_PERFORMANCE CommInterface.DisplayStatusMessage("OnActionCompleted started at " + DateTime.Now.ToString("hh:mm:ss.fff"), StatusMessageType.DEV); #endif //ignore actions not started by this code if (action == mMyLastStartedAction) { if (action.CompletedWithoutCommunicationError) { if (success) { if ((mState == State.DefineVariables) && (mDataLogAction.ReadMode == ExtendedDataLoggingDefineReadVariables.Mode.Define)) { mState = State.ReadVariables; mExtendedDataLoggingSetup = true; mLastReadData = null; CommInterface.DisplayStatusMessage("ECU reports " + mDataLogAction.NumVariablesDefined + " variables were defined for data logging.", StatusMessageType.USER); } else if ((mState == State.ReadVariables) && (mDataLogAction.ReadMode == ExtendedDataLoggingDefineReadVariables.Mode.Read)) { mLastReadData = new List <byte[]>(mDataLogAction.ReadVariableData.Count()); foreach (var data in mDataLogAction.ReadVariableData) { mLastReadData.Add(data); } } } else { if (mState == State.DefineVariables) { if (mDataLogAction.DefineFailureResponseCode == (byte)KWP2000ResponseCode.ServiceNotSupported) { CommInterface.DisplayStatusMessage("Failed to define data logged variables with the ECU. Extended data logging protocol does not appear to have been setup.", StatusMessageType.USER); if (!mExtendedDataLoggingSetup) { CommInterface.DisplayStatusMessage("Setting up extended data logging protocol.", StatusMessageType.USER); ShouldRelocateMessageHandlingTable = true; success = true; } } else { CommInterface.DisplayStatusMessage("Failed to define data logged variables with the ECU.", StatusMessageType.USER); } } else if (mState == State.ReadVariables) { CommInterface.DisplayStatusMessage("Failed to read data logged variables from the ECU.", StatusMessageType.USER); } } } } mMyLastStartedAction = null; base.OnActionCompleted(action, success); #if LOG_PERFORMANCE CommInterface.DisplayStatusMessage("OnActionCompleted finished at " + DateTime.Now.ToString("hh:mm:ss.fff"), StatusMessageType.DEV); #endif }
protected override CommunicationAction NextAction() { var currentTime = DateTime.Now; #if LOG_PERFORMANCE CommInterface.DisplayStatusMessage("NextAction started at " + DateTime.Now.ToString("hh:mm:ss.fff"), StatusMessageType.DEV); #endif var nextAction = base.NextAction(); if (nextAction == null) { if (mState == State.ReadVariables) { { var minTimeBetweenReads = TimeSpan.FromMilliseconds(1000.0f / MaxReadsPerSecond); var nextReadTime = mLastReadStartTime + minTimeBetweenReads; var timeUntilNextRead = nextReadTime - currentTime; if (timeUntilNextRead.TotalMilliseconds > 0) { Thread.Sleep(timeUntilNextRead);//TODO: test performance if we don't sleep.... while (DateTime.Now < nextReadTime) { ; } } mLastReadStartTime = nextReadTime; } mDataLogAction.ReadMode = ExtendedDataLoggingDefineReadVariables.Mode.Read; mDataLogAction.MaxNumVariableReadsPerTick = MaxVariableReadsPerTick; mDataLogAction.MaxNumBytesPerRead = MaxNumBytesPerRead; nextAction = mDataLogAction; } else if (mState == State.DefineVariables) { var variables = new List <ExtendedDataLoggingDefineReadVariables.VariableDefinition>(mSynchronizedRegions.Count); foreach (var operationVariable in mSynchronizedRegions) { var varType = ExtendedDataLoggingDefineReadVariables.VariableDefinition.VariableType.Byte; if (operationVariable.Size > 1) { varType = ExtendedDataLoggingDefineReadVariables.VariableDefinition.VariableType.Word; } var actionVariable = new ExtendedDataLoggingDefineReadVariables.VariableDefinition(operationVariable.StartAddress, varType); variables.Add(actionVariable); } CommInterface.DisplayStatusMessage("Defining " + variables.Count + " variables with the ECU for data logging.", StatusMessageType.USER); mDataLogAction = new ExtendedDataLoggingDefineReadVariables(KWP2000CommInterface, ExtendedDataLoggingDefineReadVariables.Mode.Define, variables); nextAction = mDataLogAction; } mMyLastStartedAction = nextAction; } #if LOG_PERFORMANCE CommInterface.DisplayStatusMessage("NextAction finished at " + DateTime.Now.ToString("hh:mm:ss.fff"), StatusMessageType.DEV); #endif return(nextAction); }