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

📄 es16uh.zrg

📁 本代码为与电能表相配套的掌上通讯设备的源程序
💻 ZRG
📖 第 1 页 / 共 5 页
字号:
       				enddo 
       				if ccszflag = 1 .and. writename="初始电量"
       					datanewfig = inputkey
       				endif       
           			ctmpstr2=str(val(inputkey),datalen,dot) 
           			m=scanbyte(ctmpstr2{1,datalen},asc("."))          
           			if m>0
               				ctmpstr2=substr(ctmpstr2,1,m-1)+substr(ctmpstr2,m+1,datalen-m) 
           			endif  
            			i=1  
            			ctmpstr3=""
                     		if dot>0
                        		k=datalen-1
                     		else
                        		k=datalen
                     		endif
            			do while i<=k
                       			ctmpstr4=str(val(substr(ctmpstr2,i,1)),1)
					ctmpstr3=ctmpstr3+ctmpstr4
                       			i=i+1
                   		enddo     
            			strinput=strinput+ctmpstr3                              
           			ncharstart=ncharstart+21 
          			j=j+datalen
          			l=l+1
          			if writename="电表密码"
					strinput=strinput+"00" 
				endif  
          			if ifdefault=0  .and. writename="电表密码"    &&单设表底时不执行
					inputkey=" "	 
					ctempcode=inputkey
					@2,0 say "新密码"
					nrow=2
					ncol=9
					do inputformat
					ctempcode=" "
				endif	
			enddo
			
			if writename="循显时间" .and. val(strinput)>9 
            			szdata{1,1}=val(strinput)+51
            		else
            			szdata=numtobcd(val(strinput),33h)
            		endif 

            	      	m=scanbyte(szdata{1,ndatalen},255)
            		if m>0          
                		szdata{m,ndatalen-m+1}=51                                   
            		endif
			@1,0 say space(21)   
            		@2,0 say space(21)               
             		@1,0 say "正在设置"+trim(ctmpstr)

		case nchangeformat=11
			return		&&通断电操作

		case nchangeformat=13		&&密码修改
				inputkey=""
				do while len(inputkey)=0
	   				@1,0 say "电表密码:"
					input "" to inputkey
	  				if len(inputkey)=0 .or. len(inputkey)>6
						clear
						@0,0 say "密码长度错误!按确认重输,其他键返回"
						Wait "" to chKey
						if asc(chKey) = 13
							inputkey=""
		    					loop
		    				else
		    					ifquit=1
		    					return
		    				endif
					endif   
				enddo
			inputkey= right("000000"+inputkey,6)
			HexStr = inputkey
			do HEXtonum
			szdata{1,4} =51
			szdata{1,1} = 33H
			szdata{2,1} = word3 
			szdata{3,1} = word2 
			szdata{4,1} = word1	
	endcase	
	return
endpro
*/---------------------------------------------------------------------\*
*/---------------------------------------------------------------------\*
PROCEDURE ddsfmenuzb
	clear
	DO WHILE .T.
		initsio 1,"e",8 
		set com to 1 
		szWinTitle = "载波菜单"
		do ShowWindow
		aszMxItem[1] = "1.单项设置"
		aszMxItem[2] = "2.单项抄收"
		aszMxItem[3] = "3.表号操作"
		aszMxItem[4] = "4.广播校时"
		aszMxItem[5] = "5.出厂设置"
		nMxItemNum = 5
		nMxChoice = 1
		do Menu
		chfMain = chr(nMxChoice+48)
		do case
            		case chfMain = "1"
            			do inputmeterid
                		if ifquit=1
                    			loop	
				endif
    				@0,7 say cmtnum1
    				inputkey=""
   				@1,0 say "电表密码:"
   				input "" to inputkey
  				if len(inputkey)=0 .or. len(inputkey)>6
  					clear
  					@0,0 say "密码长度错误!"
  					wait""
                    			loop
                    			exit
               			endif   
               			 
               			inputkey= right("000000"+inputkey,6)
               			HexStr = inputkey
               			do HEXtonum
  				szpassword{1,4} =51
  				szpassword{1,1} = 33H
  				szpassword{2,1} = word3 
  				szpassword{3,1} = word2 
  				szpassword{4,1} = word1  
   				do ddsfdxwrite				
     			
			case chfMain = "2"
				do inputmeterid
				if ifquit=1
                    			loop
                		endif
    				@0,7 say cmtnum1 
				do ddsfdxread		
   				
         		case chfMain = "3"
         			do ddsfmeteridmenu
         		
         		case chfMain = "4"
         			do broadcast

         		case chfMain = "5"
         			ctempcode=""
                                do inputmeterid
                        	if ifquit=1
                        		loop	
				endif
        			@0,7 say cmtnum1 
        			datauno = cmtnum1
				datanewfig="99997.00"    &&默认出厂底数为99997.00
                           	do Es16uDefaultSetupMain
                        OTHERWISE
				CLEAR
				RETURN
		endcase
	enddo
	return
