📄 progressmanamgedlg.cpp
字号:
bety.SetSize(15);
bety.SetAt(0,setupDownSendPrefix);
UCHAR matchinetemp = getDirectoryByMatchId(recentMatchine);
bety.SetAt(1,matchinetemp);
// bety.SetAt(2,0);
// bety.SetAt(3,0);
int betyIndex =2;
for(index=0;index<4-m_sSetup.GetLength();index++){
bety.SetAt(betyIndex,0);
betyIndex++;
}
// MessageBox("m_sSetup:"+m_sSetup);
for(index =0; index<m_sSetup.GetLength();index++){
bety.SetAt(betyIndex,Hex2Char(m_sSetup.GetAt(index)));
// affix += Hex2Char(m_sSetup.GetAt(index));
betyIndex++;
}
for(index = 6;index<sendDataLength-1;index++)
{
bety.SetAt(index,0);
}
affix = computeAffix(bety);
bety.SetAt(sendDataLength-1,affix);
m_ctrlMSComm.SetOutput(COleVariant(bety));
CString temp;
temp.Format("%d",recentMatchine);
m_sOpration += "向";
m_sOpration += temp;
m_sOpration += "号看板发送'设定原来数据'。";
m_sOpration += "\r\n";
changeShowIcon();
UpdateData(FALSE);
//iSetupSendCount++ ;
/*if(debugFlag){
UpdateData(TRUE);
m_sOpration += "第";
CString temp;
temp.Format("%d",iSetupSendCount);
m_sOpration += temp;
m_sOpration += "次与下位机连接,发送";
m_sOpration += m_sSetup;
// temp.Format("%02x",affix);
// m_sOpration += temp;
m_sOpration += "\r\n";
UpdateData(FALSE);
}*/
//}
}
void CProgressManamgeDlg::processPlan(){
/*if (iPlanSendCount == 3)
{
iPlanSendCount = 0;
sendPlan = FALSE ;
KillTimer(IDT_TIMER_PLAN);
MessageBox("无法与下位机进行通信!","通信错误对话框",MB_OK | MB_ICONINFORMATION);
}
else{*/
CByteArray bety;
int index;
UCHAR affix = 0;
bety.SetSize(sendDataLength);
bety.SetAt(0,planDownSendPrefix);
UCHAR matchinetemp = getDirectoryByMatchId(recentMatchine);
bety.SetAt(1,matchinetemp);
// bety.SetAt(2,0);
// bety.SetAt(3,0);
int betyIndex =2;
for(index=0;index<4-m_sPlan.GetLength();index++){
bety.SetAt(betyIndex,0);
betyIndex++;
}
for(index =0; index <m_sPlan.GetLength();index++,betyIndex++){
bety.SetAt(betyIndex,Hex2Char(m_sPlan.GetAt(index)));
// affix += Hex2Char(m_sPlan.GetAt(index));
}
for(index = 6;index<sendDataLength-1;index++){
bety.SetAt(index,0);
}
affix = computeAffix(bety);
bety.SetAt(sendDataLength-1,affix);
m_ctrlMSComm.SetOutput(COleVariant(bety));
CString temp;
temp.Format("%d",recentMatchine);
m_sOpration += "向";
m_sOpration += temp;
m_sOpration += "号看板发送'计划原来数据'。";
m_sOpration += "\r\n";
changeShowIcon();
UpdateData(FALSE);
/* iPlanSendCount++ ;
if(debugFlag){
UpdateData(TRUE);
m_sOpration += "第";
CString temp;
temp.Format("%d",iPlanSendCount);
m_sOpration += temp;
m_sOpration += "次与下位机连接,发送";
m_sOpration += m_sPlan;
// temp.Format("%02x",affix);
// m_sOpration += temp;
m_sOpration += "\r\n";
UpdateData(FALSE);
}
}*/
}
void CProgressManamgeDlg::processFact(){
/* if (iFactSendCount == 3)
{
iFactSendCount = 0;
sendFact = FALSE;
KillTimer(IDT_TIMER_FACT);
MessageBox("无法与下位机进行通信!","通信错误对话框",MB_OK | MB_ICONINFORMATION);
}
else{*/
CByteArray bety;
int index;
UCHAR affix =0 ;
bety.SetSize(sendDataLength);
bety.SetAt(0,factDownSendPrefix);
UCHAR matchinetemp= getDirectoryByMatchId(recentMatchine);
bety.SetAt(1,matchinetemp);
//bety.SetAt(2,0);
//bety.SetAt(3,0);
int byteIndex=2;
for(index=0;index<4-m_sFact.GetLength();index++){
bety.SetAt(byteIndex,0);
byteIndex++;
}
for(index =0; index<m_sFact.GetLength();index++){
bety.SetAt(byteIndex,Hex2Char(m_sFact.GetAt(index)));
byteIndex++;
//affix += Hex2Char(m_sFact.GetAt(index));
}
/*CString byteStr;
byteStr.Format("%d",byteIndex);
MessageBox("index:"+byteStr);*/
for(index = 6;index<sendDataLength-1;index++){
bety.SetAt(index,0);
}
affix = computeAffix(bety);
bety.SetAt(sendDataLength-1,affix);
m_ctrlMSComm.SetOutput(COleVariant(bety));
CString temp;
temp.Format("%d",recentMatchine);
m_sOpration += "向";
m_sOpration += temp;
m_sOpration += "号看板发送'实际原来数据'。";
m_sOpration += "\r\n";
changeShowIcon();
UpdateData(FALSE);
/* iFactSendCount++ ;
if(debugFlag){
UpdateData(TRUE);
m_sOpration += "第";
CString temp;
temp.Format("%d",iFactSendCount);
m_sOpration += temp;
m_sOpration += "次与下位机连接, 发送";
m_sOpration += m_sFact;
// temp.Format("%02x",affix);
// m_sOpration += temp;
m_sOpration += "\r\n";
UpdateData(FALSE);
}
}*/
}
void CProgressManamgeDlg::processDateTime(){
/* if (iDateSendCount == 3)
{
iDateSendCount = 0;
sendDateTime = FALSE;
KillTimer(IDT_TIMER_DATETIME);
MessageBox("无法与下位机进行通信!","通信错误对话框",MB_OK | MB_ICONINFORMATION);
}
else if(iDateSendCount <3){*/
CByteArray bety;
UCHAR affix=0;
CString strTemp;
bety.SetSize(sendDataLength);
bety.SetAt(0,datetimeDownSendPrefix);
UCHAR matchinetemp = getDirectoryByMatchId(recentMatchine);
bety.SetAt(1,matchinetemp);
strTemp.Format("%d",year);
char chatTemp[2];
Str2Hex(strTemp,chatTemp);
//MessageBox(strTemp);
bety.SetAt(2,chatTemp[1]);
CHAR hexInt = (date/10)*16+date%10;
bety.SetAt(3,hexInt);
hexInt = (mouth/10)*16+mouth%10;
// bety.SetAt(3,chatTemp[0]);
// affix += chatTemp[1];
// strTemp.Format("%d",hexMouth);
// Str2Hex(strTemp,chatTemp);
bety.SetAt(4,hexInt);
// affix+=mouth;
// strTemp.Format("%d",day);
hexInt = (day/10)*16+day%10;
bety.SetAt(5,hexInt);
// affix += day;
// strTemp.Format("%d",date);
// affix += date;
// strTemp.Format("%d",hour);
hexInt = (hour/10)*16+hour%10;
bety.SetAt(6,hexInt);
// affix += hour;
// strTemp.Format("%d",minute);
hexInt = (minute/10)*16+minute%10;
bety.SetAt(7,hexInt);
// affix += minute;
// strTemp.Format("%d",second);
hexInt = (second/10)*16+second%10;
bety.SetAt(8,hexInt);
// affix += second;
for(int index =9; index < sendDataLength-1;index++){
bety.SetAt(index,0);
}
/* affix += chatTemp[0];
affix += Hex2Char(mouth);
affix += Hex2Char(day);
affix += Hex2Char(date);
affix += Hex2Char(hour);
affix += Hex2Char(minute);
affix += Hex2Char(second);*/
affix = computeAffix(bety);
bety.SetAt(sendDataLength-1,affix);
m_ctrlMSComm.SetOutput(COleVariant(bety));
CString temp;
temp.Format("%d",recentMatchine);
m_sOpration += "向";
m_sOpration += temp;
m_sOpration += "号看板发送日期时间数据。";
m_sOpration += "\r\n";
UpdateData(FALSE);
/* iDateSendCount++ ;
if(debugFlag){
UpdateData(TRUE);
m_sOpration += "第";
CString temp;
temp.Format("%d",iDateSendCount);
m_sOpration += temp;
m_sOpration += "次与下位机连接,发送";
m_sOpration += m_sDatetime;
//temp.Format("%02x",affix);
// m_sOpration += temp;
m_sOpration += "\r\n";
UpdateData(FALSE);
}
}*/
}
//计算累加数
UCHAR CProgressManamgeDlg::computeAffix(CByteArray &byte){
UCHAR result =0;
for (int index=0;index<byte.GetSize();index++)
{
result += byte.GetAt(index);
}
return result;
}
void CProgressManamgeDlg::OnButtonPlan()
{
// TODO: Add your control notification handler code here
//UpdateData(TRUE);
SetupNewValueDlg setupDlg(this->m_sPlan,this);
int iResult = setupDlg.DoModal();
if(iResult == IDOK)
{
this->m_sPlan = setupDlg.getVaule();
/*if (!m_sFact.IsEmpty())
{
int diviationInt = atoi(m_sFact) - atoi(m_sPlan);
m_sDiviation.Format("%d", diviationInt);
}*/
iPlanSendCount = 0;
// SetTimer(IDT_TIMER_PLAN,elapseTime,NULL);
processPlan();
sendPlan =TRUE;
UpdateData(FALSE);
}
}
void CProgressManamgeDlg::OnButtonFact()
{
// TODO: Add your control notification handler code here
SetDoubleValueDlg setupDlg(m_sFact,perFact);
int iResult = setupDlg.DoModal();
if(iResult == IDOK)
{
if (setupDlg.getNewValueFlag() ==1)
{
this->m_sFact = setupDlg.getNewValue();
if(!m_sSetup.IsEmpty())
{
int diviationInt = atoi(m_sFact) - atoi(m_sSetup);
m_sDiviation.Format("%d",diviationInt);
}
UpdateData(FALSE);
iFactSendCount = 0;
sendFact = TRUE ;
// SetTimer(IDT_TIMER_FACT,elapseTime,NULL);
processFact();
}
else{
this->perFact = setupDlg.getNewValue();
processPerFact();
}
}
}
void CProgressManamgeDlg::OnButtonSetup()
{
// TODO: Add your control notification handler code here
SetDoubleValueDlg setupDlg(this->m_sSetup,this->perSetup);
int iResult = setupDlg.DoModal();
if(iResult == IDOK)
{
if (setupDlg.getNewValueFlag() ==1)
{
this->m_sSetup = setupDlg.getNewValue();
if (!m_sFact.IsEmpty())
{
int diviationInt = atoi(m_sFact) - atoi(m_sSetup);
m_sDiviation.Format("%d",diviationInt);
}
iSetupSendCount = 0;
sendSetup = TRUE;
//屏蔽下发次数计时
//SetTimer(IDT_TIMER_SETUP,elapseTime,NULL);
processSetup();
UpdateData(FALSE);
}
else{
this->perSetup = setupDlg.getNewValue();
processPerSetup();
}
}
}
void CProgressManamgeDlg::OnButtonDatetime()
{
DateTimeSetupDlg dlg(year,mouth,day,hour,minute,second, this);
//dlg.DoModal();
int iResult = dlg.DoModal();
if(iResult == IDOK){
CTime t = dlg.getDate();
year = t.GetYear();
mouth = t.GetMonth();
day = t.GetDay();
date = t.GetDayOfWeek();
t = dlg.getTime();
hour = t.GetHour();
minute = t.GetMinute();
second = t.GetSecond();
iDateSendCount = 0 ;
sendDateTime = TRUE;
//SetTimer(IDT_TIMER_DATETIME,elapseTime,NULL);
processDateTime();
setDateString();
UpdateData(FALSE);
}
}
void CProgressManamgeDlg::setDateString(){
CString st;
m_sDatetime = "";
st.Format("%d",year);
m_sDatetime += st;
m_sDatetime += "年";
st.Format("%d",mouth);
m_sDatetime += st;
m_sDatetime += "月";
st.Format("%d",day);
m_sDatetime += st;
m_sDatetime += "日";
st.Format("%d",hour);
m_sDatetime += st;
m_sDatetime += "时";
st.Format("%d",minute);
m_sDatetime += st;
m_sDatetime += "分";
// st.Format("%d",second);
// m_sDatetime += st;
// m_sDatetime += "秒";
CString strDate = getDateByInt(date);
m_sDatetime +=" ";
m_sDatetime += strDate;
}
CString CProgressManamgeDlg::getDateByInt(int dateInt){
switch(dateInt)
{
case 2:
return "星期一";
case 3:
return "星期二";
case 4:
return "星期三";
case 5:
return "星期四";
case 6:
return "星期五";
case 7:
return "星期六";
case 1:
return "星期天";
}
}
/*void CProgressManamgeDlg::OnRadio1()
{
// TODO: Add your control notification handler code here
progressRadioChange(IDC_RADIO1);
}*/
void CProgressManamgeDlg::progressBoardChange(int radioId){
/* if(!((CButton *)GetDlgItem(radioId))->GetCheck()){
return;
}*/
map<int,DlgDate>::iterator it= matchineData.find(recentMatchine);
if(it != matchineData.end())
{
matchineData.erase(it->first);
}
DlgDate dlgDate;
copyDataToDlgDate(dlgDate);
matchineData[recentMatchine] = dlgDate;
recentMatchine = radioId;
it = matchineData.find(radioId);
if (it != matchineData.end())
{
dlgDate = it->second;
copyDateFromDlgDate(dlgDate);
if (m_sDatetime.IsEmpty())
{
setDateString();
}
changeShowIcon();
UpdateData(FALSE);
return;
}
initMyData();
changeShowIcon();
UpdateData(FALSE);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -