Skip to content

Commit

Permalink
Merge branch 'develop' of github.com-myrobotlab:MyRobotLab/myrobotlab…
Browse files Browse the repository at this point in the history
… into jmonkey-updates
  • Loading branch information
supertick committed Feb 24, 2024
2 parents 87e60f2 + a247c31 commit 3335702
Show file tree
Hide file tree
Showing 193 changed files with 1,806 additions and 1,104 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Open Source Framework for Robotics and Creative Machine Control

* Project Website http://myrobotlab.org
* Project Discord https://discord.gg/AfScp5x8r5
* Latest Build [Nixie 1.1.(Latest)](https://github.com/MyRobotLab/myrobotlab/releases/latest/download/myrobotlab.zip)
* Latest Build [Nixie 1.1.(Latest)](https://build.myrobotlab.org:8443/job/myrobotlab/job/develop/lastSuccessfulBuild/artifact/target/myrobotlab.zip)
* Latest Javadocs [Javdocs](http://build.myrobotlab.org:8080/job/myrobotlab/job/develop/lastSuccessfulBuild/artifact/target/site/apidocs/org/myrobotlab/service/package-summary.html)

## Base Requirements
Expand All @@ -18,7 +18,7 @@ You will need Java 11 or newer. If you are only running MyRobotLab you need the
## Download the myrobotlab.zip
Download

latest [Nixie 1.1.X](https://github.com/MyRobotLab/myrobotlab/releases/latest/download/myrobotlab.zip)
latest [Nixie 1.1.X](https://build.myrobotlab.org:8443/job/myrobotlab/job/develop/lastSuccessfulBuild/artifact/target/myrobotlab.zip)

## Starting MyRobotLab

Expand Down
2 changes: 1 addition & 1 deletion myrobotlab.bat
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ IF NOT "%*"=="" (
"%JAVA%" %JAVA_OPTIONS% -cp %CLASSPATH% org.myrobotlab.service.Runtime --install --log-file myrobotlab-install.log
)

"%JAVA%" %JAVA_OPTIONS% -cp %CLASSPATH% org.myrobotlab.service.Runtime --log-level info -s webgui WebGui intro Intro python Python
"%JAVA%" %JAVA_OPTIONS% -cp %CLASSPATH% org.myrobotlab.service.Runtime --log-level info -s log Log webgui WebGui intro Intro python Python

)
2 changes: 1 addition & 1 deletion myrobotlab.sh
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,6 @@ else
"${JAVA}" ${JAVA_OPTIONS} -cp ${CLASSPATH} org.myrobotlab.service.Runtime --install --log-file myrobotlab-install.log
fi

"${JAVA}" ${JAVA_OPTIONS} -cp ${CLASSPATH} org.myrobotlab.service.Runtime --log-level info -s webgui WebGui intro Intro python Python
"${JAVA}" ${JAVA_OPTIONS} -cp ${CLASSPATH} org.myrobotlab.service.Runtime --log-level info -s log Log webgui WebGui intro Intro python Python

echo $# $@
71 changes: 71 additions & 0 deletions src/main/java/org/myrobotlab/config/ConfigUtils.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.myrobotlab.config;

import java.io.File;
import java.io.IOException;

import org.myrobotlab.codec.CodecUtils;
import org.myrobotlab.framework.StartYml;
import org.myrobotlab.io.FileIO;
import org.myrobotlab.service.Runtime;
import org.myrobotlab.service.config.RuntimeConfig;

public class ConfigUtils {

/**
* This gets the current resource root without starting a Runtime instance if
* not already started. The resource root depends on config, if Runtime is
* running the logic and current config name is already available. If Runtime
* is not running, we need to go through a series of steps to deterime where
* the resource root is configured.
*
* @return
*/
public static String getResourceRoot() {

String resource = "resource";

// check if runtime is running
if (!Runtime.isAvailable()) {
// check for start.yml

File checkStartYml = new File("start.yml");
StartYml startYml = new StartYml();
if (checkStartYml.exists()) {
String yml;
try {
yml = FileIO.toString("start.yml");
startYml = CodecUtils.fromYaml(yml, StartYml.class);

// see if autostart is on with a config
if (startYml.enable) {
// use that config to find runtime.yml

File runtimeYml = new File(Runtime.ROOT_CONFIG_DIR + File.separator + startYml.config + File.separator + "runtime.yml");
if (runtimeYml.exists()) {
// parse that file look for resource: entry in file
RuntimeConfig config = (RuntimeConfig) CodecUtils.readServiceConfig(runtimeYml.getAbsolutePath());
resource = config.resource;
}

} else {
// start.yml enable = false / so we'll use default config
File runtimeYml = new File(Runtime.ROOT_CONFIG_DIR + File.separator + "default" + File.separator + "runtime.yml");
if (runtimeYml.exists()) {
// parse that file look for resource: entry in file
RuntimeConfig config = (RuntimeConfig) CodecUtils.readServiceConfig(runtimeYml.getAbsolutePath());
resource = config.resource;
}
}

} catch (IOException e) {
// problem getting or parsing
// going to assume default "resource"
}
} // no startYml
return resource;
} else {
// Runtime is available - ask it
return Runtime.getInstance().getConfig().resource;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import org.myrobotlab.document.Document;
import org.myrobotlab.document.transformer.ConnectorConfig;
import org.myrobotlab.framework.Service;
import org.myrobotlab.service.config.ServiceConfig;
import org.myrobotlab.service.config.AbstractConnectorConfig;
import org.myrobotlab.service.interfaces.DocumentConnector;
import org.myrobotlab.service.interfaces.DocumentPublisher;

Expand All @@ -17,7 +17,7 @@
* service.
*
*/
public abstract class AbstractConnector extends Service<ServiceConfig> implements DocumentPublisher, DocumentConnector {
public abstract class AbstractConnector <C extends AbstractConnectorConfig> extends Service<C> implements DocumentPublisher, DocumentConnector {

private static final long serialVersionUID = 1L;
protected ConnectorState state = ConnectorState.STOPPED;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/myrobotlab/image/WebImage.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public WebImage(final BufferedImage img, final String source, Integer frameIndex
if (quality == null) {
ImageIO.write(img, imgType, os);
os.close();
data = String.format("data:image/%s;base64,%s", type,CodecUtils.toBase64(os.toByteArray()));
data = String.format("data:image/%s;base64,%s", imgType,CodecUtils.toBase64(os.toByteArray()));
} else {

// save jpeg image with specific quality. "1f" corresponds to 100% ,
Expand Down
17 changes: 11 additions & 6 deletions src/main/java/org/myrobotlab/service/AdafruitIna219.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.myrobotlab.logging.LoggerFactory;
import org.myrobotlab.logging.Logging;
import org.myrobotlab.logging.LoggingFactory;
import org.myrobotlab.service.config.ServiceConfig;
import org.myrobotlab.service.config.AdafruitIna219Config;
import org.myrobotlab.service.interfaces.I2CControl;
import org.myrobotlab.service.interfaces.I2CController;
import org.myrobotlab.service.interfaces.VoltageSensorControl;
Expand All @@ -26,7 +26,8 @@
*
* References : https://www.adafruit.com/products/904
*/
public class AdafruitIna219 extends Service<ServiceConfig> implements I2CControl, VoltageSensorControl {
public class AdafruitIna219 extends Service<AdafruitIna219Config> implements I2CControl,VoltageSensorControl
{

private static final long serialVersionUID = 1L;

Expand All @@ -36,7 +37,8 @@ public class AdafruitIna219 extends Service<ServiceConfig> implements I2CControl
public static final byte INA219_SHUNTVOLTAGE = 0x01;
public static final byte INA219_BUSVOLTAGE = 0x02;

public List<String> deviceAddressList = Arrays.asList("0x40", "0x41", "0x42", "0x43", "0x44", "0x45", "0x46", "0x47", "0x48", "0x49", "0x4A", "0x4B", "0x4C", "0x4D", "0x4E",
public List<String> deviceAddressList = Arrays.asList("0x40", "0x41", "0x42", "0x43", "0x44", "0x45", "0x46", "0x47",
"0x48", "0x49", "0x4A", "0x4B", "0x4C", "0x4D", "0x4E",
"0x4F");

public String deviceAddress = "0x40";
Expand Down Expand Up @@ -171,7 +173,8 @@ public double getCurrent() {
public double getShuntVoltage() {
byte[] writebuffer = { INA219_SHUNTVOLTAGE };
byte[] readbuffer = { 0x0, 0x0 };
controller.i2cWrite(this, Integer.parseInt(deviceBus), Integer.decode(deviceAddress), writebuffer, writebuffer.length);
controller.i2cWrite(this, Integer.parseInt(deviceBus), Integer.decode(deviceAddress), writebuffer,
writebuffer.length);
controller.i2cRead(this, Integer.parseInt(deviceBus), Integer.decode(deviceAddress), readbuffer, readbuffer.length);
// log.info(String.format("getShuntVoltage x%02X x%02X", readbuffer[0],
// readbuffer[1]));
Expand All @@ -189,14 +192,16 @@ public double getShuntVoltage() {
public double getBusVoltage() {
byte[] writebuffer = { INA219_BUSVOLTAGE };
byte[] readbuffer = { 0x0, 0x0 };
controller.i2cWrite(this, Integer.parseInt(deviceBus), Integer.decode(deviceAddress), writebuffer, writebuffer.length);
controller.i2cWrite(this, Integer.parseInt(deviceBus), Integer.decode(deviceAddress), writebuffer,
writebuffer.length);
controller.i2cRead(this, Integer.parseInt(deviceBus), Integer.decode(deviceAddress), readbuffer, readbuffer.length);
// A bit tricky conversion. The LSB needs to be right shifted 3 bits, so
// the MSB needs to be left shifted (8-3) = 5 bits
// And bytes are signed in Java so first a mask of 0xff needs to be
// applied to the MSB to remove the sign
int rawBusVoltage = ((readbuffer[0] & 0xff) << 8 | readbuffer[1] & 0xff) >> 3;
log.debug("Busvoltage high byte = {}, low byte = {}, rawBusVoltagee = {}", readbuffer[0], readbuffer[1], rawBusVoltage);
log.debug("Busvoltage high byte = {}, low byte = {}, rawBusVoltagee = {}", readbuffer[0], readbuffer[1],
rawBusVoltage);
// LSB = 4mV, so multiply wit 4 to get the volatage in mV
busVoltage = rawBusVoltage * 4;
return busVoltage;
Expand Down
5 changes: 3 additions & 2 deletions src/main/java/org/myrobotlab/service/Android.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
import org.myrobotlab.logging.LoggerFactory;
import org.myrobotlab.logging.Logging;
import org.myrobotlab.logging.LoggingFactory;
import org.myrobotlab.service.config.ServiceConfig;
import org.myrobotlab.service.config.AndroidConfig;
import org.slf4j.Logger;

public class Android extends Service<ServiceConfig> {
public class Android extends Service<AndroidConfig>
{

private static final long serialVersionUID = 1L;

Expand Down
Loading

0 comments on commit 3335702

Please sign in to comment.