How to Automatically Upload AEwin .DTA Files to a Web Server Using MATLAB or Python?
조회 수: 10 (최근 30일)
이전 댓글 표시
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!
채택된 답변
Hitesh
2024년 10월 4일
편집: Hitesh
2024년 10월 4일
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
Christopher Stapels
2024년 10월 4일
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.
추가 답변 (0개)
커뮤니티
더 많은 답변 보기: ThingSpeak 커뮤니티
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Import and Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!