-
Notifications
You must be signed in to change notification settings - Fork 0
/
ConfigUnit.cpp
71 lines (65 loc) · 2.52 KB
/
ConfigUnit.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
//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
#include <Registry.hpp>
#include "ConfigUnit.h"
#include "Terminal.h"
#include "TerminalConfig.h"
#include "TerminalBox.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TConfigForm *ConfigForm;
//---------------------------------------------------------------------------
__fastcall TConfigForm::TConfigForm(TComponent* Owner): TForm(Owner){}
//---------------------------------------------------------------------------
void TConfigForm::SetTerminal(CTerminal *term){
terminal =term;
_di_IXMLTerminalType terminalXML =terminal->xmlConfig;
//设置参数
EditNo->Text =terminalXML->TerminalID;
GetComPortList(ComboBoxCom->Items);
ComboBoxCom->Text =terminalXML->BoxComParam;
EditUKey->Text =terminalXML->LotteryPos->UKeyPassword;
EditAccount->Text =terminalXML->LotteryPos->SalesAccount;
EditPasswd->Text =terminalXML->LotteryPos->SalesPassword;
//玩法
ValueListEditor->Strings->Clear();
for (int i = 0; i < terminalXML->LotteryPos->Count; i++){
_di_IXMLGameType game =terminalXML->LotteryPos->Get_Game(i);
ValueListEditor->InsertRow(game->GameName, game->EnterKey, true);
}
}
//---------------------------------------------------------------------------
void __fastcall TConfigForm::GetComPortList(TStrings *listCom){
//刷新并获取当前可用串口列表
listCom->Clear();
TRegistry *reg = new TRegistry();
TStringList *lst = new TStringList();
try{
reg->RootKey = HKEY_LOCAL_MACHINE;
reg->OpenKey("HARDWARE\\DEVICEMAP\\SERIALCOMM", true);
reg->GetValueNames(lst);
for (int i = 0; i < lst->Count; i++)
listCom->Add(reg->ReadString(lst->Strings[i]));
}__finally{
delete reg;
delete lst;
}
}
//---------------------------------------------------------------------------
void __fastcall TConfigForm::ButtonUpdateFirmwareClick(TObject *Sender){
//固件升级
if (terminal ==NULL || !terminal->box->connected){
ShowMessage("BOX尚未连接或状态不正常,不能更新固件。");
return;
}
if (OpenDialogFirmware->Execute()){
BYTE firmwareData[65536] = {0}; //1M字节的固件应该够用了
int binFile = FileOpen(OpenDialogFirmware->FileName, fmOpenRead);
int nRead =FileRead(binFile, firmwareData, sizeof(firmwareData));
FileClose(binFile);
terminal->box->SendFirmware(firmwareData, nRead);
}
}
//---------------------------------------------------------------------------