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 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58
| #include "apdefap.h"
void Tag_Listen()
{
// chemin d'accès pour le fichier de journalisation
char FileName[255]="D:\\Project\\";
char Chaine_Ent[255];
char Nom_Var[255];
char *str;
char c=';';
char *ptr;
// Pointeur de fichier
FILE *stream;
// mémoire intermédiaire pour la variable process
WORD Tag_1;
int n=0;
// Lecture du nom du fichier "Test_Write_Var.txt"
// Ce nom peut être indiqué manuellement via un champ d'entrée/sortie.
strcat(FileName, "Test_Write_Var.txt"); //type de valeur en retour :char*
// Création/ouverture du fichier de sortie pour la journalisation.
stream = fopen( FileName, "r" );
fgets(Chaine_Ent,40,stream);
i=strlen(Chaine_Ent);
str = Chaine_Ent;
ptr = strchr(str,c);
strncpy(Nom_Var,Chaine_Ent,(ptr-str));
SetTagChar(TAG_2,Nom_Var); //Return-Type: BOOL
SetTagDWord(TAG_1,(ptr-str)); //Return-Type: BOOL
/*for (n = 0;n<40;n++)
{
}*/
// Lecture de la variable process
// type de valeur en retour :WORD
//Tag_1 = GetTagWord("PROCESS/DB_JET_TABLE_HMI.DST_6_SPD40");
//Tag_2 = GetTagWord("PROCESS/DB_JET_TABLE_HMI.DST_6_SPD42");
// Affichage de contrôle dans une fenêtre de diagnostic Global Script
printf("Contenu FileName : %s\r\n", FileName);
// Ecriture de la valeur de la variable dans un fichier
//fprintf( stream, "PROCESS/DB_JET_PRESET.ACTUAL_PRESET ; %d\r\n", Tag_1 );
//fprintf( stream, "PROCESS/DB_JET_PRESET.ACTUAL_PRESET ; %d\r\n", Tag_2 );
// Fermeture du fichier
fclose( stream );
} |
Partager