2020-09-10 15:03:57 +02:00
|
|
|
from ..AFactory import AFactory
|
2020-05-13 14:33:22 +02:00
|
|
|
from ..IRadiant import IRadiant
|
|
|
|
from ..Entry import Entry
|
|
|
|
from .ASensor import ASensor
|
|
|
|
from .Imager import Imager
|
2020-06-30 10:26:16 +02:00
|
|
|
from .Heterodyne import Heterodyne
|
2020-05-29 09:36:02 +02:00
|
|
|
from ...lib.logger import logger
|
2020-05-13 14:33:22 +02:00
|
|
|
|
|
|
|
|
2020-09-10 15:03:57 +02:00
|
|
|
class SensorFactory(AFactory):
|
2020-05-13 14:33:22 +02:00
|
|
|
"""
|
|
|
|
A Factory creating objects of the type ASensor
|
|
|
|
"""
|
2020-09-10 15:03:57 +02:00
|
|
|
|
|
|
|
def __init__(self, common_conf: Entry):
|
2020-05-13 14:33:22 +02:00
|
|
|
"""
|
|
|
|
Instantiate a new factory object
|
2020-09-10 15:03:57 +02:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
common_conf : Entry
|
|
|
|
The common configuration of the configuration file
|
2020-05-13 14:33:22 +02:00
|
|
|
"""
|
2020-09-10 15:03:57 +02:00
|
|
|
super().__init__(common_conf)
|
2020-05-13 14:33:22 +02:00
|
|
|
|
2020-09-10 15:31:07 +02:00
|
|
|
def create(self, options: Entry, parent: IRadiant = None) -> ASensor:
|
2020-05-13 14:33:22 +02:00
|
|
|
"""
|
2020-09-10 15:03:57 +02:00
|
|
|
Create a new sensor object
|
2020-05-13 14:33:22 +02:00
|
|
|
|
|
|
|
Parameters
|
|
|
|
----------
|
|
|
|
options : Entry
|
|
|
|
The options to be used as parameters for the instantiation of the new object.
|
2020-09-10 15:03:57 +02:00
|
|
|
parent : IRadiant
|
|
|
|
The parent element of the object.
|
2020-05-13 14:33:22 +02:00
|
|
|
Returns
|
|
|
|
-------
|
|
|
|
obj : ASensor
|
|
|
|
The created sensor object
|
|
|
|
"""
|
2020-09-10 15:03:57 +02:00
|
|
|
opts = self.collectOptions(options)
|
|
|
|
|
2020-05-13 14:33:22 +02:00
|
|
|
if options.type == "Imager":
|
2020-09-10 15:03:57 +02:00
|
|
|
args = dict(parent=parent, **opts, common_conf=self._common_conf)
|
2020-05-13 14:33:22 +02:00
|
|
|
if hasattr(options, "center_offset"):
|
|
|
|
# noinspection PyCallingNonCallable
|
|
|
|
args["center_offset"] = options.center_offset()
|
|
|
|
if hasattr(options, "photometric_aperture"):
|
|
|
|
if hasattr(options.photometric_aperture, "shape") and isinstance(
|
|
|
|
options.photometric_aperture.shape, Entry):
|
|
|
|
args["shape"] = options.photometric_aperture.shape()
|
|
|
|
if hasattr(options.photometric_aperture, "contained_energy") and isinstance(
|
|
|
|
options.photometric_aperture.contained_energy, Entry):
|
|
|
|
args["contained_energy"] = options.photometric_aperture.contained_energy()
|
2020-09-09 13:14:01 +02:00
|
|
|
if hasattr(options.photometric_aperture, "aperture_size") and isinstance(
|
|
|
|
options.photometric_aperture.aperture_size, Entry):
|
|
|
|
args["aperture_size"] = options.photometric_aperture.aperture_size()
|
2020-05-13 14:33:22 +02:00
|
|
|
return Imager(**args)
|
2020-06-30 10:26:16 +02:00
|
|
|
elif options.type == "Heterodyne":
|
2020-09-10 15:03:57 +02:00
|
|
|
args = dict(parent=parent, **opts, common_conf=self._common_conf)
|
2020-06-30 10:26:16 +02:00
|
|
|
if hasattr(options, "n_on"):
|
|
|
|
# noinspection PyCallingNonCallable
|
|
|
|
args["n_on"] = options.n_on()
|
|
|
|
return Heterodyne(**args)
|
2020-05-13 14:33:22 +02:00
|
|
|
else:
|
2020-05-29 09:36:02 +02:00
|
|
|
logger.error("Wrong sensor type: " + options.type)
|