⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 walker.prg

📁 抄表机的抄表程序源码
💻 PRG
📖 第 1 页 / 共 2 页
字号:
**** WALKER.PRG  广州北区供电局  93.09.09  93.09.15 ****
**** WALKER.PRG  广州北区供电局  Update at 00.10.31 ****

set color to
set help to HelpHdl
set exact off
set numwidth to 8
set decimal to 1

KEY_ENTER = 13
KEY_F1 = 28
KEY_F10 = -9
KEY_DEL = 7
KEY_BS = 8
KEY_UP = 5
KEY_DOWN = 24
KEY_LEFT = 19
KEY_RIGHT = 4
KEY_ASTERISK = 42
KEY_SLANT = 47
KEY_PLUS = 43
KEY_MINUS = 45
rKEY_ESC = 12
KEY_ESC = 27

ib_swith = .t.

PointOfHM = 1
helpContext = 0
Httype = _GETMACHCODE()

 if Httype = 6
    do _LcdWinSet with 0,0, 127, 127, 8, 32
 else
    do _LcdWinSet with 0,0, 63, 127, 4, 32
 endif
        
do _HideCursor

clear

if Httype = 6 
     @1,0 say ' 广州北区供电局'
     @2,0 say ' HTBase抄表程序'
     @5,0 say '       HTOS V2.0'
     @6,0 say '      2000.10.31'
else
     @0,0 say ' 广州北区供电局'
     @1,0 say ' HTBase抄表程序'
     @3,0 say '       93.09.15'         
endif     
      

passWord = GetPassword('密码:')
do while password <> GetPassword('确认:')
  password = GetPassword('密码:')
enddo
clear

dimension readingFlagName(3), flagBZ(2), flagXZ(3)
*异常码定义
readingFlagName(1)='未抄'
readingFlagName(2)='已抄'
readingFlagName(3)='换表'

flagBZ(1)='母表'
flagBZ(2)='子表'

flagXZ(1)='力'
flagXZ(2)='灯'
flagXZ(3)='灯'

Percent = 50
exitBrowse = .F.
redraw = .T.
locMode = 1
scanNeeded = .T.
chargeBH=' '

do MeterReading

return

DATABASE 'CBDATA.DBF'
% heap  12288
% code   1024
% stack  4096

procedure GetPassword
parameters prmt
 
  if Httype = 6 
     do _LcdWinOpen with 54,16, 76,111, 2,12
  else
     do _LcdWinOpen with 32,17,53,111,2,16
  endif   
  
  psw = '     '
  @0,0 say prmt
  set color to n/n
  @0, 5 get psw
  do _ShowCursor
  read
  set color to w/n
  do _LcdWinClose
  return psw

procedure HelpHdl

  colsave=_color(7)
  do case
  case helpContext = 1
    if Httype = 6 
       do _LcdWinOpen with 0,0, 127,127, 16,16
       do _LcdPullMode with 0
       set color to n/w
       ? '    帮  助      '
       set color to w/n
       ? 'SHIFT+箭头浏览'
    else
       do _LcdWinOpen with 0,0, 64,128, 16, 16
       do _LcdPullMode with 0
       ? '      帮助'
       ? '用SHIFT+箭头浏览' 
    endif   
          
    ? 'MODE -- 主菜单 '
    ? '空格 -- 第二屏 '
    ? 'ENT  -- 输表底 '
    ? 'DEL  -- 设换表 '
    ? 'BS -- 移动户名 '
    ? '↑ -- 上一记录 '
    ? '←  未抄首记录 '
    ? '↓ -- 下一记录 '
    ? '→ 下一未抄记录'
    ? ' +  按编号查询 '
    ? ' -  按表号查询 '
    ? ' *  --  首记录 '
    ? ' /  --  末记录 '
    ? ' %  按户名查询 '
    do while inkey(0) # KEY_ESC
    enddo
    do _LcdWinClose
  case helpContext = 2
    if Httype = 6
       do Show2LnBox with ' 请输入 ', '本月表底', 0, 0
    else 
       do Show2LnBox with '请输入本月', '   表底', 0, 0
    endif
  endcase
  do _color with colsave
  return

