This commit is contained in:
@@ -19,13 +19,16 @@
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="1" attributes="0">
|
||||
<Component id="panelRobot" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="jPanel2" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="panelSafety" alignment="1" min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" alignment="1" groupAlignment="0" max="-2" attributes="0">
|
||||
<Component id="jPanel3" alignment="1" max="32767" attributes="0"/>
|
||||
<Component id="panelRobot" alignment="1" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="panelCommands" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="44" max="32767" attributes="0"/>
|
||||
<EmptySpace pref="32" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -40,10 +43,12 @@
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jPanel2" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="jPanel3" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="panelRobot" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace pref="21" max="32767" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -117,16 +122,16 @@
|
||||
<Group type="102" alignment="1" attributes="0">
|
||||
<EmptySpace pref="76" max="32767" attributes="0"/>
|
||||
<Component id="buttonPositionsHexiposi" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="74" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="74" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace pref="19" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="buttonPositionsHexiposi" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="32" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
@@ -433,5 +438,69 @@
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="javax.swing.JPanel" name="jPanel3">
|
||||
<Properties>
|
||||
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
|
||||
<Border info="org.netbeans.modules.form.compat2.border.TitledBorderInfo">
|
||||
<TitledBorder title="Puck Detection"/>
|
||||
</Border>
|
||||
</Property>
|
||||
</Properties>
|
||||
|
||||
<Layout>
|
||||
<DimensionLayout dim="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="buttonPuckDetCheck" linkSize="6" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="buttonPuckDetStop" linkSize="6" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="32767" attributes="0"/>
|
||||
<Component id="buttonPuckDetStart" linkSize="6" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="buttonPuckDetCheck" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonPuckDetStop" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="buttonPuckDetStart" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
</Layout>
|
||||
<SubComponents>
|
||||
<Component class="javax.swing.JButton" name="buttonPuckDetCheck">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Ckeck"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPuckDetCheckActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonPuckDetStop">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Stop"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPuckDetStopActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="buttonPuckDetStart">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Start"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="buttonPuckDetStartActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
</SubComponents>
|
||||
</Form>
|
||||
|
||||
@@ -52,10 +52,16 @@ public class Expert extends Panel {
|
||||
}
|
||||
|
||||
void execute(String statement, boolean background){
|
||||
execute(statement, background, false);
|
||||
}
|
||||
|
||||
void execute(String statement, boolean background, boolean showReturn){
|
||||
try {
|
||||
evalAsync(statement, background).handle((ret, ex) -> {
|
||||
if (ex != null){
|
||||
showException((Exception)ex);
|
||||
} else if (showReturn){
|
||||
SwingUtils.showMessage(getTopLevel(), "Return", String.valueOf(ret));
|
||||
}
|
||||
return ret;
|
||||
});
|
||||
@@ -109,6 +115,10 @@ public class Expert extends Panel {
|
||||
spinnerSegment = new javax.swing.JSpinner();
|
||||
jLabel3 = new javax.swing.JLabel();
|
||||
buttonHomingHexiposi = new javax.swing.JButton();
|
||||
jPanel3 = new javax.swing.JPanel();
|
||||
buttonPuckDetCheck = new javax.swing.JButton();
|
||||
buttonPuckDetStop = new javax.swing.JButton();
|
||||
buttonPuckDetStart = new javax.swing.JButton();
|
||||
|
||||
panelRobot.setBorder(javax.swing.BorderFactory.createTitledBorder("Robot"));
|
||||
|
||||
@@ -166,14 +176,14 @@ public class Expert extends Panel {
|
||||
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap(76, Short.MAX_VALUE)
|
||||
.addComponent(buttonPositionsHexiposi)
|
||||
.addGap(74, 74, 74))
|
||||
.addContainerGap(74, Short.MAX_VALUE))
|
||||
);
|
||||
jPanel2Layout.setVerticalGroup(
|
||||
jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel2Layout.createSequentialGroup()
|
||||
.addContainerGap(19, Short.MAX_VALUE)
|
||||
.addContainerGap()
|
||||
.addComponent(buttonPositionsHexiposi)
|
||||
.addContainerGap(32, Short.MAX_VALUE))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
panelSafety.setBorder(javax.swing.BorderFactory.createTitledBorder("Safety"));
|
||||
@@ -379,6 +389,56 @@ public class Expert extends Panel {
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
|
||||
jPanel3.setBorder(javax.swing.BorderFactory.createTitledBorder("Puck Detection"));
|
||||
|
||||
buttonPuckDetCheck.setText("Ckeck");
|
||||
buttonPuckDetCheck.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonPuckDetCheckActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonPuckDetStop.setText("Stop");
|
||||
buttonPuckDetStop.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonPuckDetStopActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
buttonPuckDetStart.setText("Start");
|
||||
buttonPuckDetStart.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
buttonPuckDetStartActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
|
||||
jPanel3.setLayout(jPanel3Layout);
|
||||
jPanel3Layout.setHorizontalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(buttonPuckDetCheck)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonPuckDetStop)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(buttonPuckDetStart)
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
jPanel3Layout.linkSize(javax.swing.SwingConstants.HORIZONTAL, new java.awt.Component[] {buttonPuckDetCheck, buttonPuckDetStart, buttonPuckDetStop});
|
||||
|
||||
jPanel3Layout.setVerticalGroup(
|
||||
jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addGroup(jPanel3Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(buttonPuckDetCheck)
|
||||
.addComponent(buttonPuckDetStop)
|
||||
.addComponent(buttonPuckDetStart))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
|
||||
this.setLayout(layout);
|
||||
layout.setHorizontalGroup(
|
||||
@@ -386,12 +446,14 @@ public class Expert extends Panel {
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
|
||||
.addComponent(panelRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(panelSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(panelSafety, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
|
||||
.addComponent(jPanel3, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(panelRobot, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(panelCommands, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addContainerGap(44, Short.MAX_VALUE))
|
||||
.addContainerGap(32, Short.MAX_VALUE))
|
||||
);
|
||||
layout.setVerticalGroup(
|
||||
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
@@ -404,8 +466,10 @@ public class Expert extends Panel {
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(panelRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addContainerGap(21, Short.MAX_VALUE))
|
||||
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
|
||||
);
|
||||
}// </editor-fold>//GEN-END:initComponents
|
||||
|
||||
@@ -480,6 +544,18 @@ public class Expert extends Panel {
|
||||
execute("put_gonio('force=" + force + ")");
|
||||
}//GEN-LAST:event_buttonPutGonioActionPerformed
|
||||
|
||||
private void buttonPuckDetCheckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPuckDetCheckActionPerformed
|
||||
execute("check_puck_detection()", true, true);
|
||||
}//GEN-LAST:event_buttonPuckDetCheckActionPerformed
|
||||
|
||||
private void buttonPuckDetStopActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPuckDetStopActionPerformed
|
||||
execute("stop_puck_detection()", true);
|
||||
}//GEN-LAST:event_buttonPuckDetStopActionPerformed
|
||||
|
||||
private void buttonPuckDetStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonPuckDetStartActionPerformed
|
||||
execute("start_puck_detection()", true);
|
||||
}//GEN-LAST:event_buttonPuckDetStartActionPerformed
|
||||
|
||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||
private javax.swing.JButton buttonDisable;
|
||||
private javax.swing.JButton buttonEnable;
|
||||
@@ -489,6 +565,9 @@ public class Expert extends Panel {
|
||||
private javax.swing.JButton buttonHomingHexiposi;
|
||||
private javax.swing.JButton buttonMount;
|
||||
private javax.swing.JButton buttonPositionsHexiposi;
|
||||
private javax.swing.JButton buttonPuckDetCheck;
|
||||
private javax.swing.JButton buttonPuckDetStart;
|
||||
private javax.swing.JButton buttonPuckDetStop;
|
||||
private javax.swing.JButton buttonPutDewar;
|
||||
private javax.swing.JButton buttonPutGonio;
|
||||
private javax.swing.JButton buttonReleaseLocal;
|
||||
@@ -500,6 +579,7 @@ public class Expert extends Panel {
|
||||
private javax.swing.JLabel jLabel3;
|
||||
private javax.swing.JLabel jLabel4;
|
||||
private javax.swing.JPanel jPanel2;
|
||||
private javax.swing.JPanel jPanel3;
|
||||
private javax.swing.JPanel jPanel5;
|
||||
private javax.swing.JPanel panelCommands;
|
||||
private javax.swing.JPanel panelRobot;
|
||||
|
||||
@@ -53,6 +53,15 @@ def system_check(robot_move=True):
|
||||
raise Exception("Guiding tool not parked")
|
||||
|
||||
|
||||
def start_puck_detection():
|
||||
run("tools/RestartPuckDetection")
|
||||
|
||||
def check_puck_detection():
|
||||
return run("tools/CheckPuckDetection")
|
||||
|
||||
def stop_puck_detection():
|
||||
run("tools/StopPuckDetection")
|
||||
|
||||
###################################################################################################
|
||||
# Device initialization
|
||||
###################################################################################################
|
||||
|
||||
6
script/tools/CheckPuckDetection.py
Normal file
6
script/tools/CheckPuckDetection.py
Normal file
@@ -0,0 +1,6 @@
|
||||
USR,PWD = "pi", "raspberry"
|
||||
HOST,PORT = "tell-raspberrypi", 22
|
||||
CMD= "sudo systemctl status puck_detection.service"
|
||||
|
||||
ret = run("tools/SshExec")
|
||||
set_return(ret)
|
||||
6
script/tools/RestartPuckDetection.py
Normal file
6
script/tools/RestartPuckDetection.py
Normal file
@@ -0,0 +1,6 @@
|
||||
USR,PWD = "pi", "raspberry"
|
||||
HOST,PORT = "tell-raspberrypi", 22
|
||||
CMD= "sudo systemctl stop puck_detection.service;sudo systemctl start puck_detection.service"
|
||||
|
||||
ret = run("tools/SshExec")
|
||||
set_return(ret)
|
||||
61
script/tools/SshExec.py
Normal file
61
script/tools/SshExec.py
Normal file
@@ -0,0 +1,61 @@
|
||||
import com.jcraft.jsch.Channel as Channel
|
||||
import com.jcraft.jsch.ChannelShell as ChannelShell
|
||||
import com.jcraft.jsch.JSch as JSch
|
||||
import com.jcraft.jsch.JSchException as JSchException
|
||||
import com.jcraft.jsch.Session as Session
|
||||
import java.lang.System as System
|
||||
import java.io.PrintStream as PrintStream
|
||||
|
||||
|
||||
#Parameters:
|
||||
#CMD
|
||||
#USR
|
||||
#PWD
|
||||
#HOST
|
||||
#PORT
|
||||
|
||||
jsch= JSch()
|
||||
session=jsch.getSession(USR, HOST, PORT)
|
||||
session.setPassword(PWD)
|
||||
session.setConfig("StrictHostKeyChecking", "no")
|
||||
session.connect()
|
||||
|
||||
#channel=session.openChannel("shell")
|
||||
#input_stream=channel.getInputStream()
|
||||
#output_stream = channel.getOutputStream()
|
||||
#print_stream = PrintStream(output_stream, True)
|
||||
#print_stream.println("ls")
|
||||
|
||||
channel=session.openChannel("exec")
|
||||
channel.setCommand(CMD)
|
||||
channel.setInputStream(None)
|
||||
channel.setOutputStream(System.out)
|
||||
channel.setErrStream(System.err)
|
||||
input_stream=channel.getInputStream()
|
||||
|
||||
|
||||
def wait_ret():
|
||||
global input_stream
|
||||
rx = ""
|
||||
while True:
|
||||
while (input_stream.available() > 0):
|
||||
i = input_stream.read()
|
||||
if i < 0:
|
||||
break
|
||||
rx=rx+chr(i)
|
||||
if channel.closed:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
return rx
|
||||
|
||||
|
||||
channel.connect()
|
||||
|
||||
try:
|
||||
ret = wait_ret()
|
||||
except:
|
||||
channel.disconnect()
|
||||
session.disconnect()
|
||||
raise
|
||||
|
||||
set_return(ret)
|
||||
8
script/tools/StopPuckDetection.py
Normal file
8
script/tools/StopPuckDetection.py
Normal file
@@ -0,0 +1,8 @@
|
||||
USR,PWD = "pi", "raspberry"
|
||||
HOST,PORT = "tell-raspberrypi", 22
|
||||
CMD= "sudo systemctl stop puck_detection.service"
|
||||
|
||||
ret = run("tools/SshExec")
|
||||
set_return(ret)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user