/** * Returns the protocol associated with a SensorID (assuming the sensor owner is already * associated with a protocol) * * @throws NotFoundException if the sensor can not be found * @throws SALRunTimeException if the sensoor isnt associated with any protocol, or the protocol * object cant be found (shouldnt happen, but...) */ AbstractProtocol getProtocol(SensorID sid) throws NotFoundException { AbstractProtocol p = null; String pName = null; Sensor s; if ((s = SensorManager.getSensorManager().getComponent(sid)) == null) { // logger.error("Cannot find the any sensor with this sensorID: " + sid.toString()); throw new NotFoundException("No sensor with this sensorID"); } if ((pName = s.getID().getPIDName()) == null) { logger.error("Cannot find the protocolID associated with this sensorID: " + sid.toString()); throw new SALRunTimeException( "we shouldnt be here - sensor not associated with any protocol ??"); } if ((p = getComponent(new ProtocolID(pName))) == null) { logger.error("Cannot find the protocol associated with this sensorID: " + sid.toString()); throw new SALRunTimeException( "We shouldnt be here - cant find the protocol the sensor is associated with"); } return p; }