📄 globalfrequencytimerchange.cpp
字号:
LoadString(library_identifier,IDS_STRING_MSG_FREQ_TMR,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
static_total_ft.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_FREQ_OCCUR,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
static_freq.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_TIMER_OCUR,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
static_timer.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_CLOSE,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
close_button.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_SAVE,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
save_button.SetWindowText(stringID_to_string);
LoadString(library_identifier,IDS_STRING_DLG_FREQ_TIMER,stringID_to_string.GetBuffer(MAX_LANG_RES_STRING_LEN+1),MAX_LANG_RES_STRING_LEN);
SetWindowText(stringID_to_string);
}
/////////////////////////////////////////////////////////////////////////////////////////////////
CPtrList* CGlobalFrequencyTimerChange::GetAllAsyncEventsForApp(CString strRecvd)
{
CPtrList *ptrList = new CPtrList();
CAsyncMessageSeq *pAsyncMessage;
CString strXMLEvent;
if(cmessagemanager.m_plstAsyncMsg->GetCount() > 0)//check if emtpy message list
{
for( POSITION pos = cmessagemanager.m_plstAsyncMsg->GetHeadPosition(); pos != NULL;)
{
pAsyncMessage = (CAsyncMessageSeq*)(cmessagemanager.m_plstAsyncMsg->GetNext( pos )) ;
strXMLEvent = pAsyncMessage->GetMessageName();
if(!strXMLEvent.CompareNoCase(strRecvd))
//add it into the Map
{
//now peek into the outgoing message list for this messagid
//and get the CMessage object to be done
//keep on adding into the Ptr List and return it
CList<UINT32, UINT32&>& messageList = pAsyncMessage->GetMessageList();
if(messageList.GetCount() > 0)
{
for( POSITION posResp = messageList.GetHeadPosition(); posResp != NULL; )
{
ptrList->AddTail(LocateMessageInList(cmessagemanager.m_plstOutGoingMsg,messageList.GetNext(posResp)));
}
}
if(ptrList->GetCount() <= 0)
AMLOGERROR(_T("Inside GetAllAsync Messages for App no found error"));
}
}
}
return ptrList;
}
CPtrList * CGlobalFrequencyTimerChange::GetAllOutMsgForApp(UINT32 AppId)
{
CPtrList* list_associated_msg =new CPtrList();
if(cmessagemanager.m_plstOutGoingMsg->GetCount())
{
for(POSITION pos = cmessagemanager.m_plstOutGoingMsg->GetHeadPosition();pos!=NULL;)
{
COutgoingMessage *OutMsg = (COutgoingMessage *) (cmessagemanager.m_plstOutGoingMsg->GetNext(pos));
if(OutMsg ->GetAppId()==AppId)
list_associated_msg->AddTail(OutMsg );
}
}
return list_associated_msg;
}
void CGlobalFrequencyTimerChange::AddDataListInTree(CPtrList *ptrAyncEventsList,CString strRecvd,HTREEITEM htree)
{
int iCount1=0;
CFormat *pFormat;// = new CFormat();
CDataList dataList;
CData dataObj;
for( POSITION pos = ptrAyncEventsList->GetHeadPosition(); pos != NULL;)
{
CMessage* pMessage = (CMessage*)(ptrAyncEventsList->GetNext( pos ));
pFormat = GetFormatForMessage(pMessage);
HTREEITEM h3 = TreeCtrlForFreqTimer.InsertItem(CString(itoa(pMessage->GetMessageId(),dummy,10))+CString(":")+pMessage->GetMessageName(), htree);
TreeCtrlForFreqTimer.SetItemData(h3,2);
if(pFormat!=NULL)
{
CList<CVar,CVar&>& varList = pFormat->GetVarList();
dataList = pFormat->GetDataList();
CList<CData,CData&>& data= dataList.GetData();
if((data.GetCount() > 0) && (varList.GetCount() > 0))
{
int iCount2 = 0;
for( POSITION datapos = data.GetHeadPosition(); datapos != NULL;)
{
dataObj = (data.GetNext( datapos ));
HTREEITEM h4 = TreeCtrlForFreqTimer.InsertItem(dataObj.GetName(), h3);
if(dataObj.GetFrequency()>1)
{
TreeCtrlForFreqTimer.SetCheck(h4,1);
TreeCtrlForFreqTimer.SetParentalCheckState(h4,1);
}
TreeCtrlForFreqTimer.SetItemData(h4,3);
}
}
}
}
}
CFormat* CGlobalFrequencyTimerChange ::GetFormatForMessage(CMessage *pMessage)
{
if(pMessage!=NULL)
{
CFormat *pFormat;
if(cmessagemanager.m_pFormatList->GetCount() > 0)//check if emtpy message list
{
for( POSITION pos = cmessagemanager.m_pFormatList->GetHeadPosition(); pos != NULL;)
{
pFormat = (CFormat*)(cmessagemanager.m_pFormatList->GetNext( pos )) ;
if(!(pMessage->GetFormat().CompareNoCase(pFormat->GetName())))
{
return pFormat;
}
}
}
}
return NULL;
}
CMessage* CGlobalFrequencyTimerChange::LocateMessageInList(CPtrList *msgList,UINT32 iMsgId)
{
//returns the CMessage Object for the iMsgId
CMessage *pMsg ;
if(msgList->GetCount())
{
for( POSITION pos = msgList->GetHeadPosition(); pos != NULL;)
{
pMsg = (CMessage*)(msgList->GetNext( pos )) ;
CString cs1= pMsg->GetPluginName();
if(pMsg->GetMessageId() == iMsgId)
return pMsg;
}
}
return NULL;
}
void CGlobalFrequencyTimerChange::OnWindowPosChanging(WINDOWPOS* lpwndpos)
{
if (lpwndpos->cx == -1)
if (lpwndpos->cy == -1) // is init time
{
lpwndpos->x = 257; // change here if you want to move left or right the window.
lpwndpos->y = 41; // change here if you want to move top or bottom the window.
CDialog::OnWindowPosChanging(lpwndpos);
}
}
void CGlobalFrequencyTimerChange::OnBnClickedCancel()
{
int afxMsgBoxResponse;
if(m_DialogStateChange == 1)
{
afxMsgBoxResponse = AfxMessageBox(IDS_STRING_MODIFY_CONFIRM,MB_ICONQUESTION|MB_YESNOCANCEL);
if(afxMsgBoxResponse ==IDCANCEL)
{
return ;
}
if(afxMsgBoxResponse ==IDYES)
{
SaveFreqTimer();// to perform save
OnCancel();
}
if(afxMsgBoxResponse ==IDNO)
{
OnCancel();
}
}
else
{
OnCancel();
}
}
/*------- This function is to fill the TOTAL edit box for freq & timer enable messages --------------*/
UINT32 CGlobalFrequencyTimerChange::GetTotalNoFreqMsg(HTREEITEM ti)//ti - tree item
{
HTREEITEM child = TreeCtrlForFreqTimer.GetChildItem(ti);
int count=0;
UINT32 freq,MessageId;
while(child!=NULL)
{
MessageId = _ttoi(TreeCtrlForFreqTimer.GetItemText(child));
freq= messagemanager->GetFreq(MessageId,CString(""));
if( (freq>1) && (TreeCtrlForFreqTimer.GetCheck(child))==TRUE)
count++;
count = count + GetTotalNoFreqMsg(child);
child = TreeCtrlForFreqTimer.GetNextSiblingItem(child);
}
return count;
}
void CGlobalFrequencyTimerChange::InitFrequencyTimerCombo()
{
int counter;
char *dummy = (char*) malloc(sizeof(char)*10);
for(counter=1;counter<=MAXFREQ;counter++)
{
mFreq.AddString(CString(CString(itoa(counter,dummy,10))));
}
for(counter=0;counter<=MAXTIMER;counter++)
{
mTimer.AddString(CString(CString(itoa(counter,dummy,10))));
}
free(dummy);
}
void CGlobalFrequencyTimerChange::OnCbnSelchangeComboFrequency()
{
CString freqcmbwindowtext,timerwindowtext,treeselitemtext;
HTREEITEM TreeItem;
mFreq.GetLBText(mFreq.GetCurSel(),freqcmbwindowtext);
mTimer.GetLBText(mTimer.GetCurSel(),timerwindowtext);
if(!(CString("1").CompareNoCase(freqcmbwindowtext))) //freq = 1
{
mTimer.SetCurSel(0);
mTimer.EnableWindow(0);
TreeItem=TreeCtrlForFreqTimer.GetSelectedItem(); // Set tree item uncheck if freq =1
TreeCtrlForFreqTimer.SetCheck(TreeItem,0);
TreeCtrlForFreqTimer.SetParentalCheckState(TreeItem,0);
}
else
{
if(!(CString("0").CompareNoCase(timerwindowtext))) //Timer= 1
{
mTimer.SetCurSel(1);
mTimer.EnableWindow(1);
TreeItem=TreeCtrlForFreqTimer.GetSelectedItem(); // Set tree item check if freq >1
TreeCtrlForFreqTimer.SetCheck(TreeItem,1);
TreeCtrlForFreqTimer.SetParentalCheckState(TreeItem,1);
}
}
save_button.EnableWindow(1);
mFreq.SetFocus();
m_DialogStateChange = 1;
}
void CGlobalFrequencyTimerChange::OnCbnSelendokComboFrequency()
{
/*save_button.EnableWindow(1);
m_DialogStateChange = 1;*/
}
void CGlobalFrequencyTimerChange::OnCbnEditchangeComboFrequency()
{
}
void CGlobalFrequencyTimerChange::OnBnClickedOk()
{
CString resultant_string;
AfxFormatString1(resultant_string,IDS_STRING_FT_SAVE_CONFIRMATION,m_Dataset);
if( AfxMessageBox(resultant_string,MB_YESNO)==IDYES)
{
SaveFreqTimer();
}
}
void CGlobalFrequencyTimerChange::SaveFreqTimer()
{
UINT32 Freq,Timer;
CString strFreq,strTimer;
mFreq.GetWindowText(strFreq);
Freq = _ttoi(strFreq);
mTimer.GetWindowText(strTimer);
Timer = _ttoi(strTimer);
messagemanager->SetDataSetDetails(m_MsgId,m_Dataset,CString(""),CString(""),Freq,Timer);
//now update the total count of messages having freq >1
total.SetWindowText(CString(itoa( GetTotalNoFreqMsg(TreeCtrlForFreqTimer.GetRootItem()), dummy,10)));
save_button.EnableWindow(0);
m_DialogStateChange = 0;
close_button.SetFocus();
}
void CGlobalFrequencyTimerChange::OnCbnKillfocusComboTimer()
{
//AfxMessageBox(_T("Frequency Timer get updated in the list"));
}
void CGlobalFrequencyTimerChange::OnCbnSelendokComboTimer()
{
/*save_button.EnableWindow(1);
m_DialogStateChange = 1;*/
}
void CGlobalFrequencyTimerChange::OnCbnSelchangeComboTimer()
{
CString freqcmbwindowtext,timercmbwindowtext,treeselitemtext;
int timervalue;
mFreq.GetLBText(mFreq.GetCurSel(),freqcmbwindowtext);
mTimer.GetLBText(mTimer.GetCurSel(),timercmbwindowtext);
if(!((CString("1").CompareNoCase(freqcmbwindowtext))&&(CString("0").CompareNoCase(timercmbwindowtext)))) //when freq is > 1
{
AfxMessageBox(IDS_STRING_CANT_MAKE_FREQ_0,MB_OK);
treeselitemtext=TreeCtrlForFreqTimer.GetItemText(TreeCtrlForFreqTimer.GetSelectedItem());
if(CStringToUint32(treeselitemtext)> 0) //itoa gives 0 means dataset, other means message because msg format is like 1399:MsgName
timervalue = messagemanager->GetTimer(m_MsgId,CString(""));//timer for default dataset
else
timervalue = messagemanager->GetTimer(m_MsgId,treeselitemtext); // timer for selected dataset
// if freq > 1 is selected and timer 0 selected somehow, msg pop up appear
// but if default is 0, as calculated above, then make it 1
if( (CStringToUint32(freqcmbwindowtext)> 1)&& timervalue ==0)
timervalue++;
mTimer.SetCurSel(timervalue);
}
save_button.EnableWindow(1);
mTimer.SetFocus();
m_DialogStateChange = 1;
}
void CGlobalFrequencyTimerChange::OnCbnSetfocusComboFrequency()
{
}
void CGlobalFrequencyTimerChange::OnCbnSetfocusComboTimer()
{
//OnCbnSelendokComboTimer();
}
BOOL CGlobalFrequencyTimerChange::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_KEYDOWN)
{
if(pMsg->wParam == VK_ESCAPE)
{
OnBnClickedCancel();
return 1;
}
else if(pMsg->wParam == VK_RETURN)
{
CWnd* wnd_under_focus = GetFocus();
if(wnd_under_focus == &save_button)
return CDialog::PreTranslateMessage(pMsg);
else if(wnd_under_focus == &close_button)
return CDialog::PreTranslateMessage(pMsg);
else
return 1;
}
}
return CDialog::PreTranslateMessage(pMsg);
}
UINT32 CGlobalFrequencyTimerChange::CStringToUint32(CString cstrValue)
{
return _ttoi(cstrValue);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -