/** Get current sensor values */ @OPERATION void getCurrentScan() { logger1.info("ArtScan >> getCurrentScan()"); ObsProperty prop = getObsProperty(propertyName); if (currentScan != null) // prop.updateValues(checkNan(currentScan[0]), checkNan(currentScan[(int) // (laserScanSize*0.25)]), checkNan(currentScan[(int) (laserScanSize*0.5)]), // checkNan(currentScan[(int) (laserScanSize*0.75)]), checkNan(currentScan[laserScanSize-1])); // prop.updateValues(checkNan(currentScan[0]), checkNan(currentScan[182]), // checkNan(currentScan[363]), checkNan(currentScan[544]), // checkNan(currentScan[laserScanSize-1])); prop.updateValues( checkNan(currentScan[0]), checkNan(currentScan[127]), checkNan(currentScan[255]), checkNan(currentScan[384]), checkNan(currentScan[laserScanSize - 1])); else prop.updateValues(50000f, 50000f, 50000f, 50000f, 50000f); // logger1.info("ArtScan >> Value:" + prop); logger1.info("ArtScan >> end of getCurrentScan()"); // 182, 363, 544, 725 hokuyo scan // 0, 270, 514, 810, 1080 // 0, 159, 319, 479, 639 // System.out.println("ArtScan >> getCurrentScan()"); // ObsProperty prop = getObsProperty(propertyName); // prop.updateValues(prop.getValues()); signal("tick_scan"); }
@OPERATION public void bid(double bidValue, int count) { if (!getObsProperty("running").booleanValue()) failed("auction not started"); getObsProperty("answer_count").updateValue(count + 1); ObsProperty opCurrentValue = getObsProperty("best_bid"); if (bidValue < opCurrentValue.doubleValue()) { // the bid is better than // the previous opCurrentValue.updateValue(bidValue); chosenAgent = getOpUserName(); // the name of the agent doing this // operation } System.out.println("Received bid " + bidValue + " from " + getOpUserName()); }
@OPERATION void sense() { OpFeedbackParam<PersonSenseData[]> people = new OpFeedbackParam<>(); OpFeedbackParam<PoTSenseData[]> points = new OpFeedbackParam<>(); try { execLinkedOp("env-link", "sense", ID, people, points); ObsProperty peoplep = getObsProperty("people"); ObsProperty pointsp = getObsProperty("points"); peoplep.updateValue(toArray(people.get())); pointsp.updateValue(toArray(points.get())); } catch (Exception e) { e.printStackTrace(); failed("Sense linked operation failed", "fail", ID, e); } }
/** The command code */ public void exec() { try { ObsProperty prop = getObsProperty(propertyName); prop.updateValues( checkNan(currentScan[0]), checkNan(currentScan[(int) (laserScanSize * 0.25)]), checkNan(currentScan[(int) (laserScanSize * 0.5)]), checkNan(currentScan[(int) (laserScanSize * 0.75)]), checkNan(currentScan[laserScanSize - 1])); // prop.updateValues(checkNan(currentScan[0]), checkNan(currentScan[182]), // checkNan(currentScan[363]), checkNan(currentScan[544]), // checkNan(currentScan[laserScanSize-1])); } catch (Exception ex) { ex.printStackTrace(); } }