1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| If UNIT(Index).communication = False Then 'si ports ouverts, fermeture
Port1 = Trim(Str(UNIT(Index).portcom))
Port2 = Trim(Str(UNIT(Index).portvirt))
Port1 = "COM" + Port1 'mise en forme
Port2 = "COM" + Port2
Call CreatePair(Port1, Port2) 'création de la paire de port com
otimer = Timer 'attente de création
While (CreatePair(Port1, Port2) = False) And (Abs(otimer - Timer) < 1)
Wend
Open App.Path + "\Portcom" For Output As #1 'écriture port com pour récupération par l'exploitation
Print #1, Trim(Str(UNIT(Index).portcom)) 'valeur de portcom avec lequel le logiciel d'exploitation doit s'ouvrir
Print #1, Trim(UNIT(Index).ident) 'identifiant que le logiciel doit reconnaître
Close #1
Call CONNEXION_com2(Index) 'connexion au port virtuel correspondant au num du matériel
Command3(Index).Picture = LoadPicture(App.Path + "\connexion_ok1.bmp")
UNIT(Index).communication = True 'indicateur de communication à true
'Lancement du prog d'exploitation correspondant au système
chemin = App.Path + "\" + UNIT(Index).exploitation 'chemin de l'executable
retval = Shell(chemin, 1)
Else
UNIT(Index).communication = False 'si la paire était ouverte on la ferme
Command3(Index).Picture = LoadPicture(App.Path + "\connexion_no1.bmp")
Port1 = Trim(Str(UNIT(Index).portcom)) 'récupération de la paire de ports
Port2 = Trim(Str(UNIT(Index).portvirt))
Port1 = "COM" + Port1 'mise en forme
Port2 = "COM" + Port2
MSComm2(Index).PortOpen = False
Call DeletePair(Port1)
otimer = Timer 'attente de suppression
While (DeletePair(Port1) = False) And (Abs(otimer - Timer) < 1)
Wend
End If |
Partager