This commit is contained in:
gac-S_Changer
2018-12-14 15:25:12 +01:00
parent da3bf82cfe
commit 927c6acc46
7 changed files with 39 additions and 19 deletions

View File

@@ -1,4 +1,5 @@
import ch.psi.pshell.core.Context;
import ch.psi.pshell.device.Device;
import ch.psi.pshell.swing.DevicePanel;
import ch.psi.utils.swing.SwingUtils;
import java.util.concurrent.CompletableFuture;
@@ -17,11 +18,21 @@ public class BarcodeReaderPanel extends DevicePanel {
CompletableFuture future;
@Override
public void setDevice(Device device){
super.setDevice(device);
if (device != null){
deviceStatePanel1.setDevice(device);
deviceValuePanel1.setDevice(device);
}
}
@Override
public void onTimer(){
if ((getDevice()!=null) && enabled){
if ((future==null) || (future.isDone())){
future = Context.getInstance().evalLineBackgroundAsync("barcode_reader.get()");
future = Context.getInstance().evalLineBackgroundAsync(getDevice().getName() + ".get()");
}
}
}
@@ -109,10 +120,7 @@ public class BarcodeReaderPanel extends DevicePanel {
.addContainerGap())
);
deviceStatePanel1.setDeviceName("barcode_reader");
deviceValuePanel1.setBorder(javax.swing.BorderFactory.createTitledBorder("Value"));
deviceValuePanel1.setDeviceName("barcode_reader");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
@@ -135,18 +143,18 @@ public class BarcodeReaderPanel extends DevicePanel {
}// </editor-fold>//GEN-END:initComponents
private void buttonEnableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonEnableActionPerformed
execute("barcode_reader.enable()", false);
execute(getDevice().getName() + ".enable()", false);
enabled = true;
}//GEN-LAST:event_buttonEnableActionPerformed
private void buttonDisableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonDisableActionPerformed
enabled = false;
execute("barcode_reader.disable()", false);
execute(getDevice().getName() + ".disable()", false);
}//GEN-LAST:event_buttonDisableActionPerformed
private void buttonReadActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_buttonReadActionPerformed
enabled = false;
execute("barcode_reader.read(5.0) ", true);
execute(getDevice().getName() + ".read(5.0) ", true);
}//GEN-LAST:event_buttonReadActionPerformed