parse ScannedData serial number

android-scanner
Laura Radaelli 2017-04-27 16:32:12 +03:00
parent 4e1b66f890
commit 646824de44
2 changed files with 9 additions and 6 deletions

View File

@ -22,6 +22,7 @@ public class PollingStationMainController implements PollingStationControllerInt
private static final String SUB_ADDRESS = "";
private static final int PORT = 8080;
public PollingStationMainController() {
queue = new LinkedBlockingQueue<PollingStationCommand>();
shutDownHasBeenCalled = false;
@ -80,7 +81,7 @@ public class PollingStationMainController implements PollingStationControllerInt
private void doProcessScan(ReceivedScanCommand command) {
logger.info("The Polling Station starts processing the data...");
logger.info("BallotID = "+command.getBallotSerialNumber());
logger.info("Ballot Serial Number = "+command.getBallotSerialNumber());
}
/**
@ -92,7 +93,7 @@ public class PollingStationMainController implements PollingStationControllerInt
}
@Override
// TODO: 4/16/2017 Implemet the shutdown behavior
// TODO: 4/16/2017 Implement the shutdown behavior
public void callShutDown() {
}

View File

@ -16,6 +16,7 @@ import org.glassfish.jersey.server.ResourceConfig;
import org.glassfish.jersey.servlet.ServletContainer;
import java.nio.ByteBuffer;
import java.time.Instant;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.LinkedBlockingQueue;
@ -115,12 +116,13 @@ public class ReceiverScanHandler implements PollingStationScanner.Consumer, Runn
}
}
// TODO: 4/16/2017 Parse protobuf fields properly
// TODO: 4/27/2017 set requestID properly
private void doScannedData(ScanDataCallback cb) {
PollingStation.ScannedData scan = cb.getScannedData();
int channel = ByteBuffer.wrap(scan.getChannel().toByteArray()).getInt();
long channelLong = 12345678910L;
controllerQueue.add(new ReceivedScanCommand(channel, channelLong));
// String channel = scan.getChannel().toStringUtf8();
int requestID = 1;
long serialNumber = scan.getSignedEncryptedBallot().getEncryptedBallot().getSerialNumber();
controllerQueue.add(new ReceivedScanCommand(requestID, serialNumber));
}
private void doScanError(ScanErrorCallback cb) {