📄 almset1.lst
字号:
340 4 flag_ac_power_on_reported = FALSE;
341 4 }
342 3 else if((!flag_ac_power_on_reported)&&(ac_power_state()==ON))
343 3 {m2 += 16;
344 4 flag_ac_power_on_reported = TRUE;
345 4 flag_ac_power_off_reported = FALSE;
346 4 }
347 3 }
348 2 if((flag_by_mb_or_set==BY_SET)&&bit_setphone_busy&&(!(m1|(m2&0x06))))
349 2 {flag_by_mb_or_set = BY_MB;
350 3 }
351 2 m3 = 0;
352 2 if(m1|m2)
353 2 {if(flag_by_mb_or_set==BY_SET)
354 3 {m3 = 1;
355 4 }
356 3 else
357 3 {m3 = 2;
358 4 }
359 3 if(flag_section_1_set_alarm&&flag_section_2_set_alarm
360 3 &&flag_section_3_set_alarm&&flag_section_4_set_alarm
361 3 &&flag_section_5_set_alarm&&flag_section_6_set_alarm
362 3 &&flag_section_7_set_alarm&&flag_section_8_set_alarm)
363 3 {m3 += 4;
364 4 }else
C51 COMPILER V7.00 ALMSET1 09/25/2002 15:25:41 PAGE 7
365 3 if(flag_section_1_set_alarm||flag_section_2_set_alarm
366 3 ||flag_section_3_set_alarm||flag_section_4_set_alarm
367 3 ||flag_section_5_set_alarm||flag_section_6_set_alarm
368 3 ||flag_section_7_set_alarm||flag_section_8_set_alarm)
369 3 {m3 += 8;
370 4 }
371 3 if(flag_enable_bell&&flag_risk_occur)
372 3 //if(!bit_bell)
373 3 {m3 += 16;
374 4 }
375 3 if(flag_enable_report_to_user)
376 3 {m3 += 32;
377 4 }
378 3 report_alarm(PHONE_1,m1,m2,m3);
379 3 if(flag_enable_report_to_user&&flag_risk_occur)
380 3 {report_alarm(PHONE_2,m1,m2,m3);
381 4 report_alarm(PHONE_3,m1,m2,m3);
382 4 }
383 3 flag_mbphone_ring = FALSE;
384 3 }
385 2 }
386 1 }
387
388 static bit sensor_alarm_occur()
389 {uchar k,m;
390 1 delay_milliseconds(20);
391 1 for(k=m=0;k<50;k++)
392 1 {if(!bit_sensor)
393 2 {m ++;
394 3 }
395 2 }
396 1 if(m>=40)
397 1 {return(TRUE);
398 2 }
399 1 else
400 1 {return(FALSE);
401 2 }
402 1 }
403
404 static bit confirm_ring_occur()
405 {bit line_state_previous,line_state_this;
406 1 uchar k;
407 1 flag_mb_ring_occur = TRUE;
408 1 seconds_wdt = 30;
409 1 seconds_down = k = 20; //ring 4 sounds at most
410 1 line_state_previous = bit_buzzer;
411 1 do
412 1 {line_state_this = bit_buzzer;
413 2 if(line_state_this==line_state_previous)
414 2 {if((k-seconds_down)>=5)
415 3 {break;
416 4 }
417 3 }
418 2 else
419 2 {k = seconds_down;
420 3 line_state_previous = line_state_this;
421 3 }
422 2 }
423 1 while(seconds_down);
424 1 flag_mb_ring_occur = FALSE;
425 1 if((k>=5)&&(k<=15)) //ring 2 or 3 sounds
426 1 {return(TRUE);
C51 COMPILER V7.00 ALMSET1 09/25/2002 15:25:41 PAGE 8
427 2 }
428 1 else
429 1 {hangup_mbphone;
430 2 delay_milliseconds(2000);
431 2 return(FALSE);
432 2 }
433 1 }
434
435 #if 0
static bit confirm_ring_occur()
{bit line_state_previous;
bit line_state_this;
uchar count_1_l,count_2_l;
uint count_1_h,count_2_h;
seconds_wdt = 30;
flag_mb_ring_occur = TRUE;
seconds_down = 20;
count_1_h = count_1_l = 0;
count_2_h = count_2_l = 0;
while(seconds_down)
{line_state_this = bit_buzzer;
if(line_state_this==line_state_previous)
{count_1_l ++;
if(!count_1_l)
{count_1_h ++;
if(count_1_h>
}
else
{line_state_previous = line_state_this;
count_2_l ++;
if(!count_2_l)
{count_2_h ++;
}
}
}
flag_mb_ring_occur = FALSE;
if((count_2_h>=30)&&(count_2_h<80))
{return(TRUE);
}
else
{hangup_mbphone;
delay_milliseconds(2000);
return(FALSE);
}
}
#endif
474
475 #if 0
static bit confirm_ring_occur()
{uint count1,count2;
bit line_state_previous;
bit line_state_this;
{seconds_wdt = 40;
flag_mb_ring_occur = TRUE;
count1 = 0;
count2 = 0;
while(1)
{line_state_this = bit_buzzer;
if(line_state_this==line_state_previous)
{if(line_state_this)
{count1 ++;
C51 COMPILER V7.00 ALMSET1 09/25/2002 15:25:41 PAGE 9
if(count1>40000)
{//hangup_mbphone;
flag_mb_ring_occur = FALSE;
seconds_wdt = 20;
if(count2>3000)
{return(TRUE);
}
else
{return(FALSE);
}
}
}
}
else
{line_state_previous = line_state_this;
count1 = 0;
count2 ++;
if(count2>5500)
{hangup_mbphone;
flag_mb_ring_occur = FALSE;
seconds_wdt = 20;
return(FALSE);
}
}
}
}
}
#endif
517
518 static bit ac_power_state()
519 {uchar k;
520 1 bit flag;
521 1 flag = OFF;
522 1 for(k=0;k<200;k++)
523 1 {if(!bit_ac_power_state)
524 2 {flag = ON;
525 3 break;
526 3 }
527 2 }
528 1 return(flag);
529 1 }
530
531 #ifdef HAVE_SETPHONE
532 static bit phone_line_cut_off()
533 {uchar k,sum;
534 1 bit flag;
535 1 flag = TRUE;
536 1 for(k=0;k<200;k++)
537 1 {if(!bit_phone_line_state)
538 2 {flag = FALSE;
539 3 break;
540 3 }
541 2 }
542 1 return(flag);
543 1 }
*** WARNING C280 IN LINE 533 OF ..\ALARM\ALMSET1.C: 'sum': unreferenced local variable
544 #endif
545
546 static void report_alarm(uchar phone_id,uchar m1,uchar m2,uchar m3)
547 {uchar k,sum;
548 1 uint m;
549 1 seconds_wdt = 100;
C51 COMPILER V7.00 ALMSET1 09/25/2002 15:25:41 PAGE 10
550 1 flag_reporting_alarm = TRUE;
551 1 if(phone_id==PHONE_1)
552 1 {get_number(PHONE_1_NUMBER_ADDRESS);
553 2 }
554 1 if(phone_id==PHONE_2)
555 1 {get_number(PHONE_2_NUMBER_ADDRESS);
556 2 }
557 1 if(phone_id==PHONE_3)
558 1 {get_number(PHONE_3_NUMBER_ADDRESS);
559 2 }
560 1 if(number[0]==0xff)
561 1 {flag_reporting_alarm = FALSE;
562 2 return;
563 2 }
564 1 if(!(number[0]||number[1]||number[2]))
565 1 {flag_by_mb_or_set = BY_MB;
566 2 }
567 1 if(flag_by_mb_or_set==BY_SET)
568 1 {pickup_setphone;
569 2 delay_milliseconds(1000);
570 2 hangup_setphone;
571 2 delay_milliseconds(2000);
572 2 if(bit_setphone_busy)
573 2 {flag_by_mb_or_set = BY_MB;
574 3 m3 &= 0xfe;
575 3 m3 |= 0x02;
576 3 }
577 2 else
578 2 {pickup_setphone;
579 3 delay_milliseconds(1000);
580 3 }
581 2 }
582 1 if(flag_by_mb_or_set==BY_MB)
583 1 {flag_mbphone_power_on = FALSE;
584 2 press_phone_key(KEY_STAR,200,200);
585 2 press_phone_key(KEY_STAR,200,200);
586 2 if(!flag_serial_number_valid)
587 2 {press_phone_key(KEY_0,200,200);
588 3 }
589 2 if(!flag_phone_1_number_valid)
590 2 {press_phone_key(KEY_1,200,200);
591 3 }
592 2 if(!flag_phone_2_number_valid)
593 2 {press_phone_key(KEY_2,200,200);
594 3 }
595 2 if(!flag_phone_3_number_valid)
596 2 {press_phone_key(KEY_3,200,200);
597 3 }
598 2 clear_mbphone_screen;
599 2 hangup_mbphone;
600 2 if(!flag_mbphone_power_on)
601 2 {turn_mbphone_on;
602 3 delay_milliseconds(8000);
603 3 clear_mbphone_screen;
604 3 clear_mbphone_screen;
605 3 clear_mbphone_screen;
606 3 seconds_wdt = 100;
607 3 }
608 2 }
609 1 //dial phone number
610 1 if(flag_by_mb_or_set==BY_MB)
611 1 {if((!number[0])&&(!number[1]))
C51 COMPILER V7.00 ALMSET1 09/25/2002 15:25:41 PAGE 11
612 2 {if(number[2])
613 3 {for(k=1;k<13;k++)
614 4 {if(number[k]==0xff) break;
615 5 press_phone_key(number[k]&0x0f,300,300);
616 5 }
617 4 press_phone_key(KEY_YES,300,300);
618 4 delay_milliseconds(15000);
619 4 }
620 3 else
621 3 {for(k=0;k<13;k++)
622 4 {if(number[k]==0xff) break;
623 5 press_phone_key(number[k]&0x0f,300,300);
624 5 }
625 4 delay_milliseconds(2000);
626 4 clear_mbphone_screen;
627 4 }
628 3 }
629 2 else
630 2 {for(k=0;k<13;k++)
631 3 {if(number[k]==0xff) break;
632 4 press_phone_key(number[k]&0x0f,300,300);
633 4 }
634 3 press_phone_key(KEY_YES,300,300);
635 3 delay_milliseconds(15000);
636 3 }
637 2 }
638 1 else //SET PHONE
639 1 {k = 0;
640 2 if(!number[0])
641 2 {k = 4;
642 3 }
643 2 for(;k<13;k++)
644 2 {if(number[k]>9) break;
645 3 press_phone_key(number[k],300,300);
646 3 }
647 2 delay_milliseconds(11000);
648 2 }
649 1 //////////
650 1 m = 300;
651 1 if((flag_by_mb_or_set==BY_MB)&&(phone_id==PHONE_1))
652 1 {m = 700;
653 2 }
654 1 press_phone_key(KEY_STAR,300,m);
655 1 press_phone_key(KEY_STAR,300,m);
656 1 press_phone_key(KEY_STAR,300,m);
657 1 //report serial number
658 1 get_number(SERIAL_NUMBER_ADDRESS);
659 1 for(k=sum=0;k<13;k++)
660 1 {if(number[k]==0xff) break;
661 2 press_phone_key(number[k]&0x0f,300,m);
662 2 sum += number[k]*(number[k]+1);
663 2 }
664 1 //report alarm data 1
665 1 char_to_bcd(m1);
666 1 for(k=0;k<3;k++)
667 1 {press_phone_key(number[k]&0x0f,300,m);
668 2 sum += number[k]*(number[k]+1);
669 2 }
670 1 //report alarm data 2
671 1 char_to_bcd(m2);
672 1 for(k=0;k<3;k++)
673 1 {press_phone_key(number[k]&0x0f,300,m);
C51 COMPILER V7.00 ALMSET1 09/25/2002 15:25:41 PAGE 12
674 2 sum += number[k]*(number[k]+1);
675 2 }
676 1 //report alarm data 3
677 1 char_to_bcd(m3);
678 1 for(k=0;k<3;k++)
679 1 {press_phone_key(number[k]&0x0f,300,m);
680 2 sum += number[k]*(number[k]+1);
681 2 }
682 1 //report checksum
683 1 char_to_bcd(sum);
684 1 press_phone_key(number[0],300,m);
685 1 press_phone_key(number[1],300,m);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -