This commit is contained in:
gac-S_Changer
2018-06-29 11:27:20 +02:00
parent 51858eb819
commit 4371d9c6d8
38 changed files with 379 additions and 61 deletions
+19 -2
View File
@@ -49,7 +49,7 @@
<Component id="panelRobot1" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace pref="29" max="32767" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -383,6 +383,7 @@
<Component id="jLabel2" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" linkSize="1" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
@@ -390,6 +391,7 @@
<Component id="spinnerSample" linkSize="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerPuck" linkSize="2" min="-2" max="-2" attributes="0"/>
<Component id="spinnerSegment" linkSize="2" min="-2" max="-2" attributes="0"/>
<Component id="checkDatamatrix" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
@@ -418,7 +420,12 @@
<Component id="jLabel4" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="checkForce" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Group type="103" groupAlignment="2" attributes="0">
<Component id="jLabel5" alignment="2" min="-2" max="-2" attributes="0"/>
<Component id="checkDatamatrix" alignment="2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@@ -477,6 +484,16 @@
<Property name="text" type="java.lang.String" value="Sample:"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel5">
<Properties>
<Property name="text" type="java.lang.String" value="Read DM:"/>
</Properties>
</Component>
<Component class="javax.swing.JCheckBox" name="checkDatamatrix">
<Properties>
<Property name="horizontalTextPosition" type="int" value="10"/>
</Properties>
</Component>
</SubComponents>
</Container>
<Component class="javax.swing.JButton" name="buttonMovePark">
+20 -5
View File
@@ -114,6 +114,8 @@ public class Expert extends Panel {
jLabel2 = new javax.swing.JLabel();
spinnerSegment = new javax.swing.JSpinner();
jLabel3 = new javax.swing.JLabel();
jLabel5 = new javax.swing.JLabel();
checkDatamatrix = new javax.swing.JCheckBox();
buttonMovePark = new javax.swing.JButton();
buttonHomingHexiposi = new javax.swing.JButton();
buttonMoveHome = new javax.swing.JButton();
@@ -309,6 +311,10 @@ public class Expert extends Panel {
jLabel3.setText("Sample:");
jLabel5.setText("Read DM:");
checkDatamatrix.setHorizontalTextPosition(javax.swing.SwingConstants.LEADING);
javax.swing.GroupLayout jPanel5Layout = new javax.swing.GroupLayout(jPanel5);
jPanel5.setLayout(jPanel5Layout);
jPanel5Layout.setHorizontalGroup(
@@ -319,13 +325,15 @@ public class Expert extends Panel {
.addComponent(jLabel3)
.addComponent(jLabel2)
.addComponent(jLabel1)
.addComponent(jLabel4))
.addComponent(jLabel4)
.addComponent(jLabel5))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(checkForce)
.addComponent(spinnerSample, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerPuck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(spinnerSegment, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(checkDatamatrix))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
);
@@ -352,7 +360,11 @@ public class Expert extends Panel {
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel4)
.addComponent(checkForce))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(jPanel5Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
.addComponent(jLabel5)
.addComponent(checkDatamatrix))
.addGap(0, 0, 0))
);
buttonMovePark.setText("Move Park");
@@ -627,7 +639,7 @@ public class Expert extends Panel {
.addComponent(panelRobot, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(panelRobot1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addContainerGap(29, Short.MAX_VALUE))
.addContainerGap(23, Short.MAX_VALUE))
);
}// </editor-fold>//GEN-END:initComponents
@@ -640,7 +652,8 @@ public class Expert extends Panel {
int puck = (Integer) spinnerPuck.getValue();
int sample = (Integer) spinnerSample.getValue();
String force = checkForce.isSelected() ? "True" : "False";
execute("mount('" + segment + "'," + puck + "," + sample + ", force=" + force + ")");
String readDatamatrix = checkDatamatrix.isSelected() ? "True" : "False";
execute("mount('" + segment + "'," + puck + "," + sample + ", force=" + force + ", read_dm=" + readDatamatrix + ")");
}//GEN-LAST:event_buttonMountActionPerformed
@@ -779,11 +792,13 @@ public class Expert extends Panel {
private javax.swing.JButton buttonReleasePsys;
private javax.swing.JToggleButton buttonStream;
private javax.swing.JButton buttonUnmount;
private javax.swing.JCheckBox checkDatamatrix;
private javax.swing.JCheckBox checkForce;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JLabel jLabel7;
private javax.swing.JPanel jPanel2;
+5
View File
@@ -37,6 +37,11 @@ public class LN2 extends Panel {
}
@Override
public void onStop() {
super.onStop();
}
@Override
public void onStateChange(State state, State former) {
Binary file not shown.
+149
View File
@@ -0,0 +1,149 @@
import ch.psi.pshell.imaging.SourceBase;
import ch.psi.pshell.imaging.SourceConfig;
import ch.psi.pshell.imaging.Utils;
import java.awt.image.BufferedImage;
import java.io.BufferedInputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.logging.Level;
/**
* Image source receive frames from a mjpeg server.
*/
public class MjpegSource2 extends SourceBase {
final String url;
final boolean flushOnUpdate;
public MjpegSource2(String name, String url) {
this(name, url, false);
}
public MjpegSource2(String name, String url, boolean flushOnUpdate) {
super(name, new SourceConfig());
this.url = url;
this.flushOnUpdate = flushOnUpdate;
}
InputStream stream;
@Override
protected void doInitialize() throws IOException, InterruptedException {
super.doInitialize();
URL aux = new URL(url);
stream = aux.openStream();
// if (!stream.markSupported()) {
stream = new BufferedInputStream(stream);
// }
}
Thread monitoredThread;
@Override
protected void doSetMonitored(boolean value) {
if (value && (monitoredThread == null)) {
monitoredThread = new Thread(() -> {
try {
while (true) {
try {
doUpdate();
Thread.sleep(1);
} catch (IOException ex) {
getLogger().log(Level.FINE, null, ex);
}
}
} catch (InterruptedException ex) {
return;
}
});
monitoredThread.setDaemon(true);
monitoredThread.start();
} else if (!value && (monitoredThread != null)) {
monitoredThread.interrupt();
monitoredThread = null;
}
}
final byte[] START_OF_FRAME = {(byte) 0xFF, (byte) 0xD8};
final byte[] END_OF_FRAME = {(byte) 0xFF, (byte) 0xD9};
final int MAX_FRAME_SIZE = 512 * 1024;
@Override
protected void doUpdate() throws IOException, InterruptedException {
byte[] data = null;
if (stream != null) {
if (flushOnUpdate) {
flush();
}
try {
data = readData();
} catch (EOFException ex) {
//Try to reopen stream
doInitialize();
data = readData();
}
}
if (data == null) {
pushImage(null);
} else {
BufferedImage img = Utils.newImage(data);
pushImage(img);
}
}
byte[] readData() throws IOException {
if (stream != null) {
stream.mark(MAX_FRAME_SIZE);
int startOfFrame = waitBytes(START_OF_FRAME) - START_OF_FRAME.length;
if (startOfFrame >= 0) {
int endOfFrame = waitBytes(END_OF_FRAME);
if (endOfFrame >= 0) {
stream.reset();
stream.skip(startOfFrame);
int length = endOfFrame - END_OF_FRAME.length;
byte[] data = new byte[length];
stream.read(data, 0, length);
return data;
}
}
}
return null;
}
int waitBytes(byte[] data) throws IOException {
int index = 0;
int dataPos = 0;
while (true) {
int ret = stream.read();
if (ret < 0) {
throw new EOFException();
}
byte value = (byte) ret;
if (value == data[dataPos]) {
dataPos++;
if (dataPos == data.length) {
return (index + 1);
}
} else {
dataPos = 0;
}
index++;
if (index >= MAX_FRAME_SIZE) {
return -1;
}
}
}
public void flush() throws IOException {
//stream.skip(stream.available());
//TODO: Skipping won't make the current image to be displayed
stream.close();
stream = new URL(url).openStream();
if (!stream.markSupported()) {
stream = new BufferedInputStream(stream);
}
}
}