36 |
OutputDebugString( debug ); |
OutputDebugString( debug ); |
37 |
|
|
38 |
try{ |
try{ |
39 |
|
// Depending on what we have received from client, we replay with the relevant data. |
40 |
switch( atoi(Buff) ) |
switch( atoi(Buff) ) |
41 |
{ |
{ |
42 |
case 110: |
case 110: |
75 |
} |
} |
76 |
|
|
77 |
void TcpClientClass::SendReply(void) |
void TcpClientClass::SendReply(void) |
78 |
{ |
{ |
79 |
CH7ServerDlg* parent = (CH7ServerDlg*) AfxGetMainWnd(); |
CH7ServerDlg* parent = (CH7ServerDlg*) AfxGetMainWnd(); |
80 |
|
|
81 |
CString output; |
CString output; |
82 |
short Tmp; |
short Tmp; |
83 |
CString format; |
CString format; |
84 |
const int timer = 10; |
const int timer = 10; |
85 |
|
|
86 |
Sleep(timer); |
Sleep(timer); |
87 |
mLed3 = parent->H7Serial.readTarget(0); |
mLed3 = parent->H7Serial.readTarget(0); |
88 |
if( mLed3 == 0 ) |
if( mLed3 == 0 ) |
89 |
output = "110|"; |
output = "110|"; |
90 |
else if( mLed3 == 1) |
else if( mLed3 == 1) |
91 |
output = "111|"; |
output = "111|"; |
92 |
Send(output,output.GetLength(),0); |
Send(output,output.GetLength(),0); |
93 |
|
|
94 |
Sleep(timer); |
Sleep(timer); |
95 |
|
|
96 |
mLed4 = parent->H7Serial.readTarget(1); |
mLed4 = parent->H7Serial.readTarget(1); |
97 |
if( mLed4 == 0 ) |
if( mLed4 == 0 ) |
98 |
output = "120|"; |
output = "120|"; |
99 |
else if( mLed4 == 1) |
else if( mLed4 == 1) |
100 |
output = "121|"; |
output = "121|"; |
101 |
Send(output,output.GetLength(),0); |
Send(output,output.GetLength(),0); |
102 |
|
|
103 |
Sleep(timer); |
Sleep(timer); |
104 |
|
|
105 |
mLed5 = parent->H7Serial.readTarget(2); |
mLed5 = parent->H7Serial.readTarget(2); |
106 |
if( mLed5 == 0 ) |
if( mLed5 == 0 ) |
107 |
output = "130|"; |
output = "130|"; |
108 |
else if( mLed5 == 1) |
else if( mLed5 == 1) |
109 |
output = "131|"; |
output = "131|"; |
110 |
Send(output,output.GetLength(),0); |
Send(output,output.GetLength(),0); |
111 |
Sleep(timer); |
Sleep(timer); |
112 |
|
|
113 |
mSw2 = parent->H7Serial.readTarget(3); |
mSw2 = parent->H7Serial.readTarget(3); |
114 |
if( mSw2 == 0 ) |
if( mSw2 == 0 ) |
115 |
output = "140|"; |
output = "140|"; |
116 |
else if( mSw2 == 1 ) |
else if( mSw2 == 1 ) |
117 |
output = "141|"; |
output = "141|"; |
118 |
Send(output,output.GetLength(),0); |
Send(output,output.GetLength(),0); |
119 |
Sleep(timer); |
Sleep(timer); |
120 |
|
|
121 |
mSw3 = parent->H7Serial.readTarget(4); |
mSw3 = parent->H7Serial.readTarget(4); |
122 |
if( mSw3 == 0 ) |
if( mSw3 == 0 ) |
123 |
output = "150|"; |
output = "150|"; |
124 |
else if( mSw3 == 1 ) |
else if( mSw3 == 1 ) |
125 |
output = "151|"; |
output = "151|"; |
126 |
Send(output,output.GetLength(),0); |
Send(output,output.GetLength(),0); |
127 |
Sleep(timer); |
Sleep(timer); |
128 |
|
|
129 |
mPot = parent->H7Serial.readTarget(5); |
mPot = parent->H7Serial.readTarget(5); |
130 |
format.Format("%d|",mPot + 2000); |
format.Format("%d|",mPot + 2000); |
131 |
Send(format,format.GetLength(),0); |
Send(format,format.GetLength(),0); |
132 |
Sleep(timer); |
Sleep(timer); |
133 |
|
|
134 |
mTemp = parent->H7Serial.readTarget(6); |
mTemp = parent->H7Serial.readTarget(6); |
135 |
format.Format("%d|",mTemp + 4000); |
format.Format("%d|",mTemp + 4000); |
136 |
Send(format,format.GetLength(),0); |
Send(format,format.GetLength(),0); |
137 |
Sleep(timer); |
Sleep(timer); |
138 |
} |
} |
139 |
|
|
140 |
void TcpClientClass::OnClose(int nErrorCode) |
void TcpClientClass::OnClose(int nErrorCode) |
141 |
{ |
{ |