use of com.neuronrobotics.sdk.dyio.sequencer.CoreScheduler in project BowlerStudio by CommonWealthRobotics.
the class SchedulerGui method setConnection.
public boolean setConnection(BowlerAbstractDevice connection) {
dyio = (DyIO) connection;
setLayout(new MigLayout());
setBorder(BorderFactory.createLoweredBevelBorder());
cs = new CoreScheduler(get(), loopTime, 6000);
cb = new SchedulerControlBar(cs);
JPanel addBar = new JPanel(new MigLayout());
JButton addChannel = new JButton("Add new channel");
addChannel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int selected = availibleChans.getSelectedInteger();
addServoChannel(cs.addServoChannel(selected));
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Failed to select channel, " + ex.getMessage(), "Bowler ERROR", JOptionPane.ERROR_MESSAGE);
}
}
});
for (int i = 0; i < 24; i++) {
availibleChans.addInteger(i);
}
addBar.add(addChannel);
addBar.add(availibleChans);
JButton removeChannel = new JButton("Remove channel");
removeChannel.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
int selected = usedChans.getSelectedInteger();
for (int i = 0; i < outputs.size(); i++) {
ServoOutputScheduleChannelUI s = outputs.get(i);
if (s.getChannelNumber() == selected) {
rmChannel(selected);
return;
}
}
} catch (Exception ex) {
JOptionPane.showMessageDialog(null, "Failed to select channel, " + ex.getMessage(), "Bowler ERROR", JOptionPane.ERROR_MESSAGE);
}
}
});
addBar.add(removeChannel);
addBar.add(usedChans);
JButton saveConfiguration = new JButton("Save Configuration");
saveConfiguration.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
getFile();
exportToFile();
}
});
JButton loadConfiguration = new JButton("Load Configuration");
loadConfiguration.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent arg0) {
rmAllChannels();
getFile();
importfromFile();
}
});
addBar.add(saveConfiguration);
addBar.add(loadConfiguration);
channelBar.setBorder(BorderFactory.createRaisedBevelBorder());
add(cb, "wrap");
add(addBar, "wrap");
add(channelBar, "wrap");
return get().ping();
}
use of com.neuronrobotics.sdk.dyio.sequencer.CoreScheduler in project java-bowler by NeuronRobotics.
the class SchedulerTest method main.
/**
* @param args
*/
public static void main(String[] args) {
try {
DyIO dyio = new DyIO(ConnectionDialog.promptConnection());
dyio.connect();
CoreScheduler cs = new CoreScheduler(dyio, new File("SparkParty.xml"));
cs.play();
while (cs.isPlaying()) {
try {
Thread.sleep(100);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
} catch (Exception e) {
e.printStackTrace();
} finally {
System.exit(0);
}
}
Aggregations