Endpro
*/---------------------------------------------------------------------\* 
*16进制字符串数转换成为高低字节数
*/---------------------------------------------------------------------\*
Procedure HEXtonum
		
		
		temp=substr(HexStr,1,1)
		if asc(temp )> 64
			Word1high= asc(temp)-65+10
		else
			Word1high= asc(temp)-48
		endif
		temp=substr(HexStr,2,1)
		if asc(temp )> 64
			Word1low= asc(temp)-65+10
		else
			Word1low= asc(temp)-48
		endif		
		
		Word1=	Word1high*16+Word1low +51
		if word1 > 255
  			word1=word1 - 256
  		endif
			
		temp=substr(HexStr,3,1)
		if asc(temp )> 64
			Word2high= asc(temp)-65+10
		else
			Word2high= asc(temp)-48
		endif	
		temp=substr(HexStr,4,1)
		if asc(temp )> 64
			Word2low= asc(temp)-65+10
		else
			Word2low= asc(temp)-48
		endif
		Word2=	Word2high*16+Word2low +51
		if word2 > 255
  			word2=word2 - 256
  		endif	
		temp=substr(HexStr,5,1)
		if asc(temp )> 64
			Word3high= asc(temp)-65+10
		else
			Word3high= asc(temp)-48
		endif	
		temp=substr(HexStr,6,1)
		if asc(temp )> 64
			Word3low= asc(temp)-65+10
		else
			Word3low= asc(temp)-48
		endif
		Word3=	Word3high*16+Word3low +51	
		if word3 > 255
  			word3=word3 - 256
  		endif

		return		
endpro
*/---------------------------------------------------------------------\*
*/---------------------------------------------------------------------\* 
PROCEDURE ddsfmeteridmenu
	clear
	do while .t.
		szWinTitle = "--表号操作--"
		nCatStyle  = 2
		nWinStyle  = 1
		nMxItemNum = 2
		aszMxItem[1] = "1.硬设表号"
		aszMxItem[2] = "2.硬读表号"		
		nMxChoice=1
        	clear
		do Menu
		chfMain = chr(nMxChoice+48)
		do case
			case chfMain = "1"
				do ddsfmeterwrite
			case chfMain = "2"
				do ddsfmeterread
			OTHERWISE
				CLEAR
				RETURN
		endcase
	enddo
	return
ENDPRO
*/---------------------------------------------------------------------\*
Procedure ddsfmeterwrite
		inputkey="999999999999"
                szaddr{1,6}=0
    		szaddr=numtobcd(val(inputkey),0)   
    		m=scanbyte(szaddr{1,6},255) 
    		if m>0         
    			szaddr{m,7-m}=0           	
   		endif
       		if zhbcflag = 0 		&&不在综合编程中,单项编程
			clear	
         		@0,0 say "表  号:"
         		inputkey=""
			do while len(inputkey)=0
				nrow=0
				ncol=8
         			datalen=12
         			maxvalue="999999999999"
         			minvalue="0"
         			dot=0
         			unableval=0
         			do inputformat         
         			if nexitflag=1
            				exit
          			endif
           		enddo
           		if ifquit=1
                        	return
                    	endif
            		ctmpstr=str(val(inputkey),12)
            		cmtnum1=""
            		i=1
         		do while i<=12
     				cmtnum1=cmtnum1+str(val(substr(ctmpstr,i,1)),1)
     				i=i+1
    			enddo 
        	else
        		inputkey=cmtnum1	
        		unozborhw=1	  &&综合编程设置表号,成功不提示!
                endif	
     		szdata{1,8}=0
    		szdata{1,1} = 52
     		szdata{2,1} = 52
    		ctmpstr = inputkey
    		m = len(ctmpstr)
    		do while m < 12
    			ctmpstr = "0" + ctmpstr
    			m = len(ctmpstr)
    		enddo
    		szdata{3,1} = numtobcd(val(right(ctmpstr,2)),33h)
    		szdata{4,1} = numtobcd(val(substr(ctmpstr,9,2)),33h)
    		szdata{5,1} = numtobcd(val(substr(ctmpstr,7,2)),33h)
    		szdata{6,1} = numtobcd(val(substr(ctmpstr,5,2)),33h)
    		szdata{7,1} = numtobcd(val(substr(ctmpstr,3,2)),33h)
    		szdata{8,1} = numtobcd(val(substr(ctmpstr,1,2)),33h)
		ctmpstr="载波表号"	
		writename="电表表号"
		ctmpstr1="电表表号"	
		corder[1]="10"	
		corder[2]="08"	
		ndatalen=08	            
		nitem=01
		ndataid1=0
		ndataid2=0	
		nchangeformat=01	
		nbackdata=00
		strdata=""                                          
	     	do hwdxwrite
		unozborhw=0	
       	return
