XML Script help
chaosgk
Posts: 322
I am looking for a volunteer that could write a simple script for me if anyone is interested.· This is for my fireworks firing system Kwinn and I are building using a prop as the controller.
I need a file output that looks like this;
long· s2 + RY56
long· RY1
long· at +· 2000
From an input that looks like this.
long s1 +· RY49 long at 11400
long s1 +· RY1 long at 19600
long s1 +· RY2 long at 20600
The simulation program I use exports it into a CSV file. I tried using excel to create what I want, but there needs to be lines seperating the commands.
Here is how it works from the first line.
long s1 +· RY49 long at 11400
1st line =· slave select (s1 for example) + Relay number (ry49) + Next relay number if there is one at the same time code,·· Can only be RY 33-49, otherwise blank after the slave #
2nd line =· slave select 1-32,· if not 1-32, then 0
3rd line = 11400· (time in ms)· If there are other slaves and relays selected at the same time, it should·wait to add the time code line until after all the slaves and relays have been selected.
example;·
input:
long s1 +· RY49 long at 11400
long s1 +· RY1 long at 20600
long s1 +· RY32 long at 20600
long s2 +· RY2 long at 20600
output
long·s1 + ry49
long 0
long at + 11400
long s1
long ry1 + RY32
long s2
long ry2
long at + 20600
If there is more than one relay selected on the same slave in the group 33-56 or 1-32, they can be entered as;
long s1 + ry33 + ry49
long RY1 + RY32
long at +2000
Also, the data it pulls from can be in a CSV format of;
11.4,1,49· (time in seconds, slave, Relay)
If you can help, please, please let me know.· I can do it manually, but it would take me days to go through and edit it, and if I have to change the time codes or addresses in the simulation software, it would be a nightmare to try and adjust it in the code.
Thanks
Derrick
·
·
I need a file output that looks like this;
long· s2 + RY56
long· RY1
long· at +· 2000
From an input that looks like this.
long s1 +· RY49 long at 11400
long s1 +· RY1 long at 19600
long s1 +· RY2 long at 20600
The simulation program I use exports it into a CSV file. I tried using excel to create what I want, but there needs to be lines seperating the commands.
Here is how it works from the first line.
long s1 +· RY49 long at 11400
1st line =· slave select (s1 for example) + Relay number (ry49) + Next relay number if there is one at the same time code,·· Can only be RY 33-49, otherwise blank after the slave #
2nd line =· slave select 1-32,· if not 1-32, then 0
3rd line = 11400· (time in ms)· If there are other slaves and relays selected at the same time, it should·wait to add the time code line until after all the slaves and relays have been selected.
example;·
input:
long s1 +· RY49 long at 11400
long s1 +· RY1 long at 20600
long s1 +· RY32 long at 20600
long s2 +· RY2 long at 20600
output
long·s1 + ry49
long 0
long at + 11400
long s1
long ry1 + RY32
long s2
long ry2
long at + 20600
If there is more than one relay selected on the same slave in the group 33-56 or 1-32, they can be entered as;
long s1 + ry33 + ry49
long RY1 + RY32
long at +2000
Also, the data it pulls from can be in a CSV format of;
11.4,1,49· (time in seconds, slave, Relay)
If you can help, please, please let me know.· I can do it manually, but it would take me days to go through and edit it, and if I have to change the time codes or addresses in the simulation software, it would be a nightmare to try and adjust it in the code.
Thanks
Derrick
·
·
Comments
however it should not be to hard to write a php script to make the conversion
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lots of propeller based products in stock at affordable prices.
▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
Lots of propeller based products in stock at affordable prices.
You were not very clear on how the relays were added to the CSV file, so I guessed a bit here. Something very similar can be easily be done in VBA (excel)
[noparse][[/noparse]edit]
If the assumption was not correct about how you added relays for a slave to the csv file let me and I will change the code.
I also converted this to an excel macro (being a bit bored at work ) I attached the result (most of the work is a macro, so you might be asked to enable macro's depending on your security settings). Just press the big CONVERT button and select an csv file. Result will be a txt file written in the same folder as the csv file. If you don't trust to open an unknown excel file here is the code:
Just copy this in an excel spreadsheet and add a button so you can start the converter
Post Edited (rosco_pc) : 5/28/2010 8:48:41 AM GMT
Thanks a lot.
·
BTW saw now that the forum mangles the python code (losing array indexes), so I've attached the code here with a small bonus
the + need a space in front and behind them so instead of "long at+213200" it would be "long at + 213200"
Same with the RY commands.
Also, if a time code is the same for two of the S's (ie. S1, S2, ...) the time code should go at the end of the set such as.
long s1
Long RY1
long s2
long ry11
long at 213200
That way the firing program reads all of the things that should happen at that time and sets them to go off together, otherwise it sees the 2nd time code at the same time and only fires one set.
Hope this makes sense and is a quick fix.
Other then those two things, it works awesome.
Thanks
Derrick.
BTW, if you want to check out some of our videos of the testing of the fireworks, go to http://www.youtube.com/user/mumpyrotechnics
or check mumpyro.com
11.4, 1, 1,33,4,...
11.4, 2, 20,25,49
12.1, ....
Let me know if this is not the case and I will add some sorting. The attached zip file contains both Excel file and the 'raw' vba file.
Unfortunately I do not have access to youtube as I'm sitting behind the Great Firewall of China and it seems they have finally found a way to block tor
Thanks
I understood this to mean that 1st line contains slave + relays 33-49 and 2nd line contains relays 1-32 or just a '0' if no relays between 1-32 have been selected. But I now also see that you said: This is something you can quite easily change yourself (you need to learn that anyway, as I might not always be around ):
to
edited to correct some spelling mistakes
Post Edited (rosco_pc) : 6/9/2010 12:23:10 PM GMT
Thanks
All my machines at home have different flavors of Linux and/or OpenBSD installed