📄 mod_rssimdlg.cpp
字号:
PLCMemory[0].SetSize(this->m_numOutputs);
PLCMemory[1].SetSize(this->m_numInputs);
PLCMemory[2].SetSize(this->m_numAnalogs);
PLCMemory[3].SetSize(this->m_numHolding);
PLCMemory[4].SetSize(this->m_numExtended);
FillComboBox(IDC_COMBOAREA, PLCMemoryTypes, m_startUpRegisterArea);//m_listCtrlData.GetAreaDisplayed());
{
int count = ((CComboBox*)GetDlgItem(IDC_COMBOAREA))->GetCurSel();
if (-1 == count)
((CComboBox*)GetDlgItem(IDC_COMBOAREA))->SetCurSel(0);
}
break;
case PROTOCOL_SELABMASTER232:
case PROTOCOL_SELAB232:
{
int i, max = GetNumMemoryAreas();
for (i=0; i < max; i++)
PLCMemory[i].SetSize(255);
// init the memory
if (PROTOCOL_SELABMASTER232 == m_selectedProtocol)
{
for (i=0; i < max; i++)
{
PLCMemory.SetAt(i, 1, JOY_MINROOFPRESSURE);
PLCMemory.SetAt(i,2, JOY_MINROOFPRESSURE);
PLCMemory.SetAt(i,6, JOY_12VOLTS);
}
}
// fill a combo box with AB file #/names
LONG count;
CComboBox *pCombo = ((CComboBox*)GetDlgItem(IDC_COMBOAREA));
CString entry;
BOOL noSel = TRUE;
pCombo->ResetContent();
for (count = 0; count < max; count++)
{
entry.Format("File %d", count);
pCombo->AddString(entry);
pCombo->SetItemData(count, count);
if (count == m_listCtrlData.GetAreaDisplayed())
pCombo->SetCurSel(count);
}
count = pCombo->GetCurSel();
if (-1 == count)
pCombo->SetCurSel(0);
}
break;
}
//populate the LB as well
}
// ---------------------------------- SetupListViewControl ---------------------
// PURPOSE; Set up the list-view control headdings and col. widths
// NOTES;
// Data on the control comes in via a callback func
void CMOD_simDlg::SetupListViewControl(const DWORD cols)
{
m_isClone = IsDlgButtonChecked(IDC_CLONE);
m_listCtrlData.SetupColumns(LONG (cols+1), m_isClone);
} // SetupListViewControl
// ---------------------------- LoadApplicationSettings -----------------
void CMOD_simDlg::LoadApplicationSettings()
{
CString registryPath;
DRegKey key;
DWORD len = sizeof(m_portNameShort);
DWORD animationType;
////////////////////////////////////////////////////
// set default values
strcpy(m_portNameShort, "COM1");
m_baud = CBR_9600;
m_byteSize = 8;
m_parity = NOPARITY;
m_stopBits = ONESTOPBIT;
m_rts = RTS_CONTROL_ENABLE;
registryPath = APPREGISTRY_SETTINGSKEY;
// colors
m_mTickColorActive = RGB(0xFF, 0xFF, 0x00); // yellow
m_mTickColorInactive = RGB(0x80, 0x80, 0x80); // gray
m_mTickColorEnabled = RGB(0x00, 0x80, 0x00); // green
m_mTickColorDisabled = RGB(0xFF, 0x00, 0x00); // red
m_mTickColorText = RGB(0x00, 0x00, 0x00); // black
m_mTickDisColorText = RGB(0x00, 0x00, 0x00); // black
m_appSettingAdressHex = FALSE;
m_numInputs = 65535;
m_numOutputs = 65535;
m_numHolding = 65535;
m_numExtended= 65535;
m_numAnalogs = 65535;
m_PDUSize = 2048; // 4096 bytes max
m_numSeperate = 16;
m_seperateRegisters = FALSE;
m_selectedProtocol = PROTOCOL_SELMODETH; // default protocol
m_isClone = FALSE;
m_startUpRegisterArea = 3;
m_localPort = 502;
m_otherPort = 501;
m_numServers = 10;
m_linger = FALSE;
m_localId = 1;
//////////////////////////////////////////////////
// load the baud rate etc
key.Open(DRegKey::local_machine, registryPath);
key.QueryValue("Port", m_portNameShort, &len);
key.QueryValue("BaudRate", &m_baud);
key.QueryValue("ByteSize", &m_byteSize);
key.QueryValue("Parity", &m_parity);
key.QueryValue("StopBits", &m_stopBits);
key.QueryValue("RTS", &m_rts);
key.QueryValue("ResponseDelays", &m_responseDelay);
key.QueryValue("MOSCAD", &m_MOSCADchecks);
key.QueryValue("AutoLoad", &m_autoLoad);
key.QueryValue("DevicesOfflineAtStart", &m_startAsOff);
key.QueryValue("ModifyThenRespond", &m_modifyThenRespond);
key.QueryValue("DisableWrites", &m_disableWrites);
key.QueryValue("PLCMaster", &m_PLCMaster);
key.QueryValue("UseBCCs", &m_useBCC);
// JOY
key.QueryValue("ABMasterSource", &m_ABMasterSourceStation);
key.QueryValue("ABMasterDest", &m_ABMasterDestStation);
key.QueryValue("ABMasterFiles", &m_ABMasterNumFiles);
key.QueryValue("ABMasterRun", &m_ABMasterRunMode);
key.QueryValue("ABMasterRead", &m_ABMasterReadVariables);
key.QueryValue("ABMasterWrite", &m_ABMasterWriteVariables);
key.QueryValue("ABmasterIDLETime", &m_ABmasterIDLETime);
key.QueryValue("ABtimeoutValue", &m_ABtimeoutValue);
key.QueryValue("TickColorActive", &m_mTickColorActive);
key.QueryValue("TickColorInactive", &m_mTickColorInactive);
key.QueryValue("TickColorEnabled", &m_mTickColorEnabled);
key.QueryValue("TickColorDisabled", &m_mTickColorDisabled);
key.QueryValue("TickColorText", &m_mTickColorText);
key.QueryValue("TickDisabledColorText", &m_mTickDisColorText);
key.QueryValue("AddressHex", &m_appSettingAdressHex);
key.QueryValue("AnimationON", &m_animationPeriod);
key.QueryValue("RegisterSel", &m_startUpRegisterArea);
key.QueryValue("InputRegisters", &m_numInputs );
key.QueryValue("OutputRegisters", &m_numOutputs );
key.QueryValue("HoldingRegisters", &m_numHolding );
key.QueryValue("ExtendedRegisters", &m_numExtended);
key.QueryValue("AnalogRegisters", &m_numAnalogs );
key.QueryValue("PDUSize", &m_PDUSize);
key.QueryValue("Protocol", &m_selectedProtocol);
key.QueryValue("EthernetServers", &m_numServers);
key.QueryValue("LingerClose", &m_linger);
key.QueryValue("EthernetID", &m_localId);
key.QueryValue("EthernetPort", &m_localPort);
key.QueryValue("EthernetPort2", &m_otherPort);
key.QueryValue("AnimationIncrement", &m_animationIncValue);
key.QueryValue("RegistrationUserName", m_registeredUser);
key.QueryValue("RegistrationKey", m_registeredKey);
key.SetValue("RegistrationUserName", m_registeredUser);
key.SetValue("RegistrationKey", m_registeredKey);
key.QueryValue("RegistersPerStation", &m_numSeperate);
key.QueryValue("RegistersSeperated", &m_seperateRegisters);
m_registeredOK = CheckRegistrationKey(m_registeredUser, m_registeredKey);
if (!m_registeredOK)
CSplashWnd::SetWaitCount(5); // splash screen stays up longer if U not registered
else
CSplashWnd::GetSWnd()->InvalidateRect(NULL); // Force a splash re-paint with registration info
m_animationON = FALSE;
m_plantAnimation = FALSE;
m_animationBYTE = FALSE;
m_animationWORD = FALSE;
key.QueryValue("AnimationType", &animationType);
switch (animationType)
{
case 1: m_animationBYTE = TRUE;
break;
case 2: m_animationWORD = TRUE;
break;
case 3: m_plantAnimation = TRUE;
break;
default:
break;
}
if (m_animationBYTE || m_animationWORD || m_plantAnimation)
m_animationON = TRUE;
key.QueryValue("AnimationScript", m_animationScriptFile);
// m_checkParity = (NOPARITY==m_parity?FALSE;TRUE);
} // LoadApplicationSettings
// ---------------------------- SaveApplicationSettings -----------------
// save program settings to HKEY_LOCAL_MACHINE registry
void CMOD_simDlg::SaveApplicationSettings()
{
CString registryPath;
DRegKey key;
DWORD animationType;
m_appSettingAdressHex = m_listCtrlData.IsAddressFormatHex();
// Save the baud rate etc
registryPath = APPREGISTRY_SETTINGSKEY;
key.Open(DRegKey::local_machine, registryPath);
key.SetValue("Port", m_portNameShort, strlen(m_portNameShort));
key.SetValue("BaudRate", m_baud);
key.SetValue("ByteSize", m_byteSize);
key.SetValue("Parity", m_parity);
key.SetValue("StopBits", m_stopBits);
key.SetValue("RTS", m_rts);
key.SetValue("ResponseDelays", m_responseDelay);
key.SetValue("MOSCAD", m_MOSCADchecks);
key.SetValue("AutoLoad", m_autoLoad);
key.SetValue("DevicesOfflineAtStart", m_startAsOff);
key.SetValue("ModifyThenRespond", m_modifyThenRespond);
key.SetValue("DisableWrites", m_disableWrites);
key.SetValue("PLCMaster", m_PLCMaster);
key.SetValue("UseBCCs", m_useBCC);
key.SetValue("ABMasterSource",m_ABMasterSourceStation);
key.SetValue("ABMasterDest", m_ABMasterDestStation);
key.SetValue("ABMasterFiles", m_ABMasterNumFiles);
key.SetValue("ABMasterRun", m_ABMasterRunMode);
key.SetValue("ABMasterRead", m_ABMasterReadVariables);
key.SetValue("ABMasterWrite", m_ABMasterWriteVariables);
key.SetValue("ABmasterIDLETime", m_ABmasterIDLETime);
key.SetValue("ABtimeoutValue", m_ABtimeoutValue);
key.SetValue("TickColorActive", m_mTickColorActive);
key.SetValue("TickColorInactive", m_mTickColorInactive);
key.SetValue("TickColorEnabled", m_mTickColorEnabled);
key.SetValue("TickColorDisabled", m_mTickColorDisabled);
key.SetValue("TickColorText", m_mTickColorText);
key.SetValue("TickDisabledColorText", m_mTickDisColorText);
key.SetValue("AddressHex", m_appSettingAdressHex);
key.SetValue("AnimationON", m_animationPeriod);
key.SetValue("RegisterSel", m_startUpRegisterArea);
key.SetValue("InputRegisters", m_numInputs);
key.SetValue("OutputRegisters", m_numOutputs);
key.SetValue("HoldingRegisters", m_numHolding);
key.SetValue("ExtendedRegisters", m_numExtended);
key.SetValue("AnalogRegisters", m_numAnalogs);
key.SetValue("PDUSize", m_PDUSize);
key.SetValue("Protocol", m_selectedProtocol);
key.SetValue("EthernetServers", m_numServers);
key.SetValue("LingerClose", m_linger);
key.SetValue("EthernetID", m_localId);
key.SetValue("Ethe
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -