-
Notifications
You must be signed in to change notification settings - Fork 6
/
AdvancedDlg.cpp
122 lines (96 loc) · 3.14 KB
/
AdvancedDlg.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
// AdvancedDlg.cpp : implementation file
//
// (c) 1996-99 Andy Whittaker, Chester, England.
#include "AdvancedDlg.h"
#include "DesIdleDlg.h" // Desired Idle Set Dialog Box
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CAdvancedDlg property page
IMPLEMENT_DYNCREATE(CAdvancedDlg, CTTPropertyPage)
CAdvancedDlg::CAdvancedDlg() : CTTPropertyPage(CAdvancedDlg::IDD) {
//{{AFX_DATA_INIT(CAdvancedDlg)
// NOTE: the ClassWizard will add member initialization here
//}}AFX_DATA_INIT
m_pSupervisor = NULL;
}
CAdvancedDlg::~CAdvancedDlg() {
}
void CAdvancedDlg::DoDataExchange(CDataExchange* pDX) {
CTTPropertyPage::DoDataExchange(pDX);
//{{AFX_DATA_MAP(CAdvancedDlg)
DDX_Control(pDX, IDC_SETDESIDLE, m_SetDesIdle);
DDX_Control(pDX, IDC_RESETIAC, m_ResetIAC);
DDX_Control(pDX, IDC_RESETBLM, m_ResetBLM);
DDX_Control(pDX, IDC_DESIDLE, m_DesiredIdle);
//}}AFX_DATA_MAP
//Updates the dialog.
if (m_pSupervisor != NULL) {
Refresh(m_pSupervisor->GetEcuData());
}
}
// Updates all of our controls
void CAdvancedDlg::Refresh(const CEcuData* const ecuData) {
CString buf;
DWORD dwCurrentMode = (m_pSupervisor != NULL)? m_pSupervisor->GetCurrentMode() : 0;
if (dwCurrentMode != 1 || !CEcuData::isValid(ecuData->m_iDesiredIdle)) {
buf.Format("N/A");
}
else {
buf.Format("%d", ecuData->m_iDesiredIdle);
}
m_DesiredIdle.SetWindowText(buf);
// Hide the buttons that don't work when not interactive
if (m_pSupervisor != NULL && m_pSupervisor->GetInteract()) {
m_SetDesIdle.EnableWindow(TRUE);
m_ResetIAC.EnableWindow(TRUE);
m_ResetBLM.EnableWindow(TRUE);
}
else {
m_SetDesIdle.EnableWindow(FALSE);
m_ResetIAC.EnableWindow(FALSE);
m_ResetBLM.EnableWindow(FALSE);
}
}
void CAdvancedDlg::RegisterSupervisor(CSupervisorInterface* const pSupervisor) {
m_pSupervisor = pSupervisor;
}
BEGIN_MESSAGE_MAP(CAdvancedDlg, CTTPropertyPage)
//{{AFX_MSG_MAP(CAdvancedDlg)
ON_BN_CLICKED(IDC_SETDESIDLE, OnSetdesidle)
ON_BN_CLICKED(IDC_RESETBLM, OnResetBLM)
ON_BN_CLICKED(IDC_RESETIAC, OnResetIAC)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CAdvancedDlg message handlers
BOOL CAdvancedDlg::OnInitDialog() {
CTTPropertyPage::OnInitDialog();
// Add dialog items that want ToolTip text
// m_toolTip.AddTool( GetDlgItem(IDC_EPROMID), IDC_EPROMID);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CAdvancedDlg::OnSetdesidle() {
CDesIdleDlg dlg;
dlg.m_Value = 850;;
if (CEcuData::isValid(m_pSupervisor->GetEcuData()->m_iDesiredIdle)) {
dlg.m_Value = m_pSupervisor->GetEcuData()->m_iDesiredIdle;
}
if (dlg.DoModal() == IDOK) {
// Sends the ECU command to set the desired idle
unsigned char uc;
uc = (unsigned char) ((dlg.m_Value / 25) * 2);
m_pSupervisor->ECUMode(ECU_SET_DES_IDLE, uc);
}
}
void CAdvancedDlg::OnResetBLM() {
m_pSupervisor->ECUMode(ECU_CLEAR_BLM);
}
void CAdvancedDlg::OnResetIAC() {
m_pSupervisor->ECUMode(ECU_RESET_IAC);
}