procedure Show2LnBox
parameters fstLine, sndLine, k1, k2

  i =Len(fstLine)
  j =Len(sndLine)
  m = iif(i>j, i, j)
  j = Int((128-(m*8))/2)
  i = (m*8)+j
  if Httype = 6 
     do _LcdWinOpen with 44,j-3, 81,i+3, 2,16  
  else
     do _LcdWinOpen with 12, j-3, 49, i+3, 2,16
  endif     
  @0,0 say fstLine
  @1,0 say sndLine
  k0 = -1
  do while .not. ((k0=k1) .or. (k0=k2))
    k0 = InKey(0)
    if (k1=0) .or. (k2=0)
      do _LcdWinClose
      return k0
    endif
  enddo
  do _LcdWinClose
  return k0

procedure NextRecord

  skip
  if eof()
    go bottom
    k = Show2LnBox(' 已到末尾 ', '任一键继续', 0, 0)
  else
    redraw = .T.
    scanNeeded = .T.
  endif
  return

procedure LastRecord

  skip -1
  if bof()
    go top
    k = Show2LnBox(' 已到开头 ', '任一键继续', 0, 0)
  else
    redraw = .T.
    scanNeeded = .T.
  endif
  return

procedure Readpc
parameters fx,dl
if Httype = 6
   do _LcdWinOPen with 34,0, 88,127, 3,15
else
   do _LcdWinOPen with 3,0, 57,127, 3,15
endif   
@0,0 say '上月:'
@0,5 say cs1 pict '999999.9'
@1,0 say '本月:'
@1,5 say dl pict '999999.9'
if fx = 0
  @2,0 say '偏大'
else
  @2,0 say '偏小'
endif
@2,4 say '+继续 -取消'
k0=0
do while .not. ((k0=key_Plus) .or. (k0=key_minus))
  k0 = InKey(0)
enddo
do _LcdWinClose
return k0


procedure ReadThis
  if Httype = 6 
     do _LcdWinOPen with 42,4, 80,122, 2,16
  else
     do _LcdWinOPen with 3,4, 57,122, 3,16
  endif      
  do _LcdPullMode with 0
  redraw = .F.
  Badcomf = .F.
  comfirm = .F.
  t = BYG1
  do while .not. comfirm
    do _ShowCursor
    @0,0 say '上月:'
    @0,5 say SYG1 picture '999999.9'
    @1,0 say '本月:'
    @1,5 get t picture '999999.9'
    helpContext = 2
    read
    helpContext = 0
    do _HideCursor
    v2=t
    if updated() .or. Badcomf
      redraw = .T.
      comfirm = .T.
      if (t<SYG1) .and. (.not. Badcomf)
        do _Beep with 1
        ks = Show2LnBox(' 电表回零?','+继续 -取消', asc('+'), asc('-'))
        if ks = asc('-')
          comfirm = .F.
        endif
      endif
      if comfirm
        if t<SYG1
          do case
          case SYG1 < 1000
            v2=v2+1000
          case SYG1 < 10000
            v2=v2+10000
          otherwise
            v2=v2+100000
          endcase
        endif
      endif
      if comfirm .and. (.not. Badcomf)
        if ((v2-SYG1)*BL) >= (CS1*(1+Percent/100))
           do _Beep with 1
           ks=ReadPC(0,(V2-SYG1)*BL)
           if ks = key_minus
             comfirm =.F.
           endif
        else
          if ((v2-SYG1)*BL) <= (CS1*(1-Percent/100))
            do _Beep with 1
            ks=ReadPC(1,(V2-SYG1)*BL)
            if ks = key_minus
              comfirm =.F.
            endif
          endif
        endif
      endif
      if comfirm
        if Badcomf
          replace BYG1 with 0
        else
          replace XZM1 with 0
          replace XBL  with 0
          replace BYG1 with t
          replace CBBZ with 1
        endif
        replace RQ with date()
        set numwidth to 8
        set decimal to 0
        do _HideCursor
        @2,0 say '电量:'
        if Badcomf
          @2,5 say t picture '999999.9'
        else
          @2,5 say (V2-SYG1)*BL picture '999999.9'
        endif
        ks = inkey(0)
        if ks=KEY_ESC
          comfirm = .F.
          exit
        endif
        if Badcomf
     *    replace YC with str(m,1), ti with time()
     *    replace PJ with t
        endif
        set numwidth to 8
        set decimal to 1
        skip
        if eof()
          go bottom
        endif
      endif
    else
      comfirm = .F.
      exit
    endif
  enddo
  do _LcdWinClose
  return


