-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
200 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
__author__ = 'paoolo' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package amber.location_proto; | ||
option java_package = "pl.edu.agh.amber.location.proto"; | ||
option java_outer_classname = "LocationProto"; | ||
|
||
import "drivermsg.proto"; | ||
|
||
extend amber.DriverMsg { | ||
optional bool get_location = 60; | ||
optional Location currentLocation = 61; | ||
} | ||
|
||
message Location { | ||
optional double x = 1; | ||
optional double y = 2; | ||
optional double p = 3; | ||
optional double alfa = 4; | ||
optional double timeStamp = 5; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import logging | ||
import logging.config | ||
import os | ||
|
||
from amber.common import amber_proxy, future_object | ||
from amber.common import amber_proxy | ||
|
||
__author__ = 'paoolo' | ||
|
||
DEVICE_TYPE = 6 | ||
|
||
LOGGER_NAME = 'LocationProxy' | ||
pwd = os.path.dirname(os.path.abspath(__file__)) | ||
try: | ||
logging.config.fileConfig('%s/location.ini' % pwd) | ||
except BaseException: | ||
print 'Logging not set.' | ||
|
||
|
||
class LocationProxy(amber_proxy.AmberProxy): | ||
def __init__(self, amber_client, device_id): | ||
super(LocationProxy, self).__init__(DEVICE_TYPE, device_id, amber_client) | ||
self.__amber_client, self.__syn_num, self.__future_objs, self.__listener = amber_client, 0, {}, None | ||
|
||
self.__logger = logging.getLogger(LOGGER_NAME) | ||
self.__logger.setLevel(logging.WARNING) | ||
|
||
self.__logger.info('Starting and registering LocationProxy.') | ||
|
||
def __get_next_syn_num(self): | ||
self.__syn_num += 1 | ||
return self.__syn_num | ||
|
||
def handle_data_msg(self, header, message): | ||
pass | ||
|
||
def get_location(self): | ||
self.__logger.debug('Get location') | ||
|
||
syn_num = self.__get_next_syn_num() | ||
|
||
driver_msg = self.__build_get_location_req_msg(syn_num) | ||
|
||
location = Location() | ||
self.__future_objs[syn_num] = location | ||
|
||
self.__amber_client.send_message(self.build_header(), driver_msg) | ||
|
||
return location | ||
|
||
|
||
class Location(future_object.FutureObject): | ||
def __init__(self): | ||
super(Location, self).__init__() | ||
self.__x, self.__y, self.__p, self.__alfa, self.__timestamp = None, None, None, None, None | ||
|
||
def __str__(self): | ||
if not self.is_available(): | ||
self.wait_available() | ||
return "location:" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.