You can use the code in this sample project to build plugins to connect a machine tool to STEP-NC machine. Your plugin will be called to get position information when you are tracking position with the CNC window. You can modify the SamplePlugin project or create a new project with the following:
Write code to connect to your machine tool, return the current X/Y/Z coordinates, the current block number, and a few others. The TestForm project makes a simple dialog that continually calls your DLL and shows the values returned.
When you are happy, copy your DLL to the "plugins" directory under the STEP-NC Machine installation. Click on the "Configure" button above and the settings dialog will show a list of available plugins to pick from. The plugin will be remembered and loaded whenever you run STEP-NC Machine.
Plugin Functions
The ICNCPlugin interface defines a few functions for you to implement and the sample project gives you an example to work from. The functions are:
- LoadCNC and UnloadCNC — These are called by STEP-NC Machine to give you an opportunity to initiate and clean up a communications connection with your machine tool.
- IsConnected — This function simply returns true if your plugin has connected to its CNC.
- GetActualProgramX/Y/Z — These three functions return the current X, Y, or Z axis position of the machine.
- GetCurrentProgramUnit — Return one of two different enum values to say whether the position numbers are in millimeter or inch units.
- GetCurrentProgramBlock — Return the current block as the sequence number of blocks counted from the start of the file.
- GetMachineDesc — Return a string describing the connected machine tool. This is for information only.
- SetCurrentProgram — This function will be called with a path to a Gcode file that should be loaded into the CNC. The STEP-NC Explorer expects that all position and block numbers correspond to the instructions in this file.
- IsSTEPNCPosition — This returns true if the position data being returned is in response to the STEP-NC program specified by SetCurrentProgram, or false if the position data is just raw movements.
Sample Project
The plugin sample project contains an example DLL that you can modify and a simple dialog window that you can use for testing the plugin. Double click on "sample.sln" to begin.
The SamplePlugin project creates the plugin DLL. When asked for block number, it simply increments a counter and returns the number. When asked for position, the example will move around the four corners of a square.
The TestForm project is a simple dialog window that calls the plugin several times a second and displays the results. You can use this for testing your own plugin before you add it to STEP-NC Machine. The first time you compile the solution, you may need to right-click on the project and select "Set as Startup Project" to tell Visual Studio to run the test form.