Author Topic: File.Read  (Read 7684 times)

0 Members and 1 Guest are viewing this topic.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: File.Read
« Reply #15 on: May 27, 2013, 09:18:54 PM »
I don't know what you are asking me any more...  it is a bit hard to follow after all your posts.

What error are you getting?  Maybe if you can upload all the xml and all the python that you are using, I can try to make some sense of it.

Quote
The strange thing is if i put the old code, now work too, so the vc.callAction its returning the value
Impossible.  vc.callAction will never return a value.

The first question I would ask is, why is the sensor sending the event more than once?  What kind of sensor is it?

One way to avoid the problem with the sensor triggering multiple times is this.

1 - When your code is initialized, store the current time in a variable called "lastTriggerTime".
2 - Every time the sensor triggers your code, you compare the current time to the last time that was stored in lastTriggerTime.  If it has been less than 5 seconds (or whatever period of time works best) then exit.
3 - Update the variable lastTriggerTime to the current time.

another option would be to use a timer, but that is more difficult.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: File.Read
« Reply #16 on: May 27, 2013, 09:20:37 PM »
Oh and by the way...

Yes, I will add a new action

Code: [Select]
File.Write
in the next version of VC, that does not add the new line characters at the end.  I'm not sure why I did not have this already...  :-[

edit:  it is not as nice as using a single action, but until I create this action, you can write a file without creating an extra new line like this:

Code: [Select]
<?xml version="1.0" encoding="utf-16"?>
<command id="1077" name="file write single line" enabled="true" alwaysOn="False" confirm="False" requiredConfidence="0" loop="False" loopDelay="0" loopMax="0" description="">
  <action>
    <cmdType>File.Delete</cmdType>
    <cmdString>singleline.txt</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
  <action>
    <cmdType>File.Append</cmdType>
    <cmdString>singleline.txt&amp;&amp;1 line of text only!</cmdString>
    <cmdRepeat>1</cmdRepeat>
  </action>
</command>
« Last Edit: May 27, 2013, 09:29:49 PM by jitterjames »

claymic

  • $upporter
  • Sr. Member
  • *****
  • Posts: 152
  • Karma: 0
    • View Profile
Re: File.Read
« Reply #17 on: May 27, 2013, 10:05:27 PM »
I don't know what you are asking me any more...  it is a bit hard to follow after all your posts.

What error are you getting?  Maybe if you can upload all the xml and all the python that you are using, I can try to make some sense of it.
Impossible.  vc.callAction will never return a value.

The first question I would ask is, why is the sensor sending the event more than once?  What kind of sensor is it?

One way to avoid the problem with the sensor triggering multiple times is this.

1 - When your code is initialized, store the current time in a variable called "lastTriggerTime".
2 - Every time the sensor triggers your code, you compare the current time to the last time that was stored in lastTriggerTime.  If it has been less than 5 seconds (or whatever period of time works best) then exit.
3 - Update the variable lastTriggerTime to the current time.

another option would be to use a timer, but that is more difficult.
Ok, you can test this by yourself, but this is working
Code: [Select]
powerArCondition =vc.callAction("File.Read","{Path.VC}\Devices\ArGree.txt",None)I tested this a few minutes ago, but maybe i did something wrong or forgot to delete something, but i am almost sure that this is working because was my first test with a OSD showing the value of the powerArCondition, before change the script.
What i want understand is how Vox call the actions when a script is running (or stating to run), because i need to understand if this is a asynchronous thing. Sorry but i will not be able to explain again, try to read my last posts, i know, my English is bad, but i explained two situations: One its using the action to set a variable and prevent the action to run again, the other way is use the script, but the action run every time that i get a new feedback (its a serial feedback).
My objective its not exactly put the code to work, i can do this in a few ways. What i want is understand how a action, a event and a script are related.
- If two events run almost at the same time, and the first event have a script, what will run first ? The script or the second event ? In the example that i put in the previous post the second event run first.
- If a script is running and Vox get another event that trigger a action, what will happen ? Vox will wait until the script stop to run or will execute the action immediately ?
I have to understand this to prevent a variable to change before the script finish the code, among other things.


claymic

  • $upporter
  • Sr. Member
  • *****
  • Posts: 152
  • Karma: 0
    • View Profile
Re: File.Read
« Reply #18 on: May 27, 2013, 10:08:32 PM »
By the way...thanks for change the
Code: [Select]
File.WriteAnd since you are working hard this days, maybe you can insert a option in the actions window to determine a time (miliseconds) that this action will have to wait to run again, will be a nice future.
Thanks again for all your help and all the improvements in VoxCommando.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: File.Read
« Reply #19 on: May 28, 2013, 10:16:39 AM »
maybe you can insert a option in the actions window to determine a time (miliseconds) that this action will have to wait to run again

Can you be more specific?  I'm not 100% sure what you mean.