This page describes the steps to add a new data-type, e.g. Powerline devices, to JMRI.
It uses as an example the addition of the "powerline" type in January 2008. This was before several important migrations (SVN to Git; changes to the internal support for multiple connections; changes to how the Preferences mechanism works; etc) so this may need significant updating.
Some parts may also be useful if you're adding a new connection (e.g. through a network link) to an existing system. If you do that, please mark those sections here for the next person to come along.
Note that we don't do this very often, and the specifics are more important than the generalities here. You should should make sure you understand the intended system connection structure which is documented on another page.
We list the files that are modified and created in the order they were done in this case; other orders may also work, and you might not need to do all these.
In this particular case, we started by copying an existing system implementation (SECSI). This effects how we ordered this, and made the basic process move pretty quickly.
Using whatever tool that useful to you, duplicate the src/jmri/jmrix subtree corresponding to the existing system you want to copy.
Using your favorite editor, change all the package names in the new files to their new location. In this example, that was a bulk replace of "jmri.jmrix.secsi" with "jmri.jmrix.powerline".
At this point, make sure you can compile. This code isn't consistent yet, but it should compile.
Because you've copied a system that might not have been touched for a while, go through and add the current year (and if need be, your name) to the copyright notices in all the files.
In this step, we put the basic Git structure in place.
git add powerline powerline/serialdriver powerline/serialmon
git add powerline/configurexml powerline/serialdriver/configurexml
git add powerline/COPYING powerline/*/COPYING powerline/*/*/COPYING
git commit -m"usual file" powerline
At this point, make sure you can compile.
Using your favorite editor, change all occurances of the old system name into the new one.
bbedit `grep -irl secsi powerline/`
Then search for and replace, perhaps not literally, all the occurances.
At this point, make sure you can compile.
Add the line @ServiceProvider(service = ConnectionTypeList)
just before
the class definition so that the preferences system sees your new connection types. You
may also need to add the following import statements:
import org.openide.util.lookup.ServiceProvider;
import jmri.jmrix.ConnectionTypeList;
For more information on this, see the testing page.
Following the steps above, duplicate the directory for the previous systems tests, creating a new directory in test/jmri/jmrix to contain the tests. Change the package names, check the copyright dates, create the Git structure, and migrate the names.
At this point, make sure you can compile both the main code (which wasn't changed in this step) and the tests.
You should also be able to successfully run the tests in your new system (although
they were created for the old system's functionality): ant tests
&&./runtest.csh jmri.jmrix.powerline.SerialTest
There is also a PowerShell script available, see the JUnit page for more information
Edit the jmri/jmrix/ActiveSystemsMenu.java file (two places), src/jmri/jmrix/JmrixConfigPane.java (one place) and src/jmri/jmrix/SystemsMenu.java (one place) files to add the new system.
Don't commit this to Git yet!
At this point, make sure you can compile and run DecoderPro, and that your new system appears in the preferences panel.
Edit the test/jmri/jmrix/JmrixTest.java file to invoke your new system tests.
Don't commit this to Git yet!
At this point, when you "ant alltest", your new system's test should be run.
Speeds, etc, in powerline/serialdriver/SerialDriverAdapter.java.
The first step is to get communications working so that you can send a message from the "Send Command" window, and see it and the response in the "Monitor" window.
Create a new system-specific `ActionListBundle.properties` file
(src/jmri/jmrix/powerline/PowerlineActionListBundle.properties) to add appropriate action
items. Make sure to update the getActionModelResourceBundle()
method of the
SystemConnectionMemo to reference this newly created ActionListBundle.
Start by duplicating, then edit, don't forget to update the index.
You'll also have to change the locations on the various frames
Create the Javadocs, and fix any new (or old) problems.
Edit help/en/html/hardware/index.shtml
cp java/src/jmri/jmrix/cmri/serial/networkdriver/
java/src/jmri/jmrix/rfid/
cp java/src/jmri/jmrix/cmri/serial/SerialNetworkPortController.java
java/src/jmri/jmrix/rfid/RfidNetworkPortController.java
// connect to the traffic controller
this.getSystemConnectionMemo().setRfidTrafficController(control);
control.setAdapterMemo(this.getSystemConnectionMemo());
control.connectPort(this);
control.sendInitString();
// declare up
jmri.jmrix.rfid.ActiveFlag.setActive();
(There's also a bunch of stuff before this in the configure() method that should just be
copied over, because the RFID connections also need some complicated configuration); the ctor also
needs some parts copied over.