Switch to desktop version  
DataMailBox CSV Generator - Printable Version

+- Ewon Technical Forum (https://techforum.ewon.biz)
+-- Forum: Development (https://techforum.ewon.biz/forum-50.html)
+--- Forum: Talk2m & Argos API (https://techforum.ewon.biz/forum-54.html)
+---- Forum: DMWeb API (https://techforum.ewon.biz/forum-11.html)
+---- Thread: DataMailBox CSV Generator (/thread-183.html)



DataMailBox CSV Generator - simon - 25-11-2016

Hi,

I have developed a DataMailbox driver that generates CSV files.
This program is actually based on the "MyLittleHistorian" example provided with DataMailBox SDK.

For users : just copy the directory "ReadyToUse" in the attached zip.
For developers : All the source code is in the zip.

How to configure it ?
Copy the directory "ReadyToUse" in c:\
Create a file named "config.ini" and type your parameters. There is an example in the directory.
Here is the list of parameters available :
  • DevId:Type the DevID
  • APIToken:Type the Datamailbox API token  - Generated in eCatcher (>= 6.6.4) (Available as of ver 1.0.0.2)
  • AccountName:Type your account (No more available in 1.0.0.2)
  • Username: Type the password of your Talk2M account (No more available in 1.0.0.2)
  • Password: Type the password of your Talk2M account (No more available in 1.0.0.2)
  • DeleteData: Delete the data of the datamailbox after collecting it (yes/no). If multiple instances are collecting data on the same account, type "no"
  • CSVFileName: Name of the CSV file generated. This field can accept some dynamic keywords : %YEAR%, %MONTH%, %DAY%, %HOUR%, %EWONNAME%, %TAGNAME%. Ex : If you use %TAGNAME% in your Filename, then a different CSV file will be created for each Tag.
  • CSVTitle: Title of the each CSV file (as of ver 1.0.0.1)
  • CSVLineFormat: Format of the line in the CSV. Here are the keywords available : %EWONNAME%,%TAGNAME%,%TAGDATE%,%TAGVALUE% and %QUALITY%
  • DateTimeFormat:Format of the time and date according to https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx 
  • CSVOutputDir: Directory where the CSV files wll be stored.  The directories are automatically created. This field can accept some dynamic keywords : %YEAR%, %MONTH%, %DAY%, %HOUR%, %EWONNAME%, %TAGNAME%. Ex : If you use %EWONNAME% in your OutPutDir, then a different directory will be created for each eWON.  Keep it blank if you want to save your files in the working directory.
  • ForceRetrieveAll: Flag to force to program to retrieve all the data of the DataMailbox (TransactionID=0).
  • EwonIds: Filter your data retrieval for some Ewons Ids only.  You can set multiple Ewon Ids by separating them by a comma.  You can retrieve the Ewons list including their Ids using the command "MyCSVHistorian.exe getewonslist".  This command gonna use the credentials set in the config.ini file.
Example of config.ini :

Code:
DevId:61XXXXX64-6ade-414e-ad4e-a79dXXXX8010
APIToken:n6x2pyv0kJLAKxXPWzDJyz8N9HAz3B5E6FmZhQEFplQaJ8G1MA
DeleteData:no
CSVOutputDir:D:\Users\sdr\mydata\%YEAR%_%MONTH%_%DAY%\%EWONNAME%\
CSVTitle:Name;TagName;Date;Value;Quality
CSVFilename:%YEAR%_%MONTH%_%DAY%_%HOUR%_%EWONNAME%_%TAGNAME%.csv
CSVLineFormat:%EWONNAME%;%TAGNAME%;%TAGDATE%;%TAGVALUE%;%QUALITY%
DateTimeFormat:MM/dd/yy H:mm:ss zzz
EwonIds:123655,555445

The config.ini file is deleted at the first start (except if you simply launch a getewonslist command to read Ewon Ids).  The settings are then saved in a specific application file only accessible by the SYSTEM (Admin) user.


How to launch it ?
You can launch it manually by clicking the exe file.
Or
If you want to run it automatically, just right-click the file "installMyCSVHistorianScheduledTask.bat" and select "Run as Administrator".
This will add a new Scheduled Task in Windows.  This task will launch the program automatically even if you are not logged and will run every 5 min (Can be configured by editing the Scheduled Task).

Troubleshoot
If you don't get your data, you have a file "Log.txt" which contains the logs of the last execution.


RE: DataMailBox CSV Generator - Lonny - 12-02-2020

I need to change the config.ini but Where did it go?


RE: DataMailBox CSV Generator - simon - 14-02-2020

It removes it and create a xml config file in your user directory (If I remember well in %APPDATA%/ProgramName/filename). That's a standard .NET command


RE: DataMailBox CSV Generator - Lonny - 31-03-2020

The Generator is working perfectly but is there a way to add a header row to the file?


RE: DataMailBox CSV Generator - simon - 02-04-2020

Hi Lonny,

I have updated MyCSVHistorian in the first post to support a new parameter "CSVTitle"

Simon


RE: DataMailBox CSV Generator - Lonny - 21-09-2021

This thread has been marked as solved. If you have a similar issue, it would be better to post your own thread rather than bump this one, to help keep everybody's different issues separate.

(02-04-2020, 07:12 PM)simon Wrote: Hi Lonny,

I have updated MyCSVHistorian in the first post to support a new parameter "CSVTitle"

Simon

Simon, is it possible to use this to get alarm history as well?


RE: DataMailBox CSV Generator - simon - 27-09-2021

Hi Lonny,

No as it is. I will have to modify it.
What is your need ? What files and format would you need ?

PS : Do you use it in production ? Just to know if someone really uses it and if it works fine ;-)

Simon


RE: DataMailBox CSV Generator - Lonny - 19-11-2021

This thread has been marked as solved. If you have a similar issue, it would be better to post your own thread rather than bump this one, to help keep everybody's different issues separate.

(27-09-2021, 08:46 AM)simon Wrote: Hi Lonny,

No as it is.  I will have to modify it.
What is your need ? What files and format would you need ?

PS : Do you use it in production ? Just to know if someone really uses it and if it works fine ;-)

Simon

Simon, Yes i've been using this in production and its been working perfectly until now.  It no longer works and the error i get is 

"The request was aborted: Could not create SSL/TLS secure channel."

Can you help me get this working again please.


RE: DataMailBox CSV Generator - simon - 22-11-2021

Hi Lonny,

I have updated the tool to support TLS1.2 (ver 1.0.0.3) which is now required for connecting the Talk2M API Endpoints (Datamailbox or M2Web API).
It requires now .NET framework 4.5.

Simon


RE: DataMailBox CSV Generator - Lonny - 22-11-2021

This thread has been marked as solved. If you have a similar issue, it would be better to post your own thread rather than bump this one, to help keep everybody's different issues separate.

(22-11-2021, 05:12 PM)simon Wrote: Hi Lonny,

I have updated the tool to support TLS1.2 (ver 1.0.0.3) which is now required for connecting the Talk2M API Endpoints (Datamailbox or M2Web API).
It requires now .NET framework 4.5.

Simon

I am now getting this error message in the log.


Options and Credentials are imported from config.ini ...
YvJQGX3yOhuSZn7bD6q8STVbsR6vccdM2Oe257qNDBw7Z76wcA
Collecting the latest data...
Data received. transactionId = 359316
Tag Lafontaine.SBRAC2_AL_ARREThas no history.
3723 samples written to disk
--------------------------------------------------------------------
Oops!
The remote server returned an error: (400) Bad Request.
DataMailbox Error: at least one parameter must be specified.
--------------------------------------------------------------------


RE: DataMailBox CSV Generator - Lonny - 01-10-2023

I have been using this for quite awhile now and it works great.  I have recently upgraded my PC to win 11 and there seems to be an issue now.  It does still get the data but it is extremely slow and the command prompt window never closes since it never seems to catch up.  I am pulling data from 21 eWons every hour and before win 11, it only took a few seconds to get it all.  I started the script 3 days ago and the script has not stopped since then and the data, even though it is all there, is still 6 hours behind.  Simon, are you able to look into the win 11 compatibility?


RE: DataMailBox CSV Generator - simon - 06-10-2023

Hi Lonny,

This is very strange.

It is a .NET program. So I do not see why Win11 should be a problem.
Is the program doing something ? Do you see text files created on your disk ? What do the logs say ?


RE: DataMailBox CSV Generator - achraf - 12-04-2024

Ce fil a été marqué comme résolu. Si vous rencontrez un problème similaire, il serait préférable de publier votre propre fil de discussion plutôt que de supprimer celui-ci, afin de séparer les différents problèmes de chacun.

(25-11-2016, 06:45 PM)Simon Wrote: Bonjour,

j'ai développé un pilote DataMailbox qui génère des fichiers CSV.
Ce programme est en fait basé sur l'exemple "MyLittleHistorian" fourni avec le SDK DataMailBox.

Pour les utilisateurs : copiez simplement le répertoire "ReadyToUse" dans le zip ci-joint.
Pour les développeurs : Tout le code source est dans le zip.

Comment le configurer ?
Copiez le répertoire "ReadyToUse" dans c:\
Créez un fichier nommé "config.ini" et saisissez vos paramètres. Il y a un exemple dans le répertoire.
Voici la liste des paramètres disponibles :
  • DevId  : tapez le DevID
  • APIToken  : Tapez le jeton API Datamailbox - Généré dans eCatcher (>= 6.6.4) (Disponible à partir de la version 1.0.0.2)
  • AccountName  : Tapez votre compte (plus disponible dans la version 1.0.0.2)
  • Nom d'utilisateur : Tapez le mot de passe de votre compte Talk2M (Plus disponible en 1.0.0.2)
  • Mot de passe : Tapez le mot de passe de votre compte Talk2M (Plus disponible en 1.0.0.2)
  • DeleteData : Supprimez les données de la datamailbox après les avoir récupérées (oui/non). Si plusieurs instances collectent des données sur le même compte, tapez « non »
  • CSVFileName : Nom du fichier CSV généré. Ce champ peut accepter certains mots-clés dynamiques : %YEAR%, %MONTH%, %DAY%, %HOUR%, %EWONNAME%, %TAGNAME%. Ex : Si vous utilisez %TAGNAME% dans votre nom de fichier, alors un fichier CSV différent sera créé pour chaque balise.
  • CSVTitle  : Titre de chaque fichier CSV (à partir de la version 1.0.0.1)
  • CSVLineFormat : Format de la ligne dans le CSV. Voici les mots clés disponibles : %EWONNAME%,%TAGNAME%,%TAGDATE%,%TAGVALUE% et %QUALITY%
  • DateTimeFormat :Format de l'heure et de la date selon https://msdn.microsoft.com/en-us/library/8kb3ddd4(v=vs.110).aspx 
  • CSVOutputDir : Répertoire où seront stockés les fichiers CSV. Les répertoires sont automatiquement créés. Ce champ peut accepter certains mots-clés dynamiques : %YEAR%, %MONTH%, %DAY%, %HOUR%, %EWONNAME%, %TAGNAME%. Ex : Si vous utilisez %EWONNAME% dans votre OutPutDir, alors un répertoire différent sera créé pour chaque eWON. Gardez-le vide si vous souhaitez enregistrer vos fichiers dans le répertoire de travail.
  • ForceRetrieveAll : Flag pour forcer le programme à récupérer toutes les données de la DataMailbox (TransactionID=0).
  • EwonIds  : Filtrez la récupération de vos données pour certains identifiants Ewons uniquement. Vous pouvez définir plusieurs identifiants Ewon en les séparant par une virgule. Vous pouvez récupérer la liste des Ewons incluant leurs identifiants à l'aide de la commande "MyCSVHistorian.exe getewonslist". Cette commande va utiliser les informations d'identification définies dans le fichier config.ini.
Exemple de config.ini : Le fichier config.ini est supprimé au premier démarrage (sauf si vous lancez simplement une commande getewonslist pour lire les Ewon Ids). Les paramètres sont ensuite enregistrés dans un fichier d'application spécifique accessible uniquement par l'utilisateur SYSTEM (Admin). Comment le lancer ? Vous pouvez le lancer manuellement en cliquant sur le fichier exe. Ou si vous souhaitez l'exécuter automatiquement, cliquez simplement avec le bouton droit sur le fichier « installMyCSVHistorianScheduledTask.bat » et sélectionnez « Exécuter en tant qu'administrateur ». Cela ajoutera une nouvelle tâche planifiée dans Windows. Cette tâche lancera le programme automatiquement même si vous n'êtes pas connecté et s'exécutera toutes les 5 minutes (peut être configurée en modifiant la tâche planifiée). Dépannage Si vous ne récupérez pas vos données, vous disposez d'un fichier "Log.txt" qui contient les logs de la dernière exécution.

Code:
DevId:61XXXXX64-6ade-414e-ad4e-a79dXXXX8010
APIToken:n6x2pyv0kJLAKxXPWzDJyz8N9HAz3B5E6FmZhQEFplQaJ8G1MA
DeleteData:no
CSVOutputDir:D:\Users\sdr\mydata\%YEAR%_%MONTH%_%DAY%\%EWONNAME%\
CSVTitle:Name;TagName;Date;Value;Quality
CSVFilename:%YEAR%_%MONTH%_%DAY%_%HOUR%_%EWONNAME%_%TAGNAME%.csv
CSVLineFormat:%EWONNAME%;%TAGNAME%;%TAGDATE%;%TAGVALUE%;%QUALITY%
DateTimeFormat:MM/dd/yy H:mm:ss zzz
EwonIds:123655,555445

bonjour monsieur Simon j'ai essayé de récupérer les donner depuis ewon avec les étapes que t'a dit mais je trouve cette erreur :

Options and Credentials are importer from config.ini ...

12/04/2024 14:44:01 Collecte des dernières données...

12/04/2024 14:44:01 ---------------------------------------- ----------------------------

12/04/2024 14:44:01 Oups !

12/04/2024 14:44:01 Le serveur distant a retourné une erreur : (404) Introuvable.

12/04/2024 14:44:01 Erreur DataMailbox : aucun compte ni données pour le jeton Qvjz...
12/04/2024 14:44:01 ---------------------------------------- ----------------------------