5 changed files with 77 additions and 9 deletions
-
BINapp.db
-
23src/main/java/com/iflytop/a800/controller/DeviceController.java
-
2src/main/java/com/iflytop/a800/device/Device.java
-
54src/main/java/com/iflytop/a800/device/TrashBox.java
-
7src/main/java/com/iflytop/a800/task/TubeTestTask.java
@ -0,0 +1,54 @@ |
|||
package com.iflytop.a800.device; |
|||
import com.iflytop.uf.UfActuatorCmdExecutor; |
|||
import com.iflytop.uf.model.UfMdbNotification; |
|||
import com.iflytop.uf.model.UfMdbRuntimeVariable; |
|||
import com.iflytop.uf.util.UfCommon; |
|||
public class TrashBox { |
|||
// 是否已满 |
|||
private Boolean isFull = false; |
|||
// 清空锁 |
|||
private final Object emptyLock = new Object(); |
|||
|
|||
// 获取是否已满 |
|||
public Boolean getIsFull() { |
|||
return this.isFull; |
|||
} |
|||
|
|||
// 清理 |
|||
public void clean() { |
|||
synchronized ( this.emptyLock ) { |
|||
this.emptyLock.notifyAll(); |
|||
} |
|||
} |
|||
|
|||
// 等待清空 |
|||
public void waitForEmpty() { |
|||
do { |
|||
UfMdbNotification.action("TrashBoxCleanRequest"); |
|||
|
|||
synchronized (this.emptyLock) { |
|||
try { |
|||
this.emptyLock.wait(); |
|||
} catch (InterruptedException e) { |
|||
throw new RuntimeException(e); |
|||
} |
|||
} |
|||
this.isFull = false; |
|||
this.recheckIsFull(); |
|||
} while (this.getIsFull()); |
|||
} |
|||
|
|||
// 重新检查是否满 |
|||
public void recheckIsFull() { |
|||
if ( this.getIsFull() ) { |
|||
return ; |
|||
} |
|||
|
|||
UfActuatorCmdExecutor.execute("TrashBox", "extboard_write_outio", "0,1"); |
|||
UfCommon.delay(500); |
|||
String isFullStr = UfActuatorCmdExecutor.execute("TrashBox","extboard_read_inio", "2"); |
|||
this.isFull = "1".equals(isFullStr); |
|||
UfMdbRuntimeVariable.setString("IsTrashBoxFull", this.isFull ? "yes" : "no"); |
|||
UfActuatorCmdExecutor.execute("TrashBox", "extboard_write_outio", "0,0"); |
|||
} |
|||
} |
Write
Preview
Loading…
Cancel
Save
Reference in new issue