Skip to content

Commit

Permalink
Fixed bugs regarding local cells. Disabled output pin shutdown and in…
Browse files Browse the repository at this point in the history
…itial state. Added minimum pulse time for stepper drivers
  • Loading branch information
alex9849 committed Dec 15, 2024
1 parent c0bc838 commit c998e30
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 8 deletions.
2 changes: 1 addition & 1 deletion backend/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@
<dependency>
<groupId>net.alex9849.motorlib</groupId>
<artifactId>motorlib</artifactId>
<version>0.1.6</version>
<version>0.1.8</version>
</dependency>
<dependency>
<groupId>io.jsonwebtoken</groupId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,16 @@ public void digitalWrite(PinState value) {
public boolean isHigh() {
return false;
}

@Override
public void digitalWriteAndWait(PinState state) {

}

@Override
public void setWaitAfterWriteTimeNs(long waitAfterWriteTimeNs) {

}
};
motorDriver = new DCMotor(runPin, dirPin, isPowerStateHigh()? PinState.HIGH : PinState.LOW);
}
Expand All @@ -65,7 +75,7 @@ public double getConvertRuntimeToMl(int runtime) {
}

public void shutdownDriver() {
if(this.motorDriver != null) {
if(this.isCanPump() && this.getMotorDriver() != null) {
this.motorDriver.shutdown();
this.motorDriver = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public void setAcceleration(Integer acceleration) {
}

public void shutdownDriver() {
if(this.stepperDriver != null) {
if(this.isCanPump() && this.getMotorDriver() != null) {
this.stepperDriver.shutdown();
this.stepperDriver = null;
}
Expand Down Expand Up @@ -102,6 +102,16 @@ public void digitalWrite(PinState value) {
public boolean isHigh() {
return false;
}

@Override
public void digitalWriteAndWait(PinState state) {

}

@Override
public void setWaitAfterWriteTimeNs(long waitAfterWriteTimeNs) {

}
};

IStepperMotor motor = new StepperDriver(enablePin, stepPin, dirPin);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public boolean isCanControlDirection() {
}

public Double getTubeCapacityInMl() {
return 1d;
return 3d;
}

public void setTubeCapacityInMl(Double tubeCapacityInMl) {
Expand All @@ -46,7 +46,7 @@ public ValveDriver getMotorDriver() {

@Override
public void shutdownDriver() {
if(this.motorDriver != null) {
if(this.isCanPump() && this.getMotorDriver() != null) {
this.motorDriver.shutdown();
this.motorDriver = null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@ public synchronized IOutputPin getBoardOutputPin(int address) {
DigitalOutputConfig config = DigitalOutput
.newConfigBuilder(pi4J)
.address(address)
.shutdown(DigitalState.LOW)
.initial(DigitalState.LOW)
.build();

if(!pi4J.registry().exists(config.id())) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import lombok.SneakyThrows;
import net.alex9849.cocktailpi.config.seed.SeedDataInserter;
import net.alex9849.cocktailpi.service.PumpService;
import org.flywaydb.core.Flyway;
import org.springframework.beans.BeanWrapper;
import org.springframework.beans.BeanWrapperImpl;
Expand All @@ -22,6 +23,9 @@ public class SpringUtility implements ApplicationContextAware {
@Autowired
private SeedDataInserter seedDataInserter;

@Autowired
private PumpService pumpService;


@Autowired
private static ApplicationContext applicationContext;
Expand All @@ -31,6 +35,7 @@ public void setApplicationContext(final ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
flyway.migrate();
seedDataInserter.migrate();
pumpService.stopAllPumps();
}

/*
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

<properties>
<java.version>17</java.version>
<pi4j.version>2.6.0</pi4j.version>
<pi4j.version>2.7.0</pi4j.version>
</properties>

<repositories>
Expand Down

0 comments on commit c998e30

Please sign in to comment.