Пример #1
0
 public synchronized boolean isVerbosity() {
   try {
     return Parameters.getInstance().getBoolean(VERBOSITY);
   } catch (NoSuchParameterException ex) {
     // Not really a disaster
     logger.warning(VERBOSITY + " is not defined");
     return false;
   }
 }
Пример #2
0
  private Engine(ConfigFile config) throws FileNotFoundException, IncompatibleArgumentException {
    outBuffer = new ArrayList<>(8);
    irHardware = new TreeMap<>(String.CASE_INSENSITIVE_ORDER);
    config
        .getIrHardware()
        .stream()
        .forEach(
            (GirsHardware hw) -> {
              irHardware.put(hw.getName(), hw);
            });

    modules = new TreeMap<>();

    // Set up the special modules
    registerModule(Parameters.newParameterModule());

    // May override values in the code
    Parameters.getInstance().addAll(config.getOptions());

    Parameters.getInstance()
        .add(
            new StringParameter(
                "hardwareList",
                Utils.sortedString(irHardware.keySet(), " "),
                "List of available hardware"));

    registerModule(Base.newBase());

    try {
      renderer = new Renderer(Parameters.getInstance().getString(Parameters.IRPPROTOCOLSINI));
      registerModule(renderer);
    } catch (NoSuchParameterException ex) {
      logger.log(
          Level.WARNING,
          Parameters.IRPPROTOCOLSINI + " not defined; rendering will not be available");
    }

    if (config.getRemoteCommandsDataBase() != null)
      registerModule(NamedRemotes.newNamedRemotes(config.getRemoteCommandsDataBase()));

    irp = new Irp();
    registerModule(irp);

    registerModule(Transmit.newTransmit(renderer, irp));
    registerModule(Transmitters.newTransmittersModule());
    registerModule(Capture.newCapture());
    registerModule(Receive.newReceive());

    config
        .getModuleList()
        .stream()
        .forEach(
            (module) -> {
              try {
                registerModule(module.instantiate());
              } catch (ClassNotFoundException
                  | NoSuchMethodException
                  | InstantiationException
                  | IllegalAccessException
                  | IllegalArgumentException
                  | InvocationTargetException ex) {
                logger.log(Level.SEVERE, null, ex);
              }
            });

    irHardware
        .values()
        .forEach(
            (GirsHardware ghw) -> {
              if (ghw.isImmediateOpen()) {
                ghw.getHardware().setVerbosity(isVerbosity());
                try {
                  ghw.getHardware().open();
                } catch (HarcHardwareException | IOException ex) {
                  logger.log(Level.WARNING, null, ex);
                }
              }
            });
  }
Пример #3
0
 public synchronized GirsHardware getReceiveHardware()
     throws NoSuchHardwareException, NoSuchParameterException, AmbigousHardwareException {
   return getHardware(Parameters.getInstance().getString(Parameters.RECEIVEDEVICE));
 }
Пример #4
0
 // NOTE: "verbosity" is a silly name for a boolean property, but let's
 // keep it for compatibility with HardHardware.
 @Override
 public synchronized void setVerbosity(boolean verbosity) {
   Parameters.getInstance().setBoolean(VERBOSITY, verbosity);
 }
Пример #5
0
 public synchronized GirsHardware getTransmitHardware()
     throws NoSuchHardwareException, NoSuchParameterException, AmbigousHardwareException {
   return getHardware(Parameters.getInstance().getString(Parameters.TRANSMITDEVICE));
 }