External Feeds

Tips and questions about scripting your Verbot®.

Moderator: Staff

External Feeds

Postby dave2012 » Fri Dec 02, 2011 9:26 pm

Hi This is my first post on this forum and I am new to the Verbot world....

Similar to the Robot idea / problem I want to feed external data into my verbot so it can respond, just like a sensor input or temperature value,

The trigger to retrieve should be easy as the verbot will be asked questions "what is the temperature?" and will return a value

The best way I can see is to use variables that are updated and set via an external script but how can I pipe these from an external source into the verbot?

I understand we can use the verbot.exe --input " " but this will launch another instance of the verbot app......
If I use CSV files, I can't see an easy way to feed the verbot 'live'.....

Thanks for your help in advance
dave2012
ShyBot
ShyBot
 
Posts: 8
Joined: Sun Nov 27, 2011 10:22 pm

Re: External Feeds

Postby JonC » Sat Dec 03, 2011 4:29 pm

Okay, I'm the author of the code for using CSV files in a dynamic way.
You will need to download the CSV handling kb if you haven't already done so.
Note: this is quite different to the "phonebook" type idea.
this is one (possible) way to do it.
Let us suppose that you have a (small) csv file called(e.g.)"info".
Logically, you will load this at Verbot start-up and your Verbot will process the file as you want (well, as you've written anyway :) ).
Now, if an external program alters the data in "info", then if the Verbot re-reads this file, it will have the updated info to use.
Similarly, if the Verbot changes the data in "info" and then saves the file, the external program can (in theory at least) access this changed data also.
So, to take your example:
If you have a rule with the input: ""what is the temperature?"
then the output would contain the following:
<?csharp
vars["info"] = CSV.Open(vars["csvpath"],"info.csv");
vars["temperature"] = CSV.GetElement(CSV.GetRow(vars["info"], "temperature", true,0),"2");
?>
the temperature is [temperature] degrees centigrade.

---
vars["csvpath"] is the vars-variable that holds the path (e.g. <mem.set csvpath C:\MyDocuments\Data\>).
the second line is the composite "call" needed to the CSV vcm suite.
I'm assuming that CSV file is in the form item,value (thus temperature, 24 or day,monday) i.e. a two column csv where the first column is the "identifier" and the second the "value".
---
There are a few limitations that mean you can't fully "automate" this.
Firstly, the Verbot can only be made "aware" of the "new" data if you tell it to re-read the file (ditto the external program of course).
Thus, even if you do this using the global methods of VerbotStandard (so that it updates "info" each time a rule is used), you can't use a change in the data to "trigger" the Verbot.
Second: depending on the size of the "info" file and the amount of processing that it needs in order to determine the "state" of the Verbot you might find that re-processing the data each time a rule is fired slows the Verbot's response down too much.
---
If you are using a lot of data, you might want to make a sort of "checksum" for it.
What I mean is that if you "sum" up all the values for your data and store it in a separate "csv" file (which then has at most two elements of data, perhaps just one) then you could first re-load this tiny bit of data (therefore fast) and check if the "new" value is different to the old one. Only if the data has changed (i.e. the two "checksum"s do not agree) would you need to reload the data-file.
I'd write that in vcm as well and use that call to call everything else.
---
If you want help to write it, let us know.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Re: External Feeds

Postby dave2012 » Sun Dec 04, 2011 10:59 pm

Jonc, Thank you for your reply,
I can't find the CSV handling kb anywhere I have even tried searching using g00gle's cached pages of the verbot site .....
Could you check the kb is still available for download?

Thanks again
dave2012
ShyBot
ShyBot
 
Posts: 8
Joined: Sun Nov 27, 2011 10:22 pm

Re: External Feeds

Postby JonC » Mon Dec 05, 2011 3:55 pm

JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Re: External Feeds

Postby dave2012 » Sat Dec 10, 2011 10:03 am

Thanks, I have downloaded and installed,
I created info.cvs and loaded both vcm's

I created a rule labelled Temperature and pasted the code into the output, with "what is the temperature?" in the input.
I get no response from my Verbot.
I have no other kB's loaded so conflicting rules...

using the existing cars template and CSV could you give an example output that i can use to test?

I have started reading some C# tutorials and really do appreciate your help :)

Thanks
dave2012
ShyBot
ShyBot
 
Posts: 8
Joined: Sun Nov 27, 2011 10:22 pm

Re: External Feeds

Postby dave2012 » Sun Dec 11, 2011 8:50 am

ok I have managed to get it to work!! i can read from the csv, now I need to figure out how to write from the verbot to the csv file.......
dave2012
ShyBot
ShyBot
 
Posts: 8
Joined: Sun Nov 27, 2011 10:22 pm

Re: External Feeds

Postby Mapestone » Sun Dec 11, 2011 1:03 pm

dave2012 wrote:....
I understand we can use the verbot.exe --input " " but this will launch another instance of the verbot app......

Hello Dave. Welcome to the community!
Using the external command Verbot4Engine.exe --input="This is my input text." does send the text to an open instance of the Player on my home PC. I'm running the Verbot 5 Player 5.0.1.1 on XP SP3 with the latest .net release. I'll check it out on W7 Monday. This could be an OS configuration problem.

- Dan
Mapestone
PowerBot
PowerBot
 
Posts: 116
Joined: Tue Apr 06, 2010 1:34 am

Re: External Feeds

Postby JonC » Sun Dec 11, 2011 3:54 pm

Dave:
saving to the csv is no harder than reading it (for a standalone!).
There is a SAVE command in the csv suite, but you will probably need to "update" your csv file first. Again I'm assuming that CSV file is in the form item,value (thus temperature, 24 or day,monday) i.e. a two column csv where the first column is the "identifier" and the second the "value"....
What we do first of all is update the csv row holding the temperature data in f9le "info", we then (re-)save the updated file.
An example of the sort of cc# needed is:
<?csharp
vars["info"] = main.UpdateData(vars["info"], "temperature", vars["temperature"] );
CSV.Savefile(vars["info"], vars["csvpath"],"info.csv");
?>
You could, of course, combine the update and save commands in one composite line, but I've shown it separately for clarity.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Re: External Feeds

Postby JonC » Sun Dec 11, 2011 3:55 pm

Interesting Mapestone.
If that is a general property now, then it opens up a new way of interacting with the 'bot.
I hope others will jump in on this...
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Re: External Feeds

Postby dave2012 » Mon Dec 12, 2011 9:10 pm

Mapestone wrote:
dave2012 wrote:....
I understand we can use the verbot.exe --input " " but this will launch another instance of the verbot app......

Hello Dave. Welcome to the community!
Using the external command Verbot4Engine.exe --input="This is my input text." does send the text to an open instance of the Player on my home PC. I'm running the Verbot 5 Player 5.0.1.1 on XP SP3 with the latest .net release. I'll check it out on W7 Monday. This could be an OS configuration problem.

- Dan

Found it! a simple syntax error :oops: '='

verbot5engine.exe --input "test" opens an new verbot each time
verbot5engine.exe --input= "test" pipes to the existing verbot

Thanks again for your help..
dave2012
ShyBot
ShyBot
 
Posts: 8
Joined: Sun Nov 27, 2011 10:22 pm

Re: External Feeds

Postby JonC » Tue Dec 13, 2011 8:52 pm

Well done Mapestone and Dave - and no need for embarrassment!.
AFAIK you have found another undocumented function in the Verbot - or at least one that is poorly documented.
I base this on the fact that this is the first I've heard of this ability.
This really opens up the possibility of teh Verbot interacting with the "outside" world in all sorts of ways.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Re: External Feeds

Postby Mapestone » Wed Dec 14, 2011 12:22 am

JonC wrote:...This really opens up the possibility of the Verbot interacting with the "outside" world in all sorts of ways.
Agreed JonC. And thank you dave2012 for "discovering" another underdocumented feature. I've got an idea for a script that will use the --input= feature to load text files. Hope to find time to complete it in the next several weeks.

BTW: I tested the --input== external command on Windows 7. Works as advertised.

- Dan
Mapestone
PowerBot
PowerBot
 
Posts: 116
Joined: Tue Apr 06, 2010 1:34 am

Re: External Feeds

Postby JonC » Wed Dec 14, 2011 9:02 am

There's a typo somewhere!
Is it input="..." or input=="..."?
Okay, easy to check, but let's get it definite.
Then can I suggest that this is made a new thread?
That way it will be more obvious to other users.
Last edited by JonC on Thu Dec 15, 2011 2:16 pm, edited 1 time in total.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Re: External Feeds

Postby Mapestone » Wed Dec 14, 2011 11:43 am

JonC wrote:There's a typo somewhere!
Is it input="..." or input=="..."?

Good catch JonC. My apologies. It is --input="your text here" (just one =) .
This topic thread is listed as Scripting > External Feeds . Where should it be moved to?
For the general reader:
The Verbot 5 Player and Verbot 5 Editor programs are by default installed in the user's Application Data folder (directory) path in Windows XP. I expected to find the files under C:\Program Files... For example: logged in as user Mapestone, these programs are in:
C:\Documents and Settings\Mapestone\Application Data\Verbot5\main
The example given in the Verbot Manual assumes that you are executing the command in this folder.
Also, the manual references Verbot Version 4. The names of the programs have changed slightly since publication.
The player program is now Verbot5Engine.exe... another mistake I made in a previous post.
Continuing with the example, the fully qualified command under Windows XP is:
C:\"Documents and Settings"\Mapestone\"Application Data"\Verbot5\main\Verbot5Engine.exe --input="your text here"
whew! This can be simplified. More to come.
- Dan
Mapestone
PowerBot
PowerBot
 
Posts: 116
Joined: Tue Apr 06, 2010 1:34 am

Re: External Feeds

Postby JonC » Thu Dec 15, 2011 2:46 pm

True enough Mapestone, but I felt that it should go in new thread in scripting called, for example, "Undocumented use of verbot5.exe--input command", simply because it's a "new" Verbot command rather Verbot script.
Somewhat ironically, I think scripting is still the best place for it!
Unless our admins what to put this into a HowTo of course.
JonC
SupremeBot
SupremeBot
 
Posts: 665
Joined: Wed Apr 02, 2008 6:34 am
Location: Leicestershire, Great Britain

Next

Return to Scripting

Who is online

Users browsing this forum: No registered users and 0 guests

cron