Convertir ce programme de Quick Basic [Résolu]

j78330 10 Messages postés mardi 17 septembre 2013Date d'inscription 18 juillet 2016 Dernière intervention - 17 sept. 2013 à 19:43 - Dernière réponse : sebmafate 4947 Messages postés lundi 17 février 2003Date d'inscriptionModérateurStatut 14 février 2014 Dernière intervention
- 17 sept. 2013 à 21:28
Bonjour je voudrai reécrire ce programme de Quick Basic en Charp pouvez vous m'aidez s'il vous plait ?
DECLARE FUNCTION getd% (mn%, mx!, ns!)
DECLARE SUB helpetalDET ()
DECLARE SUB mnufonc ()
DECLARE SUB ENTET (vsoft$)
DECLARE SUB config ()
DECLARE FUNCTION modbus% (fonc%, ad%, ADatah%, adatal%, lDatah!, ldatal!)
DECLARE SUB del (duree!, resultat!)
DECLARE FUNCTION getdata% (adres%, b())
DECLARE FUNCTION getbloc% (adres%, numb%)
DECLARE SUB AFFBLOC (numb%, ok%, b())
DECLARE SUB calcrc (buf!(), lbuf!, ch!, cl!, crc!)
DECLARE SUB getmes (ncom%, a%, c%, d%, e%, F%)
DECLARE SUB tetenr (numero%)
DECLARE SUB enreg (al!, eta!, P!, s!, hc!, lc!, la!, lb!)
DECLARE SUB afesclav ()
DECLARE SUB afmod3 ()
DECLARE SUB pcesclave ()
DECLARE FUNCTION esclav (D1%)
DECLARE FUNCTION MAITRE% (a%)
DECLARE FUNCTION outmes (a%, COD!, h!, l!)
DECLARE FUNCTION param% ()
DECLARE SUB progboit (D1%, COD!, h!, l!)
DECLARE SUB resmod1 ()
DECLARE FUNCTION pcmaitre% ()
DECLARE SUB testclav ()
DECLARE FUNCTION afparf2% ()
DECLARE FUNCTION parcae% ()
DECLARE FUNCTION parbrc% ()
DECLARE FUNCTION parcsc% ()
DECLARE FUNCTION PARADLIF% ()
DECLARE FUNCTION pf% ()
DECLARE SUB afmod1 ()
COMMON SHARED z%, pc%, r%, nbcom%, fret%
COMMON SHARED hadadl%, hadcae%, hadcsc%, hadbrc%
COMMON SHARED hbcsc, lbcsc, hbcae, lbcae, hbbrc, lbbrc
COMMON SHARED ALRMH, alrml, CP, raccs, salrm, SHBCSC, alct, pan
COMMON SHARED g1, G2, G3, G4, OS1, OS2, OP3, OP4, GP, GUV, gturb
COMMON SHARED RDSP, RCSP, RDPS, RCPS, OTA, OTB, otf
COMMON SHARED fich$, fich1$, nbenr%, ENR%, numfic%, fic%, index%, j%, modenr%
COMMON SHARED codeta$, P1%, admaitre%, LANG%, xc%, CONF%
COMMON SHARED numero&, hfonc&, ms!, initap%, modct, cmL
COMMON SHARED GTB, GTA, comvent, comsim, comct, comtest
Dim br(40)
ADNVSOFT$ = " 4.5 "
Index% = 65
numfic% = 2
modenr% = 2
2 On Error GoTo 7000
4 Cls

Call ENTET(ADNVSOFT$)

Call del(0.003, ms!)

nbcom% = FreeFile

If xc% = 1 Then

Open "COM1:9600,N,8,1,BIN,rs,ds,op500" For Random As #nbcom%
P1% = &H3F8
Else