endpro
*/---------------------------------------------------------------------\*
procedure ddsfmeterread
	      		clear    
			@1,0 say "正在抄收电表表号"  
			do clearbar
  			cSdReadRqt{1,10}=255
        		sends cSdReadRqt{1,10}
        		i=1
			cSdReadRqt{i,1}=104
       			i=i+1  
			inputkey="999999999999"
                	szaddr{1,6}=0
    			szaddr=numtobcd(val(inputkey),0)   
    			m=scanbyte(szaddr{1,6},255) 
    			if m>0         
    				szaddr{m,7-m}=0           	
   			endif 
			cSdReadRqt{i,6}=szaddr{1,6}                         
			i=i+6
			cSdReadRqt{i,1}=104
			i=i+1
			cSdReadRqt{i,1}=10
			i=i+1
			cSdReadRqt{i,1}=01
        		i=i+1
			cSdReadRqt{i,1}=52 
        		i=i+1
			j=CheckSum(cSdReadRqt{1,i-1})
			j=j-256*int(j/256)
   			cSdReadRqt{i,1}=j
        		i=i+1
			cSdReadRqt{i,1}=22
			sends cSdReadRqt{1,i}

       			nStartPos=6
			do xsbar
			strRecFlag="no"
   			receivebuf{1,100}=space(100)
   			do while i<200
				i=i+1
			enddo
   			crecbuff{1,100}=0
			*判断首起始符
				i=0
   				m=1 
   				j=0
				do while i <> 068h
					j = receives(receivebuf{1,1}, 20)
	 				if j <> 0
	   					i = receivebuf{1,1}
	  				else
	   					exit
            				endif
				enddo
    				receivebuf{m,1} = 068h
    				m=m+1   
			*截取地址
				j = receives(receivebuf{m,6}, 20)     
		       		if j<6
    					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
    					return	
   				endif   
   				i = BCDtoNUM(receivebuf{m,6}, 0)  
   				ctmpstr=str(i,12) 
        			i=1
        			cmtnum=""
   				do while i<=12
   					cmtnum=cmtnum+str(val(substr(ctmpstr,i,1)),1)
   					i=i+1
 				enddo 
				m=m+6
   				j = receives(receivebuf{m,1}, 20)
  				i = receivebuf{m,1}
  				if  i<>068h
  					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
  					return
  				endif
  				m=m+1
			*判断控制码
				j = receives(receivebuf{m,1}, 20)
      				i = receivebuf{m,1}
				if  i<>08ah.and.i<>0aah
  					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
  					return
  				endif
  				m=m+1
      			*判断数据长度
  				j = receives(receivebuf{m,1}, 20)
  				i = receivebuf{m,1}
  				if  i<>02h
  					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
  					return
  				endif
      				m=m+1
  				j = receives(receivebuf{m,2}, 20)
  				i = receivebuf{m,2}
      			*判断校验字
  				m=m+2
  				j = receives(receivebuf{m,1}, 20)
  				i = receivebuf{m,1}
  				j=CheckSum(receivebuf{1,m-1})
				j=j-int(j/256)*256
      				if i <> j
  					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
  					return
				endif
        			m=m+1
			*判断结束符
   				j = receives(receivebuf{m,1}, 20)  
 				i = receivebuf{m,1}          
   				if i <> 22
    					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
    					return
      				endif
      				strRecFlag="yes"
 				nStartPos=44
				do xsbar		                     	
    				set intensity off      	
    				if strRecFlag="no"                          
					@3,0 say "     抄收失败!     "           
    					@3,20 say ""
    					sound 12,2	
    					wait ""
    					return
    				endif
        			if strRecFlag="yes"             
        				nStartPos=82
        				do xsbar
        				sound 12,1
        				clear
        				@0,0 say "    --表号操作--    "	     			
        				@2,0 say "表号:"+cmtnum
        				wait ""
				endif
		return
endpro		    	 
*/---------------------------------------------------------------------\*
*/---------------------------------------------------------------------\* 
procedure ddsfdxwrite
	clear
	DO WHILE .T.
		szWinTitle = "单项设置"
		do ShowWindow
		aszMxItem[1] = "1.密码设置"
		aszMxItem[2] = "2.远程控制"
		aszMxItem[3] = "3.表底设置"		
		aszMxItem[4] = "4.小数位数"
		nMxItemNum = 4
		nMxChoice = 1
		do Menu
		chfMain = chr(nMxChoice+48)
		do case

⌨️ 快捷键说明

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