How to Automatically Upload AEwin .DTA Files to a Web Server Using MATLAB or Python?
10 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Hello everyone,
I am working on automating the upload of Acoustic Emission data collected via AEwin, which stores data in .DTA format. My goal is to:
- Automatically process the .DTA files generated by AEwin.
- Extract key data from these .DTA files.
- Upload this data to a web server (such as ThingSpeak or a custom server) in real-time.
What I Have Tried:
- Python: I’ve tried reading the .DTA file using the MistrasDTA Python library, and encountered the error.
- MATLAB: While I haven’t tried MATLAB yet, I am wondering if it could be a better alternative for extracting data from .DTA files and uploading it to a server.
My Questions:
- Has anyone successfully processed AEwin .DTA files in MATLAB? If so, what functions or toolboxes are recommended for this task?
- Is there a way to automate this process fully (i.e., automatically upload the data to a web server whenever a new .DTA file is created)?
- Any suggestions or examples of how to integrate this workflow between AEwin and a server would be greatly appreciated.
Thank you in advance for any help or suggestions you can offer!
5 commentaires
Réponse acceptée
Hitesh
le 4 Oct 2024
Modifié(e) : Hitesh
le 4 Oct 2024
Hi Huzaifa,
You can automate the whole process in MATLAB in three phases:
- Detection of new .DTA file
- Reading and processing .DTA Files
- Uploading Data to a Web Server
Detection of new .DTA files:
- Directory Monitoring: Use MATLAB's dir function to periodically check for new files in the directory where AEwin saves the .DTA files.
- Timer Objects: Use MATLAB's timer objects to run the directory check at regular intervals.
- For more information on "how to programmatically detect a change in a directory". Please refer to below MATLAB answer: https://www.mathworks.com/matlabcentral/answers/99277-how-do-i-programmatically-detect-a-change-in-a-directory
t = timer('TimerFcn', @checkForNewFiles, 'Period', 60, 'ExecutionMode', 'fixedRate');
start(t);
function checkForNewFiles(~, ~)
files = dir('path_to_DTA_files/*.DTA');
% Read and process file
end
Reading and processing .DTA Files:
- We can read the .dta file by copying into .txt file so that we can convert the .dta file into format readable by readtable.
filename = 'file_name.DTA';
% copy the file to a legible format
filename2 = [filename(1:end-1), 'txt'];
copyfile(filename, filename2);
% read table of legible file type
T = readtable(filename2, 'ReadVariableNames', 0);
% delete the file that we created bc we don't need it anymore
delete(filename2);
Uploading Data to a Web Server:
- Setup the URL and Request Options:URL defines the server endpoint where the data will be uploaded.Request options determines the format in which the data is being sent.
- Send Data to the Server:The "webwrite" function is used to send the jsonData to the specified URL with the defined options.
- For more information on "webwrite" and "weboptions". Pease refer to below MATLAB documentation:
- Webwrite : https://www.mathworks.com/help/matlab/ref/webwrite.html
- WebOptions : https://www.mathworks.com/help/matlab/ref/weboptions.html
url = 'http://yourserver.com/api/upload';
options = weboptions('RequestMethod', 'post', 'MediaType', 'application/json');
response = webwrite(url, jsonData, options);
2 commentaires
Christopher Stapels
le 4 Oct 2024
Since the OP intent is to use ThingSpeak, you might replace the function checkForNewFiles with a MATLAB analysis script and use the TimeControl app to replace the timer object.
Plus de réponses (0)
Communautés
Plus de réponses dans ThingSpeak Community
Voir également
Catégories
En savoir plus sur Data Import and Analysis dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!