示例#1
0
bool Weather::initProperties()
{
    DefaultDevice::initProperties();
    WI::initProperties(MAIN_CONTROL_TAB, PARAMETERS_TAB);

    // Location
    IUFillNumber(&LocationN[LOCATION_LATITUDE], "LAT", "Lat (dd:mm:ss)", "%010.6m", -90, 90, 0, 0.0);
    IUFillNumber(&LocationN[LOCATION_LONGITUDE], "LONG", "Lon (dd:mm:ss)", "%010.6m", 0, 360, 0, 0.0);
    IUFillNumber(&LocationN[LOCATION_ELEVATION], "ELEV", "Elevation (m)", "%g", -200, 10000, 0, 0);
    IUFillNumberVector(&LocationNP, LocationN, 3, getDeviceName(), "GEOGRAPHIC_COORD", "Location", SITE_TAB, IP_RW, 60,
                       IPS_OK);

    // Active Devices
    IUFillText(&ActiveDeviceT[0], "ACTIVE_GPS", "GPS", "GPS Simulator");
    IUFillTextVector(&ActiveDeviceTP, ActiveDeviceT, 1, getDeviceName(), "ACTIVE_DEVICES", "Snoop devices", OPTIONS_TAB,
                     IP_RW, 60, IPS_IDLE);

    // Update Period
    IUFillNumber(&UpdatePeriodN[0], "PERIOD", "Period (secs)", "%4.2f", 0, 3600, 60, 60);
    IUFillNumberVector(&UpdatePeriodNP, UpdatePeriodN, 1, getDeviceName(), "WEATHER_UPDATE", "Update", MAIN_CONTROL_TAB,
                       IP_RW, 60, IPS_IDLE);

    // Refresh
    IUFillSwitch(&RefreshS[0], "REFRESH", "Refresh", ISS_OFF);
    IUFillSwitchVector(&RefreshSP, RefreshS, 1, getDeviceName(), "WEATHER_REFRESH", "Weather", MAIN_CONTROL_TAB, IP_RW,
                       ISR_ATMOST1, 0, IPS_IDLE);

    // Override
    IUFillSwitch(&OverrideS[0], "OVERRIDE", "Override Status", ISS_OFF);
    IUFillSwitchVector(&OverrideSP, OverrideS, 1, getDeviceName(), "WEATHER_OVERRIDE", "Safety", MAIN_CONTROL_TAB, IP_RW,
                       ISR_NOFMANY, 0, IPS_IDLE);


    IDSnoopDevice(ActiveDeviceT[0].text, "GEOGRAPHIC_COORD");

    if (weatherConnection & CONNECTION_SERIAL)
    {
        serialConnection = new Connection::Serial(this);
        serialConnection->registerHandshake([&]()
        {
            return callHandshake();
        });
        registerConnection(serialConnection);
    }

    if (weatherConnection & CONNECTION_TCP)
    {
        tcpConnection = new Connection::TCP(this);
        tcpConnection->registerHandshake([&]()
        {
            return callHandshake();
        });
        registerConnection(tcpConnection);
    }

    setDriverInterface(WEATHER_INTERFACE);

    return true;
}
示例#2
0
bool StarbookDriver::initProperties()
{
    Telescope::initProperties();

    IUFillText(&VersionT[0], "Version", "Version", "");
    IUFillTextVector(&VersionTP, VersionT, 1, getDeviceName(), "Firmware", "Firmware", INFO_TAB, IP_RO, 0,
                     IPS_IDLE);

    IUFillText(&StateT[0], "State", "State", "");
    IUFillTextVector(&StateTP, StateT, 1, getDeviceName(), "Status", "Status", MAIN_CONTROL_TAB, IP_RO, 0,
                     IPS_IDLE);

    IUFillSwitch(&StartS[0], "Initialize", "Initialize", ISS_OFF);
    IUFillSwitchVector(&StartSP, StartS, 1, getDeviceName(), "Basic", "Basic control", MAIN_CONTROL_TAB,
                       IP_RW, ISR_ATMOST1, 60, IPS_IDLE);


    curlConnection = new Connection::Curl(this);
    curlConnection->registerHandshake([&]() { return callHandshake(); });
    registerConnection(curlConnection);

    curlConnection->setDefaultHost(DEFAULT_STARBOOK_ADDRESS);
    curlConnection->setDefaultPort(DEFAULT_STARBOOK_PORT);

    cmd_interface = std::unique_ptr<starbook::CommandInterface>(
            new starbook::CommandInterface(curlConnection)
    );

    addDebugControl();

    last_known_state = starbook::UNKNOWN;
    return true;
}
示例#3
0
文件: flip_flat.cpp 项目: azwing/indi
bool FlipFlat::initProperties()
{
    INDI::DefaultDevice::initProperties();

    // Status
    IUFillText(&StatusT[0], "Cover", "", nullptr);
    IUFillText(&StatusT[1], "Light", "", nullptr);
    IUFillText(&StatusT[2], "Motor", "", nullptr);
    IUFillTextVector(&StatusTP, StatusT, 3, getDeviceName(), "Status", "", MAIN_CONTROL_TAB, IP_RO, 60, IPS_IDLE);

    // Firmware version
    IUFillText(&FirmwareT[0], "Version", "", nullptr);
    IUFillTextVector(&FirmwareTP, FirmwareT, 1, getDeviceName(), "Firmware", "", MAIN_CONTROL_TAB, IP_RO, 60, IPS_IDLE);

    initDustCapProperties(getDeviceName(), MAIN_CONTROL_TAB);
    initLightBoxProperties(getDeviceName(), MAIN_CONTROL_TAB);

    LightIntensityN[0].min  = 0;
    LightIntensityN[0].max  = 255;
    LightIntensityN[0].step = 10;

    // Set DUSTCAP_INTEFACE later on connect after we verify whether it's flip-flat (dust cover + light) or just flip-man (light only)
    setDriverInterface(AUX_INTERFACE | LIGHTBOX_INTERFACE);

    addAuxControls();

    serialConnection = new Connection::Serial(this);
    serialConnection->registerHandshake([&]() { return Handshake(); });
    registerConnection(serialConnection);

    return true;
}
示例#4
0
bool INDI::FilterWheel::initProperties()
{
    DefaultDevice::initProperties();

    initFilterProperties(getDeviceName(), FILTER_TAB);

    controller->mapController("Change Filter","Change Filter", INDI::Controller::CONTROLLER_JOYSTICK, "JOYSTICK_1");
    controller->mapController("Reset", "Reset", INDI::Controller::CONTROLLER_BUTTON, "BUTTON_1");

    controller->initProperties();

    setDriverInterface(FILTER_INTERFACE);

    if (filterConnection & CONNECTION_SERIAL)
    {
        serialConnection = new Connection::Serial(this);
        serialConnection->registerHandshake([&]()
        {
            return callHandshake();
        });
        registerConnection(serialConnection);
    }

    if (filterConnection & CONNECTION_TCP)
    {
        tcpConnection = new Connection::TCP(this);
        tcpConnection->registerHandshake([&]()
        {
            return callHandshake();
        });

        registerConnection(tcpConnection);
    }

    return true;
}
示例#5
0
// used to handle message from a ClientConnection
// those message can be 
//     'SYSTEM_REGISTER <CONSUMER | PROVIDER> #Game [Game]' --> no answer
//     'SYSTEM_REQUEST_GAME GameKind'
//             'SYSTEM_REQUEST_GAME_REFUSED ErrorMessage'
//             'SYSTEM_REQUEST_GAME_ACCEPTED GameId #Consumer [Consumer]'
//     'SYSTEM_JOIN_GAME GameId'
//     'SYSTEM_LEAVE_GAME GameId'
//     '<gameId> MESSAGE'
void ConnectionManager::handleMessage( ClientConnectionPtr connection,
                                       const std::string& message )
{
   // log the message
   AsyncLogger::getInstance()->log( "RECEIVE FROM (" + connection->getLogin() + ") : " + message );

   // explode the message to be able to check the kind 
   std::vector< std::string > messageParts;
   if ( StringUtils::explode( message,
                              ' ',
                              messageParts,
                              2 ) == 2 )
   {
      if ( messageParts[ 0 ] == SYSTEM_REGISTER )
      {
         registerConnection( connection,
                              messageParts[ 1 ] );
         dumpCurrentState();
      }
      else if ( messageParts[ 0 ] == SYSTEM_REQUEST_GAME )
      {
         requestGame( connection,
                        messageParts[ 1 ] );
         dumpCurrentState();
      }
      else if ( messageParts[ 0 ] == SYSTEM_REQUEST_GAME_LIST )
      {
         requestGameList( connection,
                           messageParts[ 1 ] );
      }
      else if ( messageParts[ 0 ] == SYSTEM_JOIN_OR_REQUEST_GAME )
      {
         joinOrRequestGame( connection,
                              messageParts[ 1 ] );
         dumpCurrentState();
      }
      else if ( messageParts[ 0 ] == SYSTEM_JOIN_GAME )
      {
         joinGame( connection,
                     messageParts[ 1 ] );
         dumpCurrentState();
      }
      else if ( messageParts[ 0 ] == SYSTEM_LEAVE_GAME )
      {
         leaveGame( connection,
                     messageParts[ 1 ] );
         dumpCurrentState();
      }
      else if ( messageParts[ 0 ] == SYSTEM_GAME_CREATION_REFUSED )
      {
         // get the relevant information
         std::vector< std::string > messageInformation;
         StringUtils::explode( messageParts[ 1 ],
                                 ' ',
                                 messageInformation,
                                 2 );

         // and close the game
         closeGame( connection,
                     messageInformation[ 0 ],
                     messageInformation[ 1 ] );
         dumpCurrentState();
      }
      else if ( messageParts[ 0 ] == GAME_MESSAGE )
      {
         // get the relevant information
         std::vector< std::string > messageInformation;
         StringUtils::explode( messageParts[ 1 ],
                                 ' ',
                                 messageInformation,
                                 2 );

         // and forward the message (gameId, message)
         handleGameMessage( connection,
                              messageInformation[ 0 ],
                              message );
      }
   }
}