-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathSimDlg.cpp
More file actions
executable file
·144 lines (125 loc) · 3.93 KB
/
Copy pathSimDlg.cpp
File metadata and controls
executable file
·144 lines (125 loc) · 3.93 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// SimDlg.cpp : implementation file
//
#include "stdafx.h"
#include "MANET.h"
#include "SimDlg.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSimDlg dialog
CSimDlg::CSimDlg(CWnd* pParent /*=NULL*/)
: CDialog(CSimDlg::IDD, pParent)
, clock(0)
{
//{{AFX_DATA_INIT(CSimDlg)
m_master = 0;
m_slave1 = 0;
m_slave2 = 0;
//}}AFX_DATA_INIT
}
void CSimDlg::DoDataExchange(CDataExchange* pDX)
{
CDialog::DoDataExchange(pDX);
DDX_Control(pDX, IDC_BUTTON_ResumeStop, m_resumestop);
DDX_Control(pDX, IDC_LIST_EVENTS, m_events);
DDX_Slider(pDX, IDC_SLIDER_MasterSpeed, m_master);
DDX_Slider(pDX, IDC_SLIDER_SlaveSpeed1, m_slave1);
DDX_Slider(pDX, IDC_SLIDER_SlaveSpeed2, m_slave2);
DDX_Text(pDX, IDC_EDIT_Clock, clock);
}
BEGIN_MESSAGE_MAP(CSimDlg, CDialog)
//{{AFX_MSG_MAP(CSimDlg)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_MasterSpeed, OnReleasedcaptureSLIDERMasterSpeed)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_SlaveSpeed1, OnReleasedcaptureSLIDERSlaveSpeed1)
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SLIDER_SlaveSpeed2, OnReleasedcaptureSLIDERSlaveSpeed2)
ON_BN_CLICKED(IDC_BUTTON_ResumeStop, OnBUTTONResumeStop)
ON_WM_TIMER()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSimDlg message handlers
BOOL CSimDlg::OnInitDialog()
{
CDialog::OnInitDialog();
// TODO: Add extra initialization here
UpdateData(TRUE);
//timer=FALSE;
ASSERT_VALID(Document); //check that the document variable is set!
this->m_master=100; //set master timer to 100
SetTimer(1,m_master,0); //Set Timer Interruption for every 1ms
this->m_slave1=0; //SlaveSpeed0=0;
this->m_slave2=0; //SlaveSpeed1=0;
TicksPerInterrupt=(m_slave1+1)*(m_slave2+1);
this->m_events.EnableWindow(FALSE);
this->RouterSize=Document->Routers.GetSize();
this->Timer=FALSE; //First to Clock!
this->CLOCK=0; //First Clock = 0!
UpdateData(FALSE);
return TRUE; // return TRUE unless you set the focus to a control
// EXCEPTION: OCX Property Pages should return FALSE
}
void CSimDlg::OnReleasedcaptureSLIDERMasterSpeed(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
SetTimer(1,m_master,0); //Set Timer Interruption for every 1 ms
UpdateData(FALSE);
*pResult = 0;
}
void CSimDlg::OnReleasedcaptureSLIDERSlaveSpeed1(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
TicksPerInterrupt=(m_slave1+1)*(m_slave2+1);
UpdateData(FALSE);
*pResult = 0;
}
void CSimDlg::OnReleasedcaptureSLIDERSlaveSpeed2(NMHDR* pNMHDR, LRESULT* pResult)
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
TicksPerInterrupt=(m_slave1+1)*(m_slave2+1);
UpdateData(FALSE);
*pResult = 0;
}
void CSimDlg::OnBUTTONResumeStop()
{
// TODO: Add your control notification handler code here
UpdateData(TRUE);
CString str;
this->GetDlgItemText(IDC_BUTTON_ResumeStop,str);
if(str=="Resume")
{
this->SetDlgItemText(IDC_BUTTON_ResumeStop,"Pause");
SetTimer(1,m_master,0);
Timer=TRUE;
}
else
{
this->SetDlgItemText(IDC_BUTTON_ResumeStop,"Resume");
KillTimer(1);
Timer=FALSE;
}
UpdateData(FALSE);
}
void CSimDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
UpdateData(TRUE);
if(Timer)
{
for(TicPerIntCounter=0;TicPerIntCounter<TicksPerInterrupt;TicPerIntCounter++)
{
CLOCK++;
RouterSize=Document->Routers.GetSize();
for(RouterSizeCounter=0;RouterSizeCounter<RouterSize;RouterSizeCounter++)
((CRouter*)(Document->Routers[RouterSizeCounter]))->tick();
}
this->clock=CLOCK;
}
UpdateData(FALSE);
CDialog::OnTimer(nIDEvent);
}