bartneck / swiML

A project to formalise swimming programs using XML
MIT License
2 stars 2 forks source link

program length calculation is incorrect #108

Closed bartneck closed 1 month ago

bartneck commented 4 months ago

I created a program /bookExamples/patterns/handshake/handshake-program.html. It uses a mixture of lengthAsLaps and lengthAsDistance. The total is reported as 520. It is calculated at 200+120+200. There are indeed 120 laps being swum in the main set. The calculation is not respecting the unit of measurement. 120 laps in a 25 meters pool is 3000 meters. The total should be 3400 meters.

It seem that the calculation is treating the number of laps as meters.

SCR-20240514-npop
calloc262 commented 4 months ago

added fix to main program length is also now output is either meters or laps as defined by lengthUnit. Still working on an output for total time.

bartneck commented 2 months ago

I created a handshake-program-manual.xml for testing. I get a validation error: Assertion evaluation ('(count(.//sw:instruction/sw:rest) = 0)') for element 'continue' on schema type 'continueType' did not succeed. The total program length is also incorrect:

SCR-20240716-kfng
bartneck commented 2 months ago

Decision: always display meters and laps. Both correspond to each other. If a lengthAsTime is present, display it as + xxx minutes. If only time is present then remove meters and laps.

bartneck commented 2 months ago

The program length of this program is now 3520 meters / 140.8 Laps. It should be 3400 meters 136 laps

calloc262 commented 1 month ago

I haven't been able to recreate this bug. Both the handshake and the manual xml files compile properly and give the correct program length output. What file were you using?

bartneck commented 1 month ago

This is an interesting one. The program that does not work is called handshake-program-test.xml in the handshake folder. It is generated through handshake-program.py. The same program created manually handshake-program.xml does not show the miscalculation.

calloc262 commented 1 month ago

Bug was caused by python outputting continue Length in XML only as lengthAsDistance. Fix should be in main swiML.py, however could you please check if its working for you as I'm currently getting this bug when trying to run the write function in python: OSError: [Errno 9] Bad file descriptor Still unsure how to fix this, but working on it.

bartneck commented 1 month ago

I updated the handshake-program.py and it worked fine. The XML is now valid and the program length is accurate.