Hello Everybody,
I am building a machine that uses an interchangeable module system to either support oxy-fuel or plasma cutting. I started out using the plasmac component, but had a really hard time configuring it to work for me, tracing the flow of the switch-case statements was very difficult.
I ended up starting from scratch, and using a lookup table to determine what to do. This lookup table is imported from a CSV file, so I can make the table in a readable way, then export. I've made an "abstract class" with methods that each module needs to have. When the lookup table determines which action needs to be taken given the machine state, the function associated with the current module will be called. The functions themselves can return a call to another function, so when the lookup table spits out "PAUSED" as the method, the PAUSED function can return the correct cut recovery process, or the BEGIN_PROCESS can call the IMPLEMENT_ON function . There is also an option to force a function call from the GUI, so the user can probe at any time from the GUI or turn on/off the torch.
I also rewrote the offset_move function to make it more intuitive (at least for me). An example call for height control would be offset_move(FROM_DATUM, MM, 'z', (velocity), target). Now I don't have to do calculations for the velocity in my function logic and it is all handled in the offset_move function.
For probing, I wanted to support contour mapping, because there is not a great way to do THC on a oxy-fuel machine. This component allows you to probe an arbitrary number of points before the program starts, and then uses these points to calculate the "datum" from which the z height is set. You can also choose to probe only on the first pierce, or at each pierce like Plasmac is now.
This currently will not work with the Plasmac GUI or really any machine besides mine, but if there is interest I can try and make it compatible. I think this method will be more readable and expandable. I am also curious to hear feedback on the concept, maybe there is something I am missing. I am pretty new at C, this is my first big project, so I am sure there are plenty of mistakes.
I have attached the code I have right now, as well as the lookup table that my program reads.