Quantcast
Channel: Rainmeter Forums
Viewing all articles
Browse latest Browse all 326

WebParser URL=file measure, how to reliably overwrite/update the local file in the background?

$
0
0
Dear Team, in this project I still have sometimes a small glitch - I was hoping that you "know the answer"? I know that there's a solution but after a few days of try+error I'm lost. It's not a show-stopper, but I know it's possible to fix this.
  • I'm using a WebParser measure to regex out a few strings from a local file "PVMetrics-Webparser.txt", see code below
  • Note hat the UpdateRate is 1 hour
  • Every 15 minutes I run an AHK script triggered by a Plugin=RunCommand measure in the skin, which updates the "PVMetrics-Webparser.txt" file in the background
  • In detail, as final step in the AHK script, I'm copying an updated temp.txt file over the existing "PVMetrics-Webparser.txt" via FileCopy("temp.txt", "PVMetrics-Webparser.txt", 1) - Note: "1" option means overwrite-mode Here's the docs for AHK's FileCopy in case I overlooked something...
Here's the problem: Not every time, but maybe 20% of the time the FileCopy fails with this AHK error:
Error: (32) The process cannot access the file because it is being used by another process.

Suspicion is, that it's the Rainmeter WebParser URL=file accessing the file every second (Update=1000) despite the 1 hour UpdateRate??! Is it true, that the WebParser measure is locking the file every time it's looking into it?

Now the million-dollar-question: How can I reliably overwrite the WebParser local file in the background with the running Rainmeter WebParser measure/skin? Honestly, I'm not 100% sure that Rainmeter is the problem, but as of now this is my best lead... Any ideas, hints, much appreciated.

Code:

[PVParser1]Measure=WebParser; UdateRate=1 hour --> we will trigger WebParser execution always with above FinishAction=[!CommandMeasure PVParser1 "Update"] after the AHK script providing an updated file "Metrics-Webparser.txt" has finished execution!UpdateRate=3600URL=file://#CURRENTPATH#PVMetrics-Webparser.txtCodePage=1200RegExp=(?siU)LastRunTimeStamp=(.*)\RLastRunTimeStampUTC=(.*)\R.*ParseString_NOMATCH_Counter=(.*)\R.*LastUpdatedAgo_minutes=(.*)\RCurrentBatteryCharge=(.*)\REnergyIndependence=(.*)\R.*Imported_kWh=(.*)\RProduced_kWh=(.*)\RDischarged_kWh=(.*)\RConsumed_kWh=(.*)\RExported_kWh=(.*)\RNetExported_kWh=(.*)\RCharged_kWh=(.*)\RMetricTrend_ScaleMAXkW=(.*)\RFinishAction=[!EnableMeasureGroup WaitForPVParser1][!ShowMeterGroup MeterWaitForPVParser1][!Log " OK, PV update cycle done."]OnConnectErrorAction=[!Log "!WebParser PVParser1 update ERROR!"]

Statistics: Posted by emp00 — June 23rd, 2024, 7:31 pm — Replies 8 — Views 149



Viewing all articles
Browse latest Browse all 326

Trending Articles