Search in sources :

Example 1 with IFileChangeListener

use of com.neuronrobotics.sdk.util.IFileChangeListener in project bowler-script-kernel by CommonWealthRobotics.

the class MobileBaseCadManager method getConfigurationDisplay.

private static ICadGenerator getConfigurationDisplay() {
    if (cadEngineConfiguration == null) {
        try {
            File confFile = ScriptingEngine.fileFromGit("https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", "dhcad.groovy");
            cadEngineConfiguration = (ICadGenerator) ScriptingEngine.inlineFileScriptRun(confFile, null);
            FileChangeWatcher watcher = FileChangeWatcher.watch(confFile);
            watcher.addIFileChangeListener(new IFileChangeListener() {

                @Override
                public void onFileChange(File fileThatChanged, WatchEvent event) {
                    // TODO Auto-generated method stub
                    try {
                        cadEngineConfiguration = (ICadGenerator) ScriptingEngine.gitScriptRun("https://github.com/CommonWealthRobotics/DHParametersCadDisplay.git", "dhcad.groovy", null);
                        for (MobileBase manager : cadmap.keySet()) {
                            MobileBaseCadManager mobileBaseCadManager = cadmap.get(manager);
                            if (mobileBaseCadManager.autoRegen)
                                if (mobileBaseCadManager.configMode)
                                    mobileBaseCadManager.generateCad();
                        }
                    } catch (Exception e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                    }
                }
            });
        } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
    return cadEngineConfiguration;
}
Also used : IFileChangeListener(com.neuronrobotics.sdk.util.IFileChangeListener) FileChangeWatcher(com.neuronrobotics.bowlerstudio.util.FileChangeWatcher) WatchEvent(java.nio.file.WatchEvent) File(java.io.File) MobileBase(com.neuronrobotics.sdk.addons.kinematics.MobileBase) GitAPIException(org.eclipse.jgit.api.errors.GitAPIException) IOException(java.io.IOException) TransportException(org.eclipse.jgit.api.errors.TransportException) InvalidRemoteException(org.eclipse.jgit.api.errors.InvalidRemoteException)

Aggregations

FileChangeWatcher (com.neuronrobotics.bowlerstudio.util.FileChangeWatcher)1 MobileBase (com.neuronrobotics.sdk.addons.kinematics.MobileBase)1 IFileChangeListener (com.neuronrobotics.sdk.util.IFileChangeListener)1 File (java.io.File)1 IOException (java.io.IOException)1 WatchEvent (java.nio.file.WatchEvent)1 GitAPIException (org.eclipse.jgit.api.errors.GitAPIException)1 InvalidRemoteException (org.eclipse.jgit.api.errors.InvalidRemoteException)1 TransportException (org.eclipse.jgit.api.errors.TransportException)1