procedure MainMenu

  if Httype = 6
     do _LcdWinOpen with 14,19,115,104, 6,10
  else
     do _LcdWinOpen with 0,19,63,104, 6,10
  endif      
  do _ShowCursor
  do _LcdPullMode with 2
  @0,0 prompt '1.密码保护'
  @1,0 prompt '2.统计信息'
  @2,0 prompt '3.数据通信'
  @3,0 prompt '4.报 警 率'
  @4,0 prompt '5.电池容量'
  if ib_swith
    @5,0 prompt '6.不能切换'
  else
    @5,0 prompt '6.允许切换'
  endif
  menu to m
  do _LcdWinClose
  return m

procedure ShowBatt

  batt = _GetBattery()
  if Batt > 100
    batt1 = int(batt /256)
    batt1 = batt1 + (batt - batt1 * 256) / 100

    if Httype = 6     
       set color to n/w
       @6,0 say batt1 pict '9.99'
       @6,4 say 'V'
       set color to w/n
    else
       if Httype = 5
         @0,11 say batt1 pict '9.99'
         @0,15 say 'V'
       else
         @0,15 say batt1 pict '9.99'
         @0,19 say 'V'   
       endif    
    endif   
  else
    do _LCDDrawBox with 6,83,10,104,1
    do _LCDDrawBox with 7,104,9,105,1
    if batt >= 100
      batt1 = 20
    else
      batt1 = int(batt/5)
    endif
    do _LCDDrawBox with 7,83,8,83+batt1,1
    do _LCDDrawLn with 9,83,9,83+batt1,1
    do _LCDRefresh
  endif

  if _BackupBatt()
      if Httype = 6 
          * do _LcdRevArea with 18, 88, 30, 127
      else
          do _LcdRevArea with 2, 88, 12, 127
      endif       
  else
    do _LcdRevArea with 9, 88, 12, 127
    do _Beep with 2
    ks = Show2lnBox(' 备电不足 ', ' 请速更换 ',0,0)
  endif
  return

procedure BadMeter

  if Httype = 6
     do _LcdWinOPen with 34,4, 88,122, 3,16
  else 
     do _LcdWinOPen with 3,4, 57,122, 3,16   
  endif   
  do _LcdPullMode with 0
  redraw = .F.
  t1 = XZM1
  t2 = XBL
  do _ShowCursor
  @0,4 say '换新表'
  @1,0 say '行度:'
  @1,5 get t1 picture '999999.9'
  @2,0 say '倍率:'
  @2,5 get t2 picture '9.9999'
  helpContext = 2
  read
  helpContext = 0
  do _HideCursor
  if updated()
    redraw = .T.
    repl XZM1 with t1
    repl XBL with t2
    repl BYG1 with 0
    repl CBBZ with 2
  endif
  do _LcdWinClose
  return

procedure DispThis28

  if redraw
     clear
     do ShowBatt
     set color to n/w
     @0,0 say ' 广州北区供电局 '
     set color to w/n
     @2,0 say '编  号:'+BH
     @3,0 say '用户名:'+HM
     @4,0 say '仪表号:'+YBH
     @4,13 say 'X'
     ?? ltrim(rtrim(str(BL,6)))
     @5,0 say flagXZ(val(XZ))
     ?? ' '
     set numwidth to 6
     set decimal to 4
     ?? DJ
     ?? '   '
     set color to n/w
     if SUBSTR(BH,8,1)='W'
        @6,8 say '无功'
     endif
     @6,12 say readingFlagName(CBBZ+1)
     PointOfHM = 1
     set color to w/n
     set numwidth to 8
     set decimal to 1
     redraw = .F.
  endif
  return
  
procedure DispThis18

  if redraw
    set color to w/n
    clear
    do ShowBatt
    @0,0 say BH
    @1,0 say HM
    @2,0 say YBH
    @2,9 say 'X'
    ?? ltrim(rtrim(str(BL,6)))
    @3,0 say flagXZ(val(XZ))
    ?? ' '
    set numwidth to 6
    set decimal to 4
    ?? DJ
    set color to n/w
    if SUBSTR(BH,8,1)='W'
      @0,14 say '无功'
    endif
    @3,12 say readingFlagName(CBBZ+1)
    PointOfHM = 1
    set color to w/n
    set numwidth to 8
    set decimal to 1

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -