📄 comm.lst
字号:
211 4 {
212 5 *((unsigned int *)&pInput[16]) = MODULE20;
213 5 }
214 4 p = (unsigned char xdata *)&pOutput->Info + (uiOffset-40191)*2;
215 4 memcpy(p,(unsigned char*)&pInput[8],uiLength*2);
216 4 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2); // flash module
217 4 ReportModuleType(MODULE20, ReadCANAddress()); //读完厂家信息后再一次上报模块信息
218 4 }
219 3 else
220 3 {
221 4 ;
222 4 }
223 3 break;
224 3
225 3 case CALIBRATION: //0x40
226 3 if (((uchCPUAddressStatus == 0) && (pInput[4] == 1 || pInput[4] == 2))
227 3 || ((uchCPUAddressStatus == 1) && (pInput[4] == 3 || pInput[4] == 4)))
228 3 {
229 4 if ((pInput[4] == 1) || (pInput[4] == 2))
230 4 {
231 5 SetCalibrationStatusMain(*(unsigned char *)&pInput[4],*((unsigned int*)&pInput[5]));
232 5 }
233 4 else if ((pInput[4] == 3) || (pInput[4] == 4))
234 4 {
235 5 SetCalibrationStatusMain(*(unsigned char *)&pInput[4] - 2,*((unsigned int*)&pInput[5]));
236 5 }
237 4 if (*((unsigned int*)&pInput[5]) == 8)
238 4 {
239 5 uchCalibrationStatus = 0;
240 5 }
C51 COMPILER V7.10 COMM 09/18/2008 14:09:30 PAGE 5
241 4 else if (*((unsigned int*)&pInput[5]) == 9)
242 4 {
243 5 uchCalibrationStatus = 1;
244 5 }
245 4 }
246 3 break;
247 3
248 3 case CALCULATE: //0x41 标定值
249 3 if (((uchCPUAddressStatus == 0) && (pInput[4] == 1 || pInput[4] == 2))
250 3 || ((uchCPUAddressStatus == 1) && (pInput[4] == 3 || pInput[4] == 4)))
251 3 {
252 4 if ((pInput[4] == 1) || (pInput[4] == 2))
253 4 {
254 5 if (uchCalibrationStatus == 0)
255 5 {
256 6 SetCalibCurrentZero(*(unsigned char *)&pInput[4], *(unsigned int *)&pInput[5]);
257 6 CalculateCalibrateValue(*(unsigned char *)&pInput[4], 0);
258 6 uchCalibrationStatus = 2;
259 6 }
260 5 else if(uchCalibrationStatus == 1)
261 5 {
262 6 SetCalibCurrentFull(*(unsigned char *)&pInput[4], *(unsigned int *)&pInput[5]);
263 6 CalculateCalibrateValue(*(unsigned char *)&pInput[4], 1);
264 6 uchCalibrationStatus = 2;
265 6 }
266 5 }
267 4 else if ((pInput[4] == 3) || (pInput[4] == 4))
268 4 {
269 5 if (uchCalibrationStatus == 0)
270 5 {
271 6 SetCalibCurrentZero(*(unsigned char *)&pInput[4] - 2, *(unsigned int *)&pInput[5]);
272 6 CalculateCalibrateValue(*(unsigned char *)&pInput[4] - 2, 0);
273 6 uchCalibrationStatus = 2;
274 6 }
275 5 else if(uchCalibrationStatus == 1)
276 5 {
277 6 SetCalibCurrentFull(*(unsigned char *)&pInput[4] - 2, *(unsigned int *)&pInput[5]);
278 6 CalculateCalibrateValue(*(unsigned char *)&pInput[4] - 2, 1);
279 6 uchCalibrationStatus = 2;
280 6 }
281 5 }
282 4 }
283 3 break;
284 3 case ALARMRESET: //0x12报警复位
285 3 SetResetStatusALM(1); //送报警模块
286 3 break;
287 3
288 3 case BYPASSCOMMAND: //0x13 Bypass
289 3 if (((uchCPUAddressStatus == 0) && (pInput[4] == 1 || pInput[4] == 2))
290 3 || ((uchCPUAddressStatus == 1) && (pInput[4] == 3 || pInput[4] == 4)) || (pInput[4] == 0xff))
291 3 {
292 4 if ((pInput[4] == 1) || (pInput[4] == 2))
293 4 {
294 5 *(unsigned int xdata *)&pOutput->uiBypassFlag[pInput[4] - 1] = *(unsigned int *)&pInput[5];
295 5 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2);
296 5 }
297 4 else if ((pInput[4] == 3) || (pInput[4] == 4))
298 4 {
299 5 *(unsigned int xdata *)&pOutput->uiBypassFlag[pInput[4] - 3] = *(unsigned int *)&pInput[5];
300 5 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2);
301 5 }
302 4 else if (pInput[4] == 0xff)
C51 COMPILER V7.10 COMM 09/18/2008 14:09:30 PAGE 6
303 4 {
304 5 *(unsigned int xdata *)&pOutput->uiBypassFlag[0] = *(unsigned int *)&pInput[5];
305 5 *(unsigned int xdata *)&pOutput->uiBypassFlag[1] = *(unsigned int *)&pInput[5];
306 5 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2);
307 5 }
308 4 }
309 3 break;
310 3
311 3 case TRIPLECOMMAND: //0x14 倍增
312 3 if (((uchCPUAddressStatus == 0) && (pInput[4] == 1 || pInput[4] == 2))
313 3 || ((uchCPUAddressStatus == 1) && (pInput[4] == 3 || pInput[4] == 4)) || (pInput[4] == 0xff))
314 3 {
315 4 if ((pInput[4] == 1) || (pInput[4] == 2))
316 4 {
317 5 *(unsigned int xdata *)&pOutput->uiTripValue[pInput[4] - 1] = *(unsigned int *)&pInput[5];
318 5 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2);
319 5 }
320 4 else if ((pInput[4] == 3) || (pInput[4] == 4))
321 4 {
322 5 *(unsigned int xdata *)&pOutput->uiTripValue[pInput[4] - 3] = *(unsigned int *)&pInput[5];
323 5 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2);
324 5 }
325 4 else if (pInput[4] == 0xff)
326 4 {
327 5 *(unsigned int xdata *)&pOutput->uiTripValue[0] = *(unsigned int *)&pInput[5];
328 5 *(unsigned int xdata *)&pOutput->uiTripValue[1] = *(unsigned int *)&pInput[5];
329 5 WriteSystemPara(0,(unsigned char xdata *)pOutput, PARALENGTH*2);
330 5 }
331 4 }
332 3 break;
333 3
334 3 case READ_MODULE_STYLE : //0x10 读模块类型
335 3 ReportModuleType(MODULE20, ReadCANAddress());
336 3 break;
337 3
338 3 case SYSTEMSELFTEST: //0x30 系统自检测试
339 3 SetSelfTestControlStatusMain(*(unsigned int *)&pInput[4]);
340 3 break;
341 3
342 3 default :
343 3 break;
344 3 }
345 2 }
346 1 }
347
348 //--------------------------------------------------------------------------------------------------
349 //函数名称:void JudgeChannelTypePara(void)
350 //功 能:判断通道类型的参数,如果通道类型不正确,则默认通道类型
351 //输入参数:无
352 //返 回:无
353 //--------------------------------------------------------------------------------------------------
354 void JudgeChannelTypePara(void)
355 {
356 1 if (((uiForeChannelType > 12) && (uiForeChannelType < 19)) || (uiForeChannelType == 21) || (uiForeChannel
-Type == 22)
357 1 || (uiForeChannelType == 28))
358 1 {
359 2 ;
360 2 }
361 1 else
362 1 {
363 2 uiForeChannelType = 13;
C51 COMPILER V7.10 COMM 09/18/2008 14:09:30 PAGE 7
364 2 }
365 1 }
366
367 //----------------------------------------------------------------------------------------------
368 //函数名称:void SetModuleStatusCOMM(unsigned char uchModuleFlag)
369 //功 能:从框架模块中将模块状态设置到通信模块中
370 //输入参数:模块状态
371 //返 回:无
372 //完成日期:4/16/2007
373 //---------------------------------------------------------------------------------------------
374 void SetModuleStatusCOMM(unsigned char uchModuleFlag)
375 {
376 1 uchModuleConfigStatus = uchModuleFlag;
377 1 }
378 //--------------------------------------------------------------------------------------------------
379 //函数名称:void ReportAlertEvent(unsigned char uchCh,unsigned int uiAlert)
380 //功 能:上报报警事件
381 //输入参数:通道,报警状态
382 //返 回:无
383 //完成日期:4/16/2007
384 //--------------------------------------------------------------------------------------------------
385 void ReportAlertEvent(unsigned char uchCh,unsigned int uiAlert)
386 {
387 1 uchSendBuf[0] = 0;
388 1 uchSendBuf[1] = 0;
389 1 uchSendBuf[2] = 4;
390 1 uchSendBuf[3] = 0x22;
391 1
392 1 if (uchCPUAddressStatus == 0) //上CPU上报数据
393 1 {
394 2 uchSendBuf[4] = uchCh;
395 2 }
396 1 else if (uchCPUAddressStatus == 1) //下CPU上报数据通道加2 因为之前的计算减了2,减少程序代码
397 1 {
398 2 uchSendBuf[4] = uchCh + 2;
399 2 }
400 1
401 1 *((unsigned int*)&uchSendBuf[5]) = uiAlert;
402 1
403 1 SendPackage(0,1,uchSendBuf);
404 1 return;
405 1 }
406
407 /*****************************************************
408 * 函数介绍: 处理地址偏移量
409 * 输入参数: 偏移量
410 * 输出参数: 数据地址
411 * 返回值 : 无
412 *****************************************************/
413 unsigned int AddrMap(unsigned int uiOffset)
414 {
415 1 if(uiOffset < 40237)
416 1 {
417 2 return (uiOffset - 40200);
418 2 }
419 1 if(uiOffset < 40253)
420 1 {
421 2 return (uiOffset - 40251);
422 2 }
423 1 if(uiOffset >= 40296)
424 1 {
425 2 return (uiOffset - 40291);
C51 COMPILER V7.10 COMM 09/18/2008 14:09:30 PAGE 8
426 2 }
427 1 return 0; //error, should not come here
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -