# Path: houston/state.py
# class State(object, metaclass=StateMeta):
#     """
#     Describes the state of the system at a given moment in time, in terms of
#     its internal and external variables.
#     """
#     @classmethod
#     def from_file(cls: Type['State'], fn: str) -> 'State':
#         """
#         Constructs a system state from a given file, containing a JSON-based
#         description of its contents.
#         """
#         with open(fn, "r") as f:
#             jsn = json.load(f)
#         return cls.from_json(jsn)
# 
#     @classmethod
#     def from_dict(cls: Type['State'], d: Dict[str, Any]) -> 'State':
#         return cls(**d)
# 
#     def __init__(self, *args, **kwargs) -> None:
#         cls_name = self.__class__.__name__
#         variables = self.__class__.variables  # type: Dict[str, Variable]
# 
#         try:
#             self.__time_offset = kwargs['time_offset']
#         except KeyError:
#             msg = "missing keyword argument [time_offset] to constructor [{}]"
#             msg = msg.format(cls_name)
#             raise TypeError(msg)
# 
#         # were any positional arguments passed to the constructor?
#         if args:
#             msg = "constructor [{}] accepts no positional arguments but {} {} given"  # noqa: pycodestyle
#             msg = msg.format(cls_name,
#                              "was" if len(args) == 1 else "were",
#                              len(args))
#             raise TypeError(msg)
# 
#         # set values for each variable
#         for name, v in variables.items():
#             try:
#                 val = kwargs[name]
#             except KeyError:
#                 msg = "missing keyword argument [{}] to constructor [{}]"
#                 msg = msg.format(name, cls_name)
#                 raise TypeError(msg)
# 
#             # TODO perform run-time type checking?
# 
#             setattr(self, v._field, val)
# 
#         # did we pass any unexpected keyword arguments?
#         if len(kwargs) > len(variables) + 1:
#             actual_args = set(n for n in kwargs)
#             expected_args = \
#                 set(name for name in variables) | {'time_offset'}
#             unexpected_arguments = list(actual_args - expected_args)
#             msg = "unexpected keyword arguments [{}] supplied to constructor [{}]"  # noqa: pycodestyle
#             msg = msg.format('; '.join(unexpected_arguments), cls_name)
#             raise TypeError(msg)
# 
#     @property
#     def time_offset(self) -> float:
#         return self.__time_offset
# 
#     def equiv(self, other: 'State') -> bool:
#         if type(self) != type(other):
#             msg = "illegal comparison of states: [{}] vs. [{}]"
#             msg = msg.format(self.__class__.__name__, state.__class__.__name__)
#             raise exceptions.HoustonException(msg)
#         for n, v in self.__class__.variables.items():
#             if self.__dict__[v._field] != other.__dict__[v._field]:
#                 return False
#         return True
# 
#     def exact(self, other: 'State') -> bool:
#         return self.equiv(other) and self.time_offset == other.time_offset
# 
#     __eq__ = exact
# 
#     def __hash__(self) -> int:
#         all_vars = (self.time_offset,)
#         all_vars += tuple(self[v] for v in self.__class__.variables)
#         return hash(all_vars)
# 
#     def __getitem__(self, name: str) -> Any:
#         try:
#             var = self.__class__.variables[name]
#         except StopIteration:
#             msg = "no variable [{}] in state [{}]"
#             msg.format(name, self.__class__.__name__)
#             raise KeyError(msg)
#         return getattr(self, var._field)
# 
#     def to_dict(self) -> Dict[str, Any]:
#         fields = {}  # type: Dict[str, Any]
#         fields['time_offset'] = self.__time_offset
#         for name, var in self.__class__.variables.items():
#             fields[name] = getattr(self, var._field)
#         return fields
# 
#     def __repr__(self) -> str:
#         fields = self.to_dict()
#         for (name, val) in fields.items():
#             if isinstance(val, float):
#                 s = "{:.3f}".format(val)
#             else:
#                 s = str(val)
#             fields[name] = val
#         s = '; '.join(["{}: {}".format(k, v) for (k, v) in fields.items()])
#         s = "{}({})".format(self.__class__.__name__, s)
#         return s
# 
#     def __iter__(self) -> Iterator[Variable]:
#         yield from self.__class__.variables.values()
# 
#     def evolve(self, message: Message, time_offset: float) -> 'State':
#         """
#         Create a new state object evloved from this state based on the
#         received message.
#         """
#         raise NotImplementedError
# 
# Path: houston/state.py
# def var(typ: Type,
#         getter: Callable[['Sandbox'], K],
#         noise: Optional[Union[int, float]] = None
#         ) -> VariableBuilder:
#     return VariableBuilder(typ, getter, noise)


from ...state import State as BaseState
from ...state import var
__all__ = ['State']



class State(BaseState):
    home_latitude = var(float, lambda c: -35.362938)  # TODO: fixed
    home_longitude = var(float, lambda c: 149.165085)  # TODO: fixed
    altitude = var(float,
                   lambda c: c.connection.location.global_relative_frame.alt,  # noqa: pycodestyle
                   noise=1.0)
    latitude = var(float,
                   lambda c: c.connection.location.global_relative_frame.lat,  # noqa: pycodestyle
                   noise=0.0005)
    longitude = var(float,
                    lambda c: c.connection.location.global_relative_frame.lon,  # noqa: pycodestyle
                    noise=0.0005)
    armable = var(bool, lambda c: c.connection.is_armable)

# Path: houston/state.py
# class State(object, metaclass=StateMeta):
#     """
#     Describes the state of the system at a given moment in time, in terms of
#     its internal and external variables.
#     """
#     @classmethod
#     def from_file(cls: Type['State'], fn: str) -> 'State':
#         """
#         Constructs a system state from a given file, containing a JSON-based
#         description of its contents.
#         """
#         with open(fn, "r") as f:
#             jsn = json.load(f)
#         return cls.from_json(jsn)
# 
#     @classmethod
#     def from_dict(cls: Type['State'], d: Dict[str, Any]) -> 'State':
#         return cls(**d)
# 
#     def __init__(self, *args, **kwargs) -> None:
#         cls_name = self.__class__.__name__
#         variables = self.__class__.variables  # type: Dict[str, Variable]
# 
#         try:
#             self.__time_offset = kwargs['time_offset']
#         except KeyError:
#             msg = "missing keyword argument [time_offset] to constructor [{}]"
#             msg = msg.format(cls_name)
#             raise TypeError(msg)
# 
#         # were any positional arguments passed to the constructor?
#         if args:
#             msg = "constructor [{}] accepts no positional arguments but {} {} given"  # noqa: pycodestyle
#             msg = msg.format(cls_name,
#                              "was" if len(args) == 1 else "were",
#                              len(args))
#             raise TypeError(msg)
# 
#         # set values for each variable
#         for name, v in variables.items():
#             try:
#                 val = kwargs[name]
#             except KeyError:
#                 msg = "missing keyword argument [{}] to constructor [{}]"
#                 msg = msg.format(name, cls_name)
#                 raise TypeError(msg)
# 
#             # TODO perform run-time type checking?
# 
#             setattr(self, v._field, val)
# 
#         # did we pass any unexpected keyword arguments?
#         if len(kwargs) > len(variables) + 1:
#             actual_args = set(n for n in kwargs)
#             expected_args = \
#                 set(name for name in variables) | {'time_offset'}
#             unexpected_arguments = list(actual_args - expected_args)
#             msg = "unexpected keyword arguments [{}] supplied to constructor [{}]"  # noqa: pycodestyle
#             msg = msg.format('; '.join(unexpected_arguments), cls_name)
#             raise TypeError(msg)
# 
#     @property
#     def time_offset(self) -> float:
#         return self.__time_offset
# 
#     def equiv(self, other: 'State') -> bool:
#         if type(self) != type(other):
#             msg = "illegal comparison of states: [{}] vs. [{}]"
#             msg = msg.format(self.__class__.__name__, state.__class__.__name__)
#             raise exceptions.HoustonException(msg)
#         for n, v in self.__class__.variables.items():
#             if self.__dict__[v._field] != other.__dict__[v._field]:
#                 return False
#         return True
# 
#     def exact(self, other: 'State') -> bool:
#         return self.equiv(other) and self.time_offset == other.time_offset
# 
#     __eq__ = exact
# 
#     def __hash__(self) -> int:
#         all_vars = (self.time_offset,)
#         all_vars += tuple(self[v] for v in self.__class__.variables)
#         return hash(all_vars)
# 
#     def __getitem__(self, name: str) -> Any:
#         try:
#             var = self.__class__.variables[name]
#         except StopIteration:
#             msg = "no variable [{}] in state [{}]"
#             msg.format(name, self.__class__.__name__)
#             raise KeyError(msg)
#         return getattr(self, var._field)
# 
#     def to_dict(self) -> Dict[str, Any]:
#         fields = {}  # type: Dict[str, Any]
#         fields['time_offset'] = self.__time_offset
#         for name, var in self.__class__.variables.items():
#             fields[name] = getattr(self, var._field)
#         return fields
# 
#     def __repr__(self) -> str:
#         fields = self.to_dict()
#         for (name, val) in fields.items():
#             if isinstance(val, float):
#                 s = "{:.3f}".format(val)
#             else:
#                 s = str(val)
#             fields[name] = val
#         s = '; '.join(["{}: {}".format(k, v) for (k, v) in fields.items()])
#         s = "{}({})".format(self.__class__.__name__, s)
#         return s
# 
#     def __iter__(self) -> Iterator[Variable]:
#         yield from self.__class__.variables.values()
# 
#     def evolve(self, message: Message, time_offset: float) -> 'State':
#         """
#         Create a new state object evloved from this state based on the
#         received message.
#         """
#         raise NotImplementedError
# 
# Path: houston/state.py
# def var(typ: Type,
#         getter: Callable[['Sandbox'], K],
#         noise: Optional[Union[int, float]] = None
#         ) -> VariableBuilder:
#     return VariableBuilder(typ, getter, noise)


# Path: houston/ardu/rover/state.py
from ...state import State as BaseState
from ...state import var

__all__ = ['State']



class State(BaseState):
    home_latitude = var(float, lambda c: -35.362938)  # TODO: fixed
    home_longitude = var(float, lambda c: 149.165085)  # TODO: fixed
    altitude = var(float,
                   lambda c: c.connection.location.global_relative_frame.alt,  # noqa: pycodestyle
                   noise=1.0)
    latitude = var(float,
                   lambda c: c.connection.location.global_relative_frame.lat,  # noqa: pycodestyle
                   noise=0.0005)
    longitude = var(float,
                    lambda c: c.connection.location.global_relative_frame.lon,  # noqa: pycodestyle
                    noise=0.0005)
    armable = var(bool, lambda c: c.connection.is_armable)

    armed = var(bool, lambda c: c.connection.armed)