PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2025 → Lecture des données d'un automate ADAM IP
Lecture des données d'un automate ADAM IP
Iniciado por MARC HOURIET, 11,jun. 2020 13:58 - 6 respuestas
Miembro registrado
11 mensajes
Publicado el 11,junio 2020 - 13:58
Bonjour,

J'essaye de récupérer les données d'un automate ADAM en IP mais je n'y arrive pas.

J'ai réussi à me connecter avec SocketConnecte mais après je n'ai rien au niveau du contenu exemple valeur 1 pour un canal de mon automate s'il y a le relais.

Merci de votre aide
Miembro registrado
160 mensajes
Publicado el 11,junio 2020 - 15:10
Sans voir ton code , je ne vois comment on peux t aider
Miembro registrado
11 mensajes
Publicado el 11,junio 2020 - 16:03
Bonjour,

Nom_socket est une chaîne
Port_autom est un entier
Adresse_autom est une chaîne
Nom_socket = "UDP4"
Port_autom = 5168
Adresse_autom = "10.10.9.253"


SI PAS SocketCréeUDP("UDP4", 5168) ALORS
Erreur("erreur création " + ErreurInfo(errMessage))
SINON
Info(SocketLit("UDP4", Faux))
FIN

Après j'aimerai lire l'ensemble du buffer dans un champ
Miembro registrado
160 mensajes
Publicado el 11,junio 2020 - 16:22
c'est normal que t'as aucune réponse parceque t'as rien demandé à l'automate , il faut d'abord envoyer la commande ensuite récupérer la réponse
sCommande is string // ta commande (Doc automate )
sBuffer is string // use string type not buffer
sReponseAutomate is string
IF SocketExist("UDP4") THEN
sBuffer=HexaToBuffer(sCommande)
IF SocketWrite("UDP4",sBuffer,10.10.9.253,5168)=True THEN
sReponseAutomate=SocketRead("UDP4",False,100)
sReponseAutomate=Replace(BufferToHexa(sReponseAutomate)," ","")
END
END
Miembro registrado
11 mensajes
Publicado el 11,junio 2020 - 17:28
L'automate est configuré pour m'envoyer chaque seconde les data. Avec votre code est ce que je peux decoder le résultat dans une table?
Miembro registrado
160 mensajes
Publicado el 11,junio 2020 - 17:53
Oui tu décodes les infos , ex : HexaToInt() si t as que des entiers après fait ce que tu veux avec ..
Miembro registrado
11 mensajes
Publicado el 12,junio 2020 - 07:04
Si je fais le code suivant j'ai rien dans ma table:
Nom_socket est une chaîne
Port_autom est un entier
Adresse_autom est une chaîne
Nom_socket = "UDP4"
Port_autom = 502
Adresse_autom = "10.10.8.21" //IP de l'automat


SI PAS SocketCrée("UDP4", 502) ALORS
Erreur("erreur création " + ErreurInfo(errMessage))
SINON
//Info(SocketLit("UDP4", Faux))



sCommande is string // ta commande (Doc automate )
sBuffer is string // use string type not buffer
sReponseAutomate is string
IF SocketExist("UDP4") THEN
sBuffer=HexaToBuffer(sCommande)
IF SocketWrite("UDP4",sBuffer,"10.10.8.21",502)=True THEN
sReponseAutomate = SocketRead("UDP4",False,100)
sReponseAutomate = Replace(BufferToHexa(sReponseAutomate)," ","")
END
END

TableAjoute(Table1,sReponseAutomate)



Si je fais le code suivant j'ai MADM[]0. Car le module adam envoie chaque seconde des info.

Nom_socket est une chaîne
Port_autom est un entier
Adresse_autom est une chaîne
Nom_socket = "UDP4"
Port_autom = 5168
Adresse_autom = "10.10.9.253" //mon ip


SI PAS SocketCréeUDP("UDP4", 5168) ALORS
Erreur("erreur création " + ErreurInfo(errMessage))
SINON
//Info(SocketLit("UDP4", Faux))
TableAjoute(Table1,SocketLit("UDP4"))

FIN