15 #if( FMI_SUPPORT_A610 ) 23 #if( FMI_SUPPORT_A615 ) 38 ON_BN_CLICKED( IDOK, OnBnClickedOk )
39 ON_EN_SETFOCUS( IDC_DRIVERS_EDIT_ID, OnEnSetfocusLoginEdit )
40 ON_EN_KILLFOCUS( IDC_DRIVERS_EDIT_ID, OnEnKillfocusLoginEdit )
41 ON_EN_SETFOCUS( IDC_DRIVERS_EDIT_PASSWORD, OnEnSetfocusLoginEdit )
42 ON_EN_KILLFOCUS( IDC_DRIVERS_EDIT_PASSWORD, OnEnKillfocusLoginEdit )
43 ON_EN_SETFOCUS( IDC_DRIVERS_EDIT_FIRST_NAME, OnEnSetfocusLoginEdit )
44 ON_EN_KILLFOCUS( IDC_DRIVERS_EDIT_FIRST_NAME, OnEnKillfocusLoginEdit )
45 ON_EN_SETFOCUS( IDC_DRIVERS_EDIT_LAST_NAME, OnEnSetfocusLoginEdit )
46 ON_EN_KILLFOCUS( IDC_DRIVERS_EDIT_LAST_NAME, OnEnKillfocusLoginEdit )
47 ON_EN_SETFOCUS( IDC_DRIVERS_EDIT_CARRIER_NAME, OnEnSetfocusLoginEdit )
48 ON_EN_KILLFOCUS( IDC_DRIVERS_EDIT_CARRIER_NAME, OnEnKillfocusLoginEdit )
49 ON_EN_SETFOCUS( IDC_DRIVERS_EDIT_CARRIER_ID, OnEnSetfocusLoginEdit )
50 ON_EN_KILLFOCUS( IDC_DRIVERS_EDIT_CARRIER_ID, OnEnKillfocusLoginEdit )
51 ON_CBN_SETFOCUS( IDC_DRIVERS_LONG_TERM_RULESETS, OnEnSetfocusLoginEdit )
52 ON_CBN_KILLFOCUS( IDC_DRIVERS_LONG_TERM_RULESETS, OnEnKillfocusLoginEdit )
53 ON_CBN_SETFOCUS( IDC_DRIVERS_LOAD_TYPE_RULESETS, OnEnSetfocusLoginEdit )
54 ON_CBN_KILLFOCUS( IDC_DRIVERS_LOAD_TYPE_RULESETS, OnEnKillfocusLoginEdit )
55 ON_CBN_SETFOCUS( IDC_DRIVERS_TIME_ZONES, OnEnSetfocusLoginEdit )
56 ON_CBN_KILLFOCUS( IDC_DRIVERS_TIME_ZONES, OnEnKillfocusLoginEdit )
58 ON_LBN_SETFOCUS( IDC_DRIVERS_LST_DRIVERS, OnLbnSetfocusDriverList )
59 ON_LBN_KILLFOCUS( IDC_DRIVERS_LST_DRIVERS, OnLbnKillfocusDriverList )
67 CAobrdDriversDlg::CAobrdDriversDlg
74 , mSelectedIndex( -1 )
76 , mDriverPassword( _T("") )
77 , mDriverFirstName( _T("") )
78 , mDriverLastName( _T("") )
79 , mDriverCarrierName( _T("") )
80 , mDriverCarrierID( _T("") )
81 , mDriverLongTermRuleset( -1 )
82 #if( FMI_SUPPORT_A615 ) 83 , mDriverLoadTypeRuleset( -1 )
85 , mDriverTimeZone( -1 )
102 CDataExchange * aDataExchange
105 CDialog::DoDataExchange( aDataExchange );
106 DDX_Control( aDataExchange, IDC_DRIVERS_LST_DRIVERS, mListBox );
107 DDX_Text( aDataExchange, IDC_DRIVERS_EDIT_ID, mDriverId );
108 DDX_Text( aDataExchange, IDC_DRIVERS_EDIT_PASSWORD, mDriverPassword );
109 DDX_Text( aDataExchange, IDC_DRIVERS_EDIT_FIRST_NAME, mDriverFirstName );
110 DDX_Text( aDataExchange, IDC_DRIVERS_EDIT_LAST_NAME, mDriverLastName );
111 DDX_Text( aDataExchange, IDC_DRIVERS_EDIT_CARRIER_NAME, mDriverCarrierName );
112 DDX_Text( aDataExchange, IDC_DRIVERS_EDIT_CARRIER_ID, mDriverCarrierID );
113 DDX_CBIndex( aDataExchange, IDC_DRIVERS_LONG_TERM_RULESETS, mDriverLongTermRuleset );
114 #if( FMI_SUPPORT_A615 ) 115 DDX_CBIndex( aDataExchange, IDC_DRIVERS_LOAD_TYPE_RULESETS, mDriverLoadTypeRuleset );
117 DDX_CBIndex( aDataExchange, IDC_DRIVERS_TIME_ZONES, mDriverTimeZone );
129 CDialog::OnInitDialog();
133 GetDlgItem( IDC_DRIVERS_SEND_UPDATE )->EnableWindow(
FALSE );
135 GetDlgItem( IDC_DRIVERS_SHIPMENTS )->EnableWindow(
FALSE );
137 SetWindowPos( NULL, 700, 350, 0, 0, SWP_NOSIZE | SWP_NOZORDER );
139 CComboBox * longTermRulesets = (CComboBox*) GetDlgItem( IDC_DRIVERS_LONG_TERM_RULESETS );
140 longTermRulesets->ResetContent();
141 longTermRulesets->AddString(_T(
"60 hour/7 day"));
142 longTermRulesets->AddString(_T(
"70 hour/8 day"));
144 #if( FMI_SUPPORT_A615 ) 145 CComboBox * loadTypeRulesets = (CComboBox*) GetDlgItem( IDC_DRIVERS_LOAD_TYPE_RULESETS );
146 loadTypeRulesets->ResetContent();
147 loadTypeRulesets->AddString(_T(
"Property"));
148 loadTypeRulesets->AddString(_T(
"Passenger"));
152 GetDlgItem( IDC_DRIVERS_LOAD_TYPE_RULESETS )->ShowWindow( SW_HIDE );
157 CComboBox * timeZones = (CComboBox*) GetDlgItem( IDC_DRIVERS_TIME_ZONES );
158 timeZones->ResetContent();
159 timeZones->AddString(_T(
"Eastern"));
160 timeZones->AddString(_T(
"Central"));
161 timeZones->AddString(_T(
"Mountain"));
162 timeZones->AddString(_T(
"Pacific"));
163 timeZones->AddString(_T(
"Alaska"));
164 timeZones->AddString(_T(
"Hawaii"));
166 ((CEdit*)GetDlgItem(IDC_DRIVERS_EDIT_ID))->LimitText(39);
167 ((CEdit*)GetDlgItem(IDC_DRIVERS_EDIT_PASSWORD))->LimitText(19);
168 ((CEdit*)GetDlgItem(IDC_DRIVERS_EDIT_FIRST_NAME))->LimitText(34);
169 ((CEdit*)GetDlgItem(IDC_DRIVERS_EDIT_LAST_NAME))->LimitText(34);
170 ((CEdit*)GetDlgItem(IDC_DRIVERS_EDIT_CARRIER_NAME))->LimitText(119);
171 ((CEdit*)GetDlgItem(IDC_DRIVERS_EDIT_CARRIER_ID))->LimitText(7);
182 mDriverPassword = _T(
"");
183 mDriverFirstName = _T(
"");
184 mDriverLastName = _T(
"");
185 mDriverCarrierName = _T(
"");
186 mDriverCarrierID = _T(
"");
187 mDriverLongTermRuleset = -1;
188 #if( FMI_SUPPORT_A615 ) 189 mDriverLoadTypeRuleset = -1;
191 mDriverTimeZone = -1;
204 mSelectedIndex = mListBox.GetCurSel();
205 int topIndex = mListBox.GetTopIndex();
208 mListBox.ResetContent();
210 for( ; iter != mCom.mAOBRDDrivers.
end(); ++iter )
212 if( iter->second.isValid() )
214 listItem.Format( _T(
"%s"), iter->second.getDriverId() );
215 mListBox.AddString( listItem );
223 mListBox.SetCurSel( mSelectedIndex );
224 mListBox.SetTopIndex( topIndex );
234 CListBox * driverListBox = ( CListBox* ) GetDlgItem( IDC_DRIVERS_LST_DRIVERS );
235 mSelectedIndex = driverListBox->GetCurSel();
237 if( mSelectedIndex >= 0 && mSelectedIndex < driverListBox->GetCount() )
239 const AobrdDriverItem & driver = mCom.mAOBRDDrivers.get( mCom.mAOBRDDrivers.getKeyAt( mSelectedIndex ) );
240 mCom.sendAOBRDDriverProfile( driver );
244 #if( FMI_SUPPORT_A615 ) 252 CListBox * driverListBox = ( CListBox* ) GetDlgItem( IDC_DRIVERS_LST_DRIVERS );
253 mSelectedIndex = driverListBox->GetCurSel();
255 if( mSelectedIndex >= 0 && mSelectedIndex < driverListBox->GetCount() )
257 const AobrdDriverItem & driver = mCom.mAOBRDDrivers.get( mCom.mAOBRDDrivers.getKeyAt( mSelectedIndex ) );
258 mCom.sendAOBRDDriverLogoff( driver );
271 if( mSelectedIndex >= 0 )
273 mCom.mAOBRDDrivers.remove( mCom.mAOBRDDrivers.getKeyAt( mSelectedIndex ) );
277 if( mSelectedIndex < 0 )
279 GetDlgItem( IDC_DRIVERS_SEND_UPDATE )->EnableWindow(
FALSE );
298 char driverPassword[20];
301 char carrierName[50];
304 WideCharToMultiByte( CP_UTF8, 0, mDriverId, -1, driverId,
sizeof( driverId ), NULL, NULL );
305 WideCharToMultiByte( CP_UTF8, 0, mDriverPassword, -1, driverPassword,
sizeof( driverPassword ), NULL, NULL );
306 WideCharToMultiByte( CP_UTF8, 0, mDriverFirstName, -1, firstName,
sizeof( firstName ), NULL, NULL );
307 WideCharToMultiByte( CP_UTF8, 0, mDriverLastName, -1, lastName,
sizeof( lastName ), NULL, NULL );
308 WideCharToMultiByte( CP_UTF8, 0, mDriverCarrierName, -1, carrierName,
sizeof( carrierName ), NULL, NULL );
309 WideCharToMultiByte( CP_UTF8, 0, mDriverCarrierID, -1, carrierID,
sizeof( carrierID ), NULL, NULL );
313 ( ( 0 != driver.
getFirstName().Compare(mDriverFirstName) ) ||
314 ( 0 != driver.
getLastName().Compare(mDriverLastName) ) ) )
316 MessageBox( _T(
"Driver First and Last name should not be changed since the device uses that information as a key." ), _T(
"Error" ), MB_ICONERROR );
326 #if( FMI_SUPPORT_A615 ) 331 mCom.mAOBRDDrivers.put( driver );
341 AobrdDriverItem& driver = mCom.mAOBRDDrivers.get( mCom.mAOBRDDrivers.getKeyAt( mSelectedIndex ) );
344 mCom.mAOBRDDrivers.put( driver );
356 if( (
"" != mDriverId ) && (
"" != mDriverPassword ) &&
357 (
"" != mDriverFirstName ) && (
"" != mDriverLastName ) &&
358 (
"" != mDriverCarrierName ) && (
"" != mDriverCarrierID ) &&
359 ( -1 != mDriverLongTermRuleset ) &&
361 ( -1 != mDriverLoadTypeRuleset ) &&
363 ( -1 != mDriverTimeZone ) )
365 GetDlgItem( IDC_DRIVERS_BTN_SET )->EnableWindow(
TRUE );
369 GetDlgItem( IDC_DRIVERS_BTN_SET )->EnableWindow(
FALSE );
382 CListBox * driverListBox = (CListBox*) GetDlgItem( IDC_DRIVERS_LST_DRIVERS );
383 mSelectedIndex = driverListBox->GetCurSel();
385 if( mSelectedIndex >= 0 && mSelectedIndex < driverListBox->GetCount() )
387 const AobrdDriverItem& item = mCom.mAOBRDDrivers.get( mCom.mAOBRDDrivers.getKeyAt( mSelectedIndex ) );
396 #if( FMI_SUPPORT_A615 ) 403 GetDlgItem( IDC_DRIVERS_SEND_UPDATE )->EnableWindow(
TRUE );
406 GetDlgItem( IDC_DRIVERS_SHIPMENTS )->EnableWindow(
TRUE );
408 OnChangeDriverData();
412 GetDlgItem( IDC_DRIVERS_SEND_UPDATE )->EnableWindow(
FALSE );
415 GetDlgItem( IDC_DRIVERS_SHIPMENTS )->EnableWindow(
FALSE );
418 driverListBox->SetCurSel( mSelectedIndex );
446 CDialog::PostNcDestroy();
457 SendMessage( DM_SETDEFID, IDC_DRIVERS_BTN_SET );
468 SendMessage( DM_SETDEFID, IDOK );
478 SendMessage( DM_SETDEFID, IDC_DRIVERS_SEND_UPDATE );
488 SendMessage( DM_SETDEFID, IDOK );
BOOL isValid() const
Check whether this item is valid.
#define IDC_DRIVERS_TIME_ZONES
#define IDC_DRIVERS_EDIT_LAST_NAME
afx_msg void OnCancel()
Handler for the Cancel action.
CString getPassword() const
Get item's password.
static BOOL ShowShipments(CWnd *aParent, AobrdDriverItem *driver)
Main entry point for showing the shipments editor.
#define IDC_DRIVERS_EDIT_ID
#define IDC_DRIVERS_EDIT_PASSWORD
afx_msg void OnBnClickedShipments()
const_iterator begin()
Iterator positioned at the first element in the map.
void updateListBox()
Update the drivers list box from the drivers map owned by FmiApplicationLayer.
void setFirstName(const std::string &aFirstName)
Set the first name of this driver.
void setLoadTypeRuleset(const uint16 aRuleset)
Set the load type ruleset of this driver.
afx_msg void OnEnKillfocusLoginEdit()
Handles the kill focus event for the driver ID and password edit boxes.
uint16 getTimeZone() const
Get item's time zone.
virtual ~CAobrdDriversDlg()
Destructor.
void setCarrierID(const std::string &aCarrierID)
Set the carrier ID of this driver.
CString getDriverId() const
Get the driver ID as a CString.
CString getFirstName() const
Get item's first name.
void PostNcDestroy()
Called by MFC after the window has been destroyed; performs final termination activities.
Dialog allowing the user to manage AOBRD drivers.
#define IDC_DRIVERS_BTN_DELETE
const_iterator end()
Iterator positioned after the last element in the map.
afx_msg void OnBnClickedOk()
Button handler for the OK button.
uint16 getLoadTypeRuleset() const
Get item's load type ruleset.
afx_msg void OnBnClickedSet()
Button handler for the Set button.
void setTimeZone(const uint16 aTimeZone)
Set the time zone of this driver.
#define IDC_DRIVERS_EDIT_FIRST_NAME
afx_msg void OnBnClickedDelete()
Button handler for the Delete button.
afx_msg void OnChangeDriverData()
Edit/Change handler for the driver-specific data controls.
#define IDC_DRIVERS_LOAD_TYPE_RULESETS
CString getCarrierName() const
Get item's carrier name.
#define IDC_DRIVERS_SEND_LOGOFF
#define FMI_SUPPORT_A615
If true, app was built with support for A615 protocols.
#define IDC_DRIVERS_EDIT_CARRIER_ID
uint16 getLongTermRuleset() const
Get item's long term ruleset.
BOOL OnInitDialog()
This function is called when the window is created.
#define IDC_DRIVERS_EDIT_CARRIER_NAME
Serial communication controller for Garmin and FMI packets.
afx_msg void OnEnSetfocusLoginEdit()
Handles the set focus event for the driver ID and password edit boxes.
afx_msg void OnBnClickedSendUpdate()
Button handler for the Send Update button.
void setLongTermRuleset(const uint16 aRuleset)
Set the long term ruleset of this driver.
CString getLastName() const
Get item's last name.
afx_msg void OnLbnSetfocusDriverList()
Handles the set focus event for the driver list.
unsigned short int uint16
16-bit unsigned integer
#define IDC_DRIVERS_BTN_SET
afx_msg void OnLbnSelchangeDriverList()
Selection Changed handler for the Driver List box.
Data structure to holds an AOBRD driver info. Used by the FmiApplicationLayer to validate logins when...
#define IDC_DRIVERS_LBL_LOAD_TYPE_RULESET
virtual void DoDataExchange(CDataExchange *pDX)
Perform dialog data exchange and validation.
Map whose contents are also saved to a file.
afx_msg void OnBnClickedSendLogoff()
Button handler for the Send Logoff button.
#define IDC_DRIVERS_SEND_UPDATE
afx_msg void OnLbnKillfocusDriverList()
Handles the kill focus event for the driver list.
void setCarrierName(const std::string &aCarrierName)
Set the carrier name of this driver.
void setPassword(const std::string &aPassword)
Set the password of this driver.
void setLastName(const std::string &aLastName)
Set the last name of this driver.
#define IDC_DRIVERS_SHIPMENTS
#define IDC_DRIVERS_LST_DRIVERS
#define IDD_AOBRD_DRIVERS
#define IDC_DRIVERS_LONG_TERM_RULESETS
void clearData()
Clear values from the editable fields.
CString getCarrierID() const
Get item's carrier ID.