Open "COM2:9600,N,8,1,BIN,RS,DS,op500" For Random As #nbcom%
P1% = &H2F8
End If
rs = INP(P1% + 4)
rts = rs And &HFE 'dtr
OUT P1% + 4, rts
a$ = ""
t# = Timer
While a$ = "" And Abs(t# - Timer) < 2

Wend


5 Cls

Rem *********************************************************
CAE = 0: BRC = 0: CSC = 0: ADL% = 0
10 Cls
g1 = 0: gturb = 0: numero& = 0
Call afmod1
t# = Timer
While Abs(t# - Timer) < 1

Wend

'pc% = 1
If PC% = 1 Then
Call afmod3
ElseIf PC% = 0 Then
Call afesclav
End If
12
Call del(0.003, ms!)
While Not EOF(nbcom%)
a$ = Input$(Loc(nbcom%), #nbcom%)
Wend
FRET% = 0
t# = Timer
While Abs(t# - Timer) < 1
Wend

TA# = Timer
While FRET% = 0
If PC% = 0 Then
Var% = 0
Temp2# = Abs(Timer - TA#)
If (Loc(nbcom%) >= 5) Then
TA# = Timer
Call pcesclave
ElseIf Temp2# > 2 Then
R% = R% + 1
Else
R% = 0
End If
If R% >= 5 Then
FRET% = 12
End If
ElseIf PC% = 1 Then 'DET. seul
te# = Abs(Timer - TA#)
If te# > 1 Then
TA# = Timer
If pcmaitre% = 0 Then
If FRET% = 0 Then
R% = 0
End If
Else
R% = R% + 1
If FRET% <> 10 Then
FRET% = 12
End If
End If
End If
End If
LOCATE 1, 12: Print Time$;
LOCATE 1, 65
If PC% = 1 Then
If lang% = 0 Then
Print " PC MAITRE ";
Else
Print " PC MASTER ";
End If
hbcsc = 255: lbcsc = 255: lbcae = 255: lbbrc = 255
Else
If lang% = 0 Then
Print " PC ESPION ";
Else
Print " PC SPYING ";
End If

End If
a = (alrml = salrm)
b = (CP = scp)
c = (raccs = sraccs)
d = (hbcsc = SHBCSC)
e = (lbcsc = slbcsc)
f = (lbcae = slbcae)
g = (lbbrc = slbbrc)
t# = Abs(Timer - TENR#)
If modenr% = 1 Then
If t# >= 1 Then
okenr% = 1: rep = 1
Else
okenr% = 0
End If
Else
If a And b And c And d And e And f And g Then
okenr% = 0
Else
okenr% = 1
End If
End If
salrm = alrml
scp = CP
sraccs = raccs
SHBCSC = hbcsc
slbcsc = lbcsc
slbcae = lbcae
slbbrc = lbbrc
If Date$ <> d$ Then
j% = 1
d$ = Date$
LOCATE 1, 1: Print Date$; " ";
okenr% = 1
End If
Call testclav
If ENR% <> 0 Then
If j% = 1 Then
ficok% = 0: Index% = 65
While ficok% = 0
fich$ = Mid$(Date$, 4, 2) + Left$(Date$, 2) + Chr$(Index%)
fich1$ = fich$
Open fich1$ + ".Adn" For Append As #numfic%
If Loc(numfic%) <> 0 Then
Close #numfic%
Index% = Index% + 1
Else
Call tetenr(numfic%)
Close #numfic%
TENR# = Timer: ficok% = 1: fic% = 0: nbenr% = 0
okenr% = 1: j% = 0
End If
Wend
End If
Open fich1$ + ".Adn" For Append As #numfic%
If okenr% = 1 Then
If Loc(numfic%) * 128 >= 60000 Then
Close #numfic%
fic% = fic% + 1
nbenr% = 0: fich1$ = fich$ + LTrim$(Str$(fic%))
Open fich1$ + ".Adn" For Append As #numfic%
Call tetenr(numfic%)
End If
Call enreg(ALRMH, alrml, CP, raccs, hbcsc, lbcsc, lbcae, lbbrc)

TENR# = Timer
dejafait% = 0
nbenr% = nbenr% + 1
End If

Close #numfic%
LOCATE 24, 1
If modenr% = 1 Then
Print "(cont) ";
Else
Print "(chg) ";
End If
Print fich1$ + ".ADN ";
If lang% = 0 Then
Print "Nbr.enrgt."; nbenr%; " ";

Else
Print "rec. nbr. "; nbenr%; " ";

End If


End If
Wend
7000
If Err <> 0 Then
rs = INP(P1% + 4)
rts = rs And &HFE 'dtr
OUT P1% + 4, rts


If Err = 61 Then
LOCATE 24, 30: Close #numfic%: ENR% = 0
If lang% = 0 Then

Print "DISQUETTE PLEINE !";
Else

Print "DISK FULL ! ";
End If


Resume Next
ElseIf Err = 64 Then
Resume Next
ElseIf Err = 69 Then
While Not EOF(nbcom%)
a$ = Input$(1, #nbcom%)
Wend
Resume Next
ElseIf (Err = 57) Or (Err = 24) Then
R% = R% + 1

If Loc(nbcom%) = 0 Then
Close #nbcom%
Resume 5

Else
Resume Next
End If
ElseIf Err = 52 Then
Cls
If lang% = 0 Then
Print "Nom ou num'ro de fichier incorrect"

Else
Print "Incorrect name or file number "

End If


Reset

End
Else
BEEP
Resume Next
End If
ElseIf R% >= 3 Then
rs = INP(P1% + 4)
rts = rs And &HFE 'dtr
OUT P1% + 4, rts
' pc% = 0
Cls
If lang% = 0 Then
Print " VEUILLEZ VERIFIER L'ETAT DU RESEAU OU LE DETECTEUR "
Print
Print " APPUYER SUR ' ECHAP ' POUR STOPPER"
Print
Print:
Print
Print " TOUCHE F1: PC maOEtre "
Print: Print
Print " TOUCHE F2: ParamStres du systSme de d'tection"
Print
Print " TOUCHE F3: Configuration du programme ";
Print: Print: Print
Print " actuellement, le PC est ";
If PC% = 0 Then
Print " ESPION "
ElseIf PC% = 1 Then
Print " MAITRE "
End If
Else
Print " PLEASE VERIFY DETECTOR OR NETWORK STATE "
Print
Print " STRIKE 'ESC' KEY TO END PROGRAM "
Print
Print:
Print
Print " F1: PC master "
Print: Print
Print " F2: Detection system settings "
Print
Print " F3: Program settings ";
Print: Print: Print
Print " Actually, PC is ";
If PC% = 0 Then
Print " SPYING "
ElseIf PC% = 1 Then
Print " MASTER "
End If
End If


hadadl% = 161


salrm = 0: CAE = 0: BRC = 0: CSC = 0: ADL% = 0
FRET% = 0
b$ = ""
While Not EOF(nbcom%)
a$ = Input$(Loc(nbcom%), #nbcom%)
Wend
While b$ = "" And FRET% = 0
Call del(0.003, ms!)
Close #nbcom%
temp1# = Timer
While (Abs(temp1# - Timer) < 0.2)
Wend
If xc% = 1 Then

Open "COM1:9600,N,8,1,BIN,rs,ds,op500" For Random As #nbcom%
P1% = &H3F8
Else

'OPEN "COM2:9600,N,8,1,BIN,RS,DS,op500" FOR RANDOM AS #nbcom%
Open "COM2:9600,N,8,1,BIN,RS,DS,op500,TB128" For Random As #nbcom%
P1% = &H2F8
End If
rs = INP(P1% + 4)
rts = rs And &HFE 'dtr
OUT P1% + 4, rts

TA# = Timer: TX1# = 0
While TX1# < 2
'rs = INP(P1% + 4)
'rts = rs AND &HFE 'dtr
'OUT (P1% + 4), rts

temp1# = Timer
While (Abs(temp1# - Timer) < 0.2)
Wend
If Loc(nbcom%) < 5 Then
If PC% = 1 Then
temp1# = Timer: Var% = 0
While (Loc(nbcom%) < 5) And Var% = 0
If (Abs(temp1# - Timer) > 0.3) Then
Var% = 1
End If
Wend
' ret% = outmes(admaitre%, 86, 0, 0)
' temp1# = TIMER
' WHILE (ABS(temp1# - TIMER) < .2)
' WEND

ret% = modbus%(3, hadadl%, 0, 15, 0, 15)
Else
ret% = 0: ct% = 0
a$ = Input$(Loc(nbcom%), #nbcom%)
While ret% = 0
Var% = 0
temp1# = Timer
While (Loc(nbcom%) = 0) And Var% = 0
If (Abs(temp1# - Timer) > 0.2) Then
Var% = 1
End If
Wend
If Loc(nbcom%) = 0 Then
ret% = 1
Else
ct% = ct% + 1
If ct% > 5 Then
ret% = 2
End If
End If
Wend
'CALL del(.003, ms!)
If ret% = 1 Then
ret% = outmes(admaitre%, 86, 255, 0)
Else
FRET% = 1
End If
End If
TX1# = Abs(Timer - TA#)
b$ = INKEY$
If b$ = Chr$(27) Then
Cls
Close
End
ElseIf b$ = Chr$(0) + Chr$(59) Then
If MAITRE%(admaitre%) <> 3 And PC% = 1 Then
FRET% = 10
TX1# = 6
End If
ElseIf b$ = Chr$(0) + Chr$(63) Then
If esclav(admaitre%) <> 3 And PC% = 0 Then
FRET% = 10
TX1# = 6
End If
ElseIf b$ = Chr$(0) + Chr$(60) Then
f = param%
FRET% = 10
TX1# = 6
ElseIf b$ = Chr$(0) + Chr$(61) Then 'F3
Call config
FRET% = 10
TX1# = 6

End If

Else
If Loc(nbcom%) >= 5 Then
AD1% = 0
Call getmes(nbcom%, AD1%, rcode%, rhb%, rlb%, rchk%)
If AD1% = admaitre% Then
'IF rhb% = 0 AND rlb% = 128 THEN
If rlb% = 128 Then
rcs% = rcs% + 1
Else
rcs% = 0
End If
If rcs% >= 2 Then
LOCATE 15, 23
If lang% = 0 Then
Print "! BoOEtier MAITRE sur ARRET !";
Else
Print "! MASTER case is OFF !";
End If

End If
ElseIf AD1% = hadadl% Then
TX1# = 6
FRET% = 1
Else
a$ = Input$(Loc(nbcom%), #nbcom%)
temp1# = Timer
Var% = 0
End If
End If
End If

Wend
If EOF(nbcom%) Then
If ENR% = 1 And dejafait% = 0 Then
Open fich1$ + ".Adn" For Append As #numfic%
Call enreg(0, 0, 0, 0, 0, 0, 0, 0)
Close #numfic%
dejafait% = 1
End If
End If
Wend
TA# = Timer
R% = 0: Cls
End If
If FRET% = 12 Then
GoTo 12
Else
GoTo 10
End If

End

Sub config()
R$ = ""
While R$ <> Chr$(27)
Cls
Print
Print
If lang% = 0 Then
Print " Configuration du programme "
Else
Print " Software configuration "
End If
Print
Print
Print

Print
Select Case CONF%
Case 0
Print " 1: Detect. +CAE+CSC+BRC"
Case 1
Print " 1: Detect. +CAE "
Case 2
Print " 1: Detect. "
End Select
Print
Print
If lang% = 0 Then
Print " 2: Langue fran#aise "
Else
Print " 2: English language"
End If
Print
If lang% = 0 Then
Print " 3: Port de communication COM"; xc%
Else
Print " 3: Communication port COM"; xc%
End If

Print
Print
Print

Print
'LOCATE 15, 1
If lang% = 0 Then
Print " Utiliser les touches 1, 2 ou 3 pour modifier la configuration "
Print
Print " Appuyer sur la touche 'ESC' pour valider la configuration actuelle "

Else
Print " Use the 1, 2 or 3 keys to modify the configuration "
Print
Print " Strike 'ESC' to validate actual configuration "
End If

R$ = ""
While R$ <> "1" And R$ <> "2" And R$ <> "3" And R$ <> Chr$(27)
R$ = INKEY$
Wend
If R$ = "1" Then

CONF% = CONF% + 1
If CONF% >= 3 Then CONF% = 0

ElseIf R$ = "2" Then

If lang% = 0 Then
lang% = 1
Else
lang% = 0
End If
ElseIf R$ = "3" Then
If xc% = 1 Then
xc% = 2
Else
xc% = 1
End If
End If
Wend


num% = FreeFile
Open "ADN.cfg" For Output As #num%
hadadl% = 161
Write #num%, CONF%, hadadl%, hadcsc%, hadcae%, hadbrc%, lang%, xc%
Close #num%
If CONF% = 0 Then
PC% = 0: admaitre% = hadcsc%
ElseIf CONF% = 1 Then
PC% = 0: admaitre% = hadcae%
Else
PC% = 1: admaitre% = 100
End If

End Sub

Sub ENTET(vsoft$)
CFG% = FreeFile
100
Open "ADN.cfg" For Input As #CFG%
If Erl = 100 Then
Close #CFG%
CONF% = 0
xc% = 1
hadadl% = 161
hadcsc% = 162
hadcae% = 164
hadbrc% = 168

lang% = 1
'BEEP
Call config
Else
Input #CFG%, CONF%, hadadl%, hadcsc%, hadcae%, hadbrc%, lang%, xc%
End If
Close #CFG%
If CONF% = 0 Then
PC% = 0: admaitre% = hadcsc%
ElseIf CONF% = 1 Then
PC% = 0: admaitre% = hadcae%
Else
PC% = 1
End If
Cls '
Print " "
Print " "
Print " "
If lang% = 0 Then
Print " Logiciel de communication ADN3.EXE ( Version ";
Color 0, 7: Print vsoft$;: Color 7, 0: Print " ) "
Print " "
Print " "
Print " Ensemble de d'tection des agressifs chimiques "
Else
Print " Communication software ADN3.EXE ( Version ";
Color 0, 7: Print vsoft$;: Color 7, 0: Print " ) "
Print " "
Print " "
Print " Chemical warfare detection set "
End If

Print " "
Print " "



LOCATE 15, 1
If lang% = 0 Then
Print " Configuration actuelle ";
Else
Print " Actual configuration ";
End If

Print
Print
Select Case CONF%
Case 0
Print " Detect. + CAE + CSC + BRC "
Case 1
Print " Detect. + CAE "
Case 2
Print " Detect. "
End Select
Print
If lang% = 0 Then
Print " Port de communication : COM";
Else
Print " Communication port : COM";
End If
Print xc%



t# = Timer
While Abs(Timer - t#) < 1
Wend

End Sub

DefInt A-Z
Function getd(mn, mx!, ns!)
If lang% = 0 Then
Print "Nouvelle valeur ("; mn; "-"; mx!; "):";
Else
Print "Enter new value ("; mn; "-"; mx!; "):";
End If
li = CSRLIN: col = POS(0)
ns! = -1: ok = 0: i = 0
While (ns! < mn Or ns! > mx!) And ok = 0
If i <> 0 Then
BEEP: i = 0
End If
ns$ = ""
LOCATE li, col
While i < 6
c$ = ""
While c$ = ""
c$ = INKEY$
Wend
If c$ >= "0" And c$ <= "9" Then
ns$ = ns$ + c$
Print c$;
Else
If c$ = Chr$(13) Then
i = 6
ElseIf c$ = Chr$(27) Then
i = 6: ns$ = ""
ElseIf c$ = Chr$(8) Then
i = 6: ns$ = ""
Else
BEEP
i = 6: ns$ = ""
End If
End If
Wend
If ns$ = "" Then
ok = 1
Else
ns! = Val(ns$)
End If
Wend
getd = ok
End Function

DefSng A-Z
Sub helpetalDET()
Cls
If lang% = 0 Then
Print " TOUCHES de CONTROLE et ETALONNAGE DETECTEUR "
Print
Print " ECHAP------> SORTIE DU MENU"
Print ""
Print " "
Print " F4 : simulation S et P S: Valeur de simulation soufre "
Print " 1: G1,gain filtre pied soufre P: Valeur de simulation phosphore"
Print " 2: G2,gain filtre pic soufre F: M/A ventilateur "
Print " 3: G3,gain filtre pic phosphore T: Test simili ADLIF "
Print " 4: G4,gain filtre pied phosphore U: Nombre d'heures "
Print " 5: offset 1: OS1, pieds soufre V: niveau UV "
Print " 2: OS2, pic soufre X: tension de turbine "
Print " 6: offset 3: OP3, pic phosphore B: gain temp'rature br-leur "
Print " 4: OP4, pieds phosphore A: gain temp'rature ambiante "
Print " 7: gain soufre (x G1 et G2) G: gain pression atmosph'rique "
Print " 8: gain phosphore (x G3 et G4) O: offset pression atmosph'rique "
Print " 9: seuils validation S et P D: correction d'rive pression "
Print " J: r'jection P > S N: num'ro du d'tecteur "
Print " H: r'jection S > P Alt+N: num'ro de s'rie d'tecteur "
Print " "
Else
Print " DETECTOR CONTROL AND SETTINGS KEYS "
Print
Print " ESC ------> EXIT this menu"
Print ""
Print " "
Print " F4 : S and P simulation S: Sulphur simulation value "
Print " 1: G1,Sulphur toe filter gain P: Phosphorus simulation value "
Print " 2: G2,Sulphur peak filter gain F: external air fan ON/OFF "
Print " 3: G3,Phosphorus peak filter gain T: Adlif detection test "
Print " 4: G4,Phosphorus toe filter gain U: hours number "
Print " 5: offset 1: OS1, Sulphur toe V: UV level gain "
Print " 2: OS2, Sulphur peak X: air circulator gain "
Print " 6: offset 3: OP3, Phosphore peak B: burner temperature gain "
Print " 4: OP4, Phosphore toe A: ambient temperature gain "
Print " 7: Sulphur gain (x G1 et G2) G: atm. pressure gain "
Print " 8: Phosphorus gain (x G3 et G4) O: atm. pressure offset "
Print " 9: validation thresholds S et P D: atm. pressure drift correction"
Print " J: rejection P > S N: Detector number "
Print " H: rejection S > P Alt+N: Detector serial number "
Print " "
End If
End Sub

Sub mnufonc()
Cls
If lang% = 0 Then
Print " TOUCHES DE FONCTION DU PROGRAMME "
Print
Print " ECHAP---> Sortie du programme et/ou des menus"
Print
Print " F1-----> PC MAITRE lecture des variables du d'tecteur "
Print " F2-----> PC MAITRE paramStres boOEtiers et d'tecteur"
Print
Print " F3-----> Raz des alarmes CT "
Print " F4-----> Test simulation S et P"
If PC% = 1 Then
Print " S--> valeur soufre P--> valeur phosphore"
End If
Print
Print " F5------> CONFIGURATION du programme"
Print " F6------> ACCES ... des menus d'aide"
Print
Print " F9------> ENREGISTREMENT des donn'es"
Print " F10-----> Mode d'enregistrement"
If (initap% And &HFC) = 0 Then
Print
Print " T-------> Test interne d'tection ADLIF"
Print " F-------> commande du ventilateur ext'rieur"
End If
Print
If PC% = 1 Then
Print " E-------> code d'accSs param'trage"

If codeta$ = "APSET" Then
Print
Print " 7 : gain final soufre (100 = x1,00) X : gain circulateur air"
Print " 8 : gain final phosphore (100 = x1,00) V : gain niveau UV ";
End If
End If





Else
Print " PROGRAM FUNCTION KEYS "
Print
Print " ESC------> EXIT PROGRAM and/or menus"
Print
Print " F1-------> PC MASTER detector data read only "
'PRINT
Print " F2-------> PC MASTER Cases and detector settings "
Print
Print " F3-------> CT alarm reset"
'PRINT
Print " F4-------> Simulation test S and P"
If PC% = 1 Then
Print " S-> sulphur value, P-> phosphorus value"
End If
Print
Print " F5-------> Program settings "
Print " F6-------> Help menus access "
Print
Print " F9-------> Data recording"
Print " F10------> Record mode"

If (initap% And &HFC) = 0 Then
Print
Print " T--------> ADLIF detection testing"
Print " F--------> External air fan toggle"
End If
Print
If PC% = 1 Then
Print " E--------> Access code for detector settings"
'PRINT

If codeta$ = "APSET" Then
Print
Print " 7 : Sulphur final gain (100 = x1,00) X : circulator gain "
Print " 8 : Phosphorus final gain (100 = x1,00) V : UV level gain ";
End If
End If




End If



End Sub

Static Sub pcesclave()
temp1# = Timer
Var% = 0
ad = 0
z% = 0
While ad = 0

t# = Timer
While (Abs(Timer - t#) < 1) And EOF(nbcom%)
Wend

If Abs(Timer - t#) >= 1 Then
ad = 1
R% = R% + 1
Else
While (Not (EOF(nbcom%))) And ad = 0
AD1% = Asc(Input$(1, #nbcom%))
hadadl% = 161
If AD1% = hadadl% Or AD1% = hadcae% Or AD1% = hadbrc% Or AD1% = hadcsc% Then
ad = 1
End If
Wend
End If
Wend
t# = Timer
While Abs(Timer - t#) < 0.05
Wend

If AD1% = hadadl% And Loc(nbcom%) >= 3 Then
code = Asc(Input$(1, #nbcom%))
adrh = Asc(Input$(1, #nbcom%))
adrl = Asc(Input$(1, #nbcom%))

If code = 3 And adrl = 20 And Loc(nbcom%) >= 4 Then
ndh = Asc(Input$(1, #nbcom%))
ndl = Asc(Input$(1, #nbcom%))
ch = Asc(Input$(1, #nbcom%))
cl = Asc(Input$(1, #nbcom%))
Rem ********************************* (demande du csc)
If admaitre% = hadcsc% Then
CSC = 1: radl = radl + 1
Else
CAE = 1: radl = radl + 1

End If
ElseIf code = 3 And adrh = 6 Then
t# = Timer: v = 0
While Loc(nbcom%) < 7 And v = 0
If Abs(Timer - t#) > 0.3 Then
v = 1
End If
Wend


If (Loc(nbcom%) >= 7) And v = 0 Then

'CP = (pf% + (ASC(INPUT$(1, #nbcom%)))) / 16
br(13) = adrl
br(14) = Asc(Input$(1, #nbcom%))

'raccs = (pf% + ASC(INPUT$(1, #nbcom%))) * 10
br(15) = Asc(Input$(1, #nbcom%))
br(16) = Asc(Input$(1, #nbcom%))

'ALRMH = ASC(INPUT$(1, #nbcom%))
'ALRML = ASC(INPUT$(1, #nbcom%))
br(17) = Asc(Input$(1, #nbcom%))
br(18) = Asc(Input$(1, #nbcom%))

ch = Asc(Input$(1, #nbcom%))
cl = Asc(Input$(1, #nbcom%))
radl = 0: ADL% = 1
Call AFFBLOC(1, ret%, br())
'adn3 envoi commande aprSs r'ception cae
If comvent = 1 Then

If vent = 0 Then
adh% = 0: ADL% = 5: hb = &HFF: lb = 0
vent = 1
Else
adh% = 0: ADL% = 5: hb = 0: lb = 0
vent = 0
End If
comvent = 0
ret% = modbus%(5, hadadl%, adh%, ADL%, hb, lb)
ElseIf comsim = 1 Then
adh% = 0: ADL% = 0: hb = &HFF: lb = 0
comsim = 0
ret% = modbus%(5, hadadl%, adh%, ADL%, hb, lb)
ElseIf comct = 1 Then
adh% = 0: ADL% = 15: hb = &HFF: lb = 0
comct = 0
ret% = modbus%(5, hadadl%, adh%, ADL%, hb, lb)
ElseIf comtest = 1 Then
adh% = 0: ADL% = 1: lb = 0

If (comteston = 1) And (alrml And &H1 = 1) Then
hb = &H0
comteston = 0
Else
comteston = 1

hb = &HFF

End If
comtest = 0
ret% = modbus%(5, hadadl%, adh%, ADL%, hb, lb)
End If


End If
End If
If radl >= 3 Then
ADL% = 0
End If
ElseIf AD1% = hadcae% Then
code = Asc(Input$(1, #nbcom%))
If code = &H55 Then
hb = Asc(Input$(1, #nbcom%))
lb = Asc(Input$(1, #nbcom%))
chk = Asc(Input$(1, #nbcom%))
CSC = 1
hbcsc = hb: lbcsc = lb
rcae = rcae + 1

ElseIf code = &HD5 Then
rhb% = Asc(Input$(1, #nbcom%))
rlb% = Asc(Input$(1, #nbcom%))
rchk% = Asc(Input$(1, #nbcom%))
rcae = 0: CAE = 1
hbcae = rhb%: lbcae = rlb%

Else
rhb% = Asc(Input$(1, #nbcom%))
rlb% = Asc(Input$(1, #nbcom%))
rchk% = Asc(Input$(1, #nbcom%))
rcae = 0: CAE = 1
hbcae = rhb%: lbcae = rlb%

End If
If rcae >= 3 Then
CAE = 0
End If
ElseIf AD1% = hadbrc% Then
code = Asc(Input$(1, #nbcom%))
If code = &H55 Then
hb = Asc(Input$(1, #nbcom%))
lb = Asc(Input$(1, #nbcom%))
chk = Asc(Input$(1, #nbcom%))
CSC = 1
hbcsc = hb: lbcsc = lb
rbrc = rbrc + 1
ElseIf code = &HD5 Then '213
rhb% = Asc(Input$(1, #nbcom%))
rlb% = Asc(Input$(1, #nbcom%))
rchk% = Asc(Input$(1, #nbcom%))
rbrc = 0: BRC = 1
hbbrc = rhb%: lbbrc = rlb%
Else
rhb% = Asc(Input$(1, #nbcom%))
rlb% = Asc(Input$(1, #nbcom%))
rchk% = Asc(Input$(1, #nbcom%))
rbrc = 0: BRC = 1
hbbrc = rhb%: lbbrc = rlb%
End If
If rbrc >= 3 Then
BRC = 0
End If
ElseIf AD1% = hadcsc% Then
code = Asc(Input$(1, #nbcom%))
hb = Asc(Input$(1, #nbcom%))
lb = Asc(Input$(1, #nbcom%))
chk = Asc(Input$(1, #nbcom%))
CSC = 1
hbcsc = hb: lbcsc = lb
End If

LOCATE 8, 5
If ADL% = 1 Then
Print " DET. OK";
Else
Print "! DET. ?";
ALRMH = 0: alrml = 0
' LOCATE 5, 1
' PRINT USING "Ah### "; ALRMH;
' PRINT USING "Al### "; alrml;
LOCATE 3, 34: Print USING; "#####"; 0;
LOCATE 4, 34: Print USING; "#####.##"; 0;
' LOCATE 2, 63: PRINT " ----------- ";
' LOCATE 3, 63: PRINT " ----------- ";
LOCATE 4, 49: Print " ";
LOCATE 2, 1: Print Space$(80);
LOCATE 5, 1: Print Space$(80);

End If

LOCATE 12, 5
If CONF% <> 2 Then
If CAE = 1 Then
Print " CAE OK"; " ";
Else
Print "! CAE ?"; " ";
hbcae = 0: lbcae = 0
End If
End If
If CONF% = 0 Then
Print USING; " ### "; hbcae;
Print USING; " ### "; lbcae;
End If

LOCATE 15, 5
If CONF% = 0 Then
If CSC = 1 Then
Print " CSC OK"; " ";
Else
Print "! CSC ?"; " ";
hbcsc = 0: lbcsc = 0
End If
Print USING; " ### "; hbcsc;
Print USING; " ### "; lbcsc;


LOCATE 18, 5
If BRC = 1 Then
Print " BRC OK"; " ";
Else
Print "! BRC ?"; " ";
hbbrc = 0: lbbrc = 0
End If
Print USING; " ### "; hbbrc;
Print USING; " ### "; lbbrc;
Else
Print Space$(30);
LOCATE 18, 5
Print Space$(30);
End If
End Sub

Static Function pcmaitre%()
LOCATE 1, 21: Print "*";
ret% = 0
While Not EOF(nbcom%)
a$ = Input$(1, #nbcom%)
Wend
Rem *************************************************************
blocetat% = 1
blocvar% = 2
blocphos% = 3
blocsouf% = 4
blocparopto% = 5
blocparmes% = 6
blocel% = 7
blocfonc% = 8
blocident% = 9
If numero& = 0 Or hfonc = 0 Then
ret% = getbloc%(hadadl%, blocident%)
ret% = getbloc%(hadadl%, blocfonc%)
End If
If g1 = 0 Or gturb = 0 Then
ret% = getbloc%(hadadl%, blocparopto%)
ret% = getbloc%(hadadl%, blocparmes%)
End If
If FRET% = 0 Then
ret% = getbloc%(hadadl%, blocetat%)
End If
If FRET% = 0 Then
ret% = getbloc%(hadadl%, blocvar%)
End If
If FRET% = 0 Then
ret% = getbloc%(hadadl%, blocsouf%)
End If
If FRET% = 0 Then
ret% = getbloc%(hadadl%, blocphos%)
End If
If FRET% = 0 Then
If (initap% And &HFC) = 0 Then
ret% = getbloc%(hadadl%, blocel%)
End If
End If
Rem *************************************************************
LOCATE 25, 1
If codeta$ = "STRAD" Or codeta$ = "APSET" Then
If lang% = 0 Then
Print "Etalonnage autoris'";
Else
Print "Settings enabled ";
End If
Else
Print " ";
End If
pcmaitre% = ret%
End Function

Static Sub testclav()
X$ = UCase$(INKEY$)
FCT = 6
adresse% = 161 ' hadadl%
adh% = &H5B
ADL% = &HFF
a$ = ""
LOCATE 24, 1
' acces global
Select Case X$


Case Chr$(0) + Chr$(59) 'F1
If MAITRE%(admaitre%) <> 3 And PC% = 1 Then
FRET% = 10
Else
BEEP
End If

Case Chr$(0) + Chr$(60) ' F2
If ENR% = 1 Then
Open fich1$ + ".Adn" For Append As #numfic%
Call enreg(254, 254, 254, 254, 254, 254, 254, 254)
Close #numfic%
End If
f = param%

Case Chr$(0) + Chr$(61) 'F3 raz CT
If PC% = 1 Then
FCT = 5
adh% = 0: ADL% = 15: hb = &HFF: lb = 0
Else
comct = 1
End If

Case Chr$(0) + Chr$(62) 'F4 simul C
If PC% = 1 Then
FCT = 5
adh% = 0: ADL% = 1: lb = 0

If cmL And &H1 = 1 Then
hb = &H0
Else
hb = &HFF
End If
Else
comtest = 1
End If

Case Chr$(0) + Chr$(63) 'F5
Call config
FRET% = 10


Case Chr$(0) + Chr$(67) 'F9
If fich$ <> "" Then
ENR% = 0: nbenr% = 0: fich$ = ""
LOCATE 24, 1: Print Space$(80);
Else
salrm = 0: slbcsc = 0
ENR% = 1: j% = 1
End If

Case Chr$(0) + Chr$(68) 'F10
Cls
If lang% = 0 Then
Print "Mode d'enregistrement des fichiers :"
Print
Print " 1: enregistrement continu toutes les secondes (cont)"
Print
Print " Longueur d'un fichier 60 Koctets"
Print " ! 150 Ko / 1 heure : 2,5 fichiers"
Print " ! 3600 Ko / 24 heures : 60 fichiers"
Print " ! 28,8 Mo / 8 jours : 480 fichiers"
Print
Print " 2: enregistrement sur changement d''tat uniquement (chgt)"
Print
Print " Mode par d'faut"
Print: Print
Print " Actuellement le mode est : ";
Else
Print "Data file record mode :"
Print
Print " 1: Continuous record every seconds (cont)"
Print
Print " File length 60 Kbytes "
Print " ! 150 Ko / 1 hour : 2,5 files "
Print " ! 3600 Ko / 24 hours : 60 files "
Print " ! 28,8 Mo / 8 days : 480 files "
Print
Print " 2: Record if device state changes only (chg) "
Print
Print " Default mode"
Print: Print
Print " Actually mode is ";
End If
If modenr% = 1 Then
If lang% = 0 Then
Print "continu "
Else
Print "continuous"
End If
Else
If lang% = 0 Then
Print "changement d''tat"
Else
Print "state change"
End If
End If
R$ = ""
While R$ <> "1" And R$ <> "2" And R$ <> Chr$(27)
R$ = INKEY$
Wend
If R$ = "1" Then
modenr% = 1
ElseIf R$ = "2" Then
modenr% = 2
End If
salrm = 255
SHBCSC = 255
TENR# = Timer
FRET% = 10: numb% = 0

Case "F"
If (initap% And &HFC) = 0 Then
LOCATE 24, 1: Print Space$(80);
LOCATE 24, 1
If PC% = 1 Then
FCT = 5
If vent = 0 Then
adh% = 0: ADL% = 5: hb = &HFF: lb = 0
vent = 1
Else
adh% = 0: ADL% = 5: hb = 0: lb = 0
vent = 0
End If
Else
comvent = 1
End If
If lang% = 0 Then
Print "Commute ventilateur externe ON/OFF";
Else
Print "Toggle external air fan ON/OFF";
End If
Else
adh% = 0: ADL% = 5: hb = 0: lb = 0
vent = 0

End If


Case "T"
If (initap% And &HFC) = 0 Then
LOCATE 24, 1: Print Space$(80);
LOCATE 24, 1
If lang% = 0 Then
Print "TEST d'tection ADLIF ";
Else
Print "ADLIF detection testing ";
End If
If PC% = 1 Then
FCT = 5
adh% = 0: ADL% = 0: hb = &HFF: lb = 0
Else
comsim = 1
End If
Else <
Afficher la suite 

2 réponses

Répondre au sujet
NHenry 14129 Messages postés vendredi 14 mars 2003Date d'inscriptionModérateurStatut 19 avril 2018 Dernière intervention - 17 sept. 2013 à 20:12
0
Utile
Merci d'utiliser la coloration syntaxique.

Recopier un programme sans en comprendre le fonctionnement n'est pas toujours une bonne idée.
Commenter la réponse de NHenry
sebmafate 4947 Messages postés lundi 17 février 2003Date d'inscriptionModérateurStatut 14 février 2014 Dernière intervention - 17 sept. 2013 à 21:28
0
Utile
Bonjour,

On n'est pas là pour convertir ton programme.
Par contre, si tu rencontres des problèmes sur certains points nous pouvons t'aider.

Sébastien
Commenter la réponse de sebmafate

Vous n'êtes pas encore membre ?

inscrivez-vous, c'est gratuit et ça prend moins d'une minute !

Les membres obtiennent plus de réponses que les utilisateurs anonymes.

Le fait d'être membre vous permet d'avoir un suivi détaillé de vos demandes et codes sources.

Le fait d'être membre vous permet d'avoir des options supplémentaires.