Skip to content

Commit

Permalink
[69] logger update
Browse files Browse the repository at this point in the history
  • Loading branch information
mirage22 committed Oct 9, 2024
1 parent 094d15d commit d34aae4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,39 +17,42 @@
package com.robo4j.units.lego;

import com.robo4j.AttributeDescriptor;
import com.robo4j.ConfigurationException;
import com.robo4j.RoboContext;
import com.robo4j.configuration.Configuration;
import com.robo4j.hw.lego.enums.DigitalPortEnum;
import com.robo4j.hw.lego.enums.SensorTypeEnum;
import com.robo4j.hw.lego.wrapper.SensorTestWrapper;
import com.robo4j.units.lego.sonic.LegoSonicServoMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Marcus Hirt (@hirt)
* @author Miro Wengner (@miragemiko)
*/
// TODO : verify usage
public class BasicSonicSensorServoUnitMock extends BasicSonicServoUnit {
private static final Logger LOGGER = LoggerFactory.getLogger(BasicSonicSensorServoUnitMock.class);

public BasicSonicSensorServoUnitMock(RoboContext context, String id) {
super(context, id);
}

@Override
protected void onInitialization(Configuration configuration) throws ConfigurationException {
protected void onInitialization(Configuration configuration) {
super.sensor = new SensorTestWrapper(DigitalPortEnum.S3, SensorTypeEnum.SONIC);
System.out.println("on initialization");
LOGGER.info("on initialization");
}

@Override
public void onMessage(LegoSonicServoMessage message) {
System.out.println("onMessage : " + message);
LOGGER.info("onMessage : {}", message);
}

@Override
public void shutdown() {
super.shutdown();
System.out.println("executor is down");
LOGGER.info("executor is down");
}

@SuppressWarnings("unchecked")
Expand All @@ -62,5 +65,4 @@ public <R> R onGetAttribute(AttributeDescriptor<R> attribute) {
}



}
Original file line number Diff line number Diff line change
Expand Up @@ -60,20 +60,20 @@ public static void main(String[] args) throws RoboBuilderException, FileNotFound
LOGGER.info("State after start:");
LOGGER.info(SystemUtil.printStateReport(ctx));

String lastCommand = "";
String lastCommand;
Scanner scanner = new Scanner(System.in);
LOGGER.info(
"Type the roboclaw unit to control and the speed [-1, 1] and angular direction[-180, 180]. For example:\ntank 1 0\nType q and enter to quit!\n");
while (!"q".equals(lastCommand = scanner.nextLine())) {
lastCommand = lastCommand.trim();
String[] split = lastCommand.split(" ");
if (split.length != 3) {
System.out.println("Could not parse " + lastCommand + ". Please try again!");
LOGGER.warn("Could not parse {}. Please try again!", lastCommand);
continue;
}
RoboReference<MotionEvent> servoRef = ctx.getReference(split[0]);
if (servoRef == null) {
System.out.println("Could not find any robo unit named " + split[0] + ". Please try again!");
LOGGER.warn("Could not find any robo unit named {}. Please try again!", split[0]);
continue;
}
try {
Expand Down

0 comments on commit d34aae4

Please sign in to comment.