示例#1
0
///
/// @brief Verify device connects properly.
///
/// 1. Establish Connection
/// 2. Check Connection Status message
/// 3. Disconnect and check connection status.
///
TEST( DEVICE, FocuserConnectsProperly )
{
  // 1. Establish Connection
  //
  BeeFocused::Driver driver;
  EstablishConnection( driver );

  //
  // 2. Check Connection Status message
  //
  // The connection status is updated on TimerHit.  Move time forward
  // a bit and check for the proper connection status.
  //
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 250 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "CONNECT_STATUS"), "Connected" );
  }

  // 3. Disconnect and check connection status.
  {
    ITH::StdoutCapture outCap;
    ITH::TurnSwitch( driver, INDI::SP::CONNECTION,
        ITH::StateData{{{"DISCONNECT", ISS_ON }}} );
    AdvanceTimeForward( driver, 250 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "CONNECT_STATUS"), "Not Connected" );
  }
}
示例#2
0
///
/// @brief Verify that abort works
///
/// 1. Test Abort while homing at start-up
/// 2. Start a move and verify that we're moving
/// 3. Issue an abort.  Focuser should stop moving.
/// 4. Make sure focuser position doesn't change if more time passes.
///
TEST( DEVICE, TestAbort )
{
  BeeFocused::Driver driver;
  EstablishConnection( driver );

  /// 1. Test Abort while homing at start-up
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 2000 );

    ITH::TurnSwitch( driver, "FOCUS_ABORT_MOTION",
      ITH::StateData{{{"ABORT", ISS_ON }}} );

    // Give plenty of time to make sure we aborted.
    AdvanceTimeForward( driver, 10000 );
    ITH::XMLCapture xml( outCap.getOutput() );

    // should be not synced (abort interrupted) and at 
    // position 0 (still re-winding from the home attempt)
    ASSERT_EQ( xml.lastState( "HOME_STATUS"), "Not Synced" );
    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Ok" );
    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "0" );
  }
  // 2. Start a move and verify that we're moving
  {
    ITH::StdoutCapture outCap;
    ITH::SetNumber( driver, "ABS_FOCUS_POSITION",
      ITH::NumberData{{{"FOCUS_ABSOLUTE_POSITION", 10000.0 }}} );
    AdvanceTimeForward( driver, 3000 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Busy" );
    ASSERT_NE( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "0" );
  }
  // 3. Issue an abort.  Focuser should stop moving.
  {
    ITH::StdoutCapture outCap;

    ITH::TurnSwitch( driver, "FOCUS_ABORT_MOTION",
      ITH::StateData{{{"ABORT", ISS_ON }}} );

    // A tiny bit of time to make sure we aborted.
    AdvanceTimeForward( driver, 750 );
    ITH::XMLCapture xml( outCap.getOutput() );

    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Ok" );
    ASSERT_NE( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "0" );
  }
  // 4. Make sure focuser position doesn't change if more time passes.
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 5000 );
    ASSERT_EQ( outCap.getOutput(), "" );
  }
}
示例#3
0
///
/// @brief Verify that we get a maximum position from the firmware
///
/// 1. Establish Connection
/// 2. Advance time & verify that we got the firmware's maximum position
///
TEST( DEVICE, FocuserUpdatesMaxPos )
{
  // 1. Establish Connection
  BeeFocused::Driver driver;
  EstablishConnection(  driver );

  // 2. Advance time & verify that we got the firmwares maximum position
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 1000 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "FOCUS_MAX_VALUE"), "35000" );
  }
}
示例#4
0
HttpConnection::HttpConnection(const char* user_agent) : 
                              AbstractHttpConnection(user_agent), inet(NULL), connection(NULL), req(NULL)
{
#ifdef _WIN32_WCE
    // used by default. check connection before...
    if (!EstablishConnection()) {
        #ifdef WIN32_PLATFORM_PSPC
        setErrorF(ERR_INTERNET_CONNECTION_MISSING, "%s: %d", "Internet Connection Missing", ERR_INTERNET_CONNECTION_MISSING);
        #else
        LOG.error("Warning: internet connection missing.");
        #endif
    }
#endif   
    numberOfRetryForProxy = 1;
}
示例#5
0
///
/// @brief Verify Set Absolute Position works & interrupts home
///
/// 1. Set an absolute position before we finish homing.
/// 2. Verify the focuser reaches the target position given time.
/// 3. Try a value past the maximum focuser position (35000)
///
TEST( DEVICE, SetABSPos )
{
  BeeFocused::Driver driver;
  EstablishConnection( driver );

  /// 1. Set an absolute position before we finish homing.
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 2000 );
    ITH::SetNumber( driver, "ABS_FOCUS_POSITION",
      ITH::NumberData{{{"FOCUS_ABSOLUTE_POSITION", 1000.0 }}} );
    AdvanceTimeForward( driver, 2000 );
    ITH::XMLCapture xml( outCap.getOutput() );

    // should be not synced (home interrupted) and at 
    // position 0 (still re-winding from the home attempt)
    ASSERT_EQ( xml.lastState( "HOME_STATUS"), "Not Synced" );
    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Busy" );
    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "0" );
  }

  /// 2. Verify the focuser reaches the target position given time.
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 5000);
    std::string myout = outCap.getOutput();
    ITH::XMLCapture xml( myout );

    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "1000" );
    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Ok" );
  }

  // 3. Try a value past the maximum focuser position (35000)
  {
    ITH::StdoutCapture outCap;
    ITH::SetNumber( driver, "ABS_FOCUS_POSITION",
      ITH::NumberData{{{"FOCUS_ABSOLUTE_POSITION", 50000.0 }}} );

    AdvanceTimeForward( driver, 100000);
    std::string output = outCap.getOutput();
    ITH::XMLCapture xml( output );
  
    // Verify warning issued, and that we don't move past 35000.
    ASSERT_NE( std::string::npos, output.find("[WARNING] Focuser will not move past maximum value of 35000")); 
    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "35000" );
    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Ok" );
  }
}
示例#6
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mdc_StartSessionIPV4
(
    uint32_t profileIndex,        ///< [IN] The profile to use
    pa_mdc_CallRef_t* callRefPtr  ///< [OUT] Reference used for stopping the data session
)
{
    le_result_t result=LE_NOT_POSSIBLE;

    if ( GetCurrentDataSessionIndex() != INVALID_PROFILE_INDEX )
    {
        return LE_DUPLICATE;
    }

    // Always executed because:
    //   - if GPRS is already attached it doesn't do anything and then it returns OK
    //   - if GPRS is not attached it will attach it and then it returns OK on success
    if ( AttachGPRS(true) != LE_OK )
    {
        return LE_NOT_POSSIBLE;
    }

    // Always executed because:
    //   - if the context is already activated it doesn't do anything and then it returns OK
    //   - if the context is not activated it will attach it and then it returns OK on success
    if ( ActivateContext(profileIndex,true) != LE_OK )
    {
        return LE_NOT_POSSIBLE;
    }

    if ( (result = EstablishConnection(profileIndex)) != LE_OK )
    {
        return LE_NOT_POSSIBLE;
    }

    if (result==LE_OK) {
        SetCurrentDataSessionIndex(profileIndex);
        memcpy(callRefPtr, &profileIndex, sizeof(void*));
    } else {
        SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX);
    }

    return result;
}
示例#7
0
///
/// @brief Verify that Syncing works
///
/// 1. Set absolute position to 1000 (also interrupts homing)
/// 2. Sync to 0
/// 3. Sync to 1234
///
TEST( DEVICE, TestSync )
{
  BeeFocused::Driver driver;
  EstablishConnection( driver );

  // 1. Set absolute position to 1000 (also interrupts homing)
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 1000 );
    ITH::SetNumber( driver, "ABS_FOCUS_POSITION",
      ITH::NumberData{{{"FOCUS_ABSOLUTE_POSITION", 1000.0 }}} );
    AdvanceTimeForward( driver, 10000 );
    ITH::XMLCapture xml( outCap.getOutput() );

    // should be not synced (home interrupted) and at 
    // position 1000
    ASSERT_EQ( xml.lastState( "HOME_STATUS"), "Not Synced" );
    ASSERT_EQ( xml.lastState( "ABS_FOCUS_POSITION"), "Ok" );
    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "1000" );
  }
  // 2. Sync to 0
  {
    ITH::StdoutCapture outCap;
    ITH::SetNumber( driver, "FOCUS_SYNC",
      ITH::NumberData{{{"FOCUS_SYNC_VALUE", 0.0 }}} );
    AdvanceTimeForward( driver, 2000 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "HOME_STATUS"), "Synced" );
    ASSERT_EQ( xml.lastState( "FOCUS_SYNC_VALUE"), "0" );
    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "0" );
  }
  // 3. Sync to 1234
  {
    ITH::StdoutCapture outCap;
    ITH::SetNumber( driver, "FOCUS_SYNC",
      ITH::NumberData{{{"FOCUS_SYNC_VALUE", 1234 }}} );
    AdvanceTimeForward( driver, 2000 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "FOCUS_SYNC_VALUE"), "1234" );
    ASSERT_EQ( xml.lastState( "FOCUS_ABSOLUTE_POSITION"), "1234" );
  }
}
示例#8
0
///
/// @brief Verify that a focuser with an end-stop auto-syncs
///
/// Flow Control:
///
/// 1. Establish Connection
/// 2. Advance time by 4000 ms and verify focuser isn't synced yet
/// 3. Advance time by 200 ms and verify focuser is now synced
///
TEST( DEVICE, FocuserHomesToEndStop)
{
  // 1. Establish Connection
  BeeFocused::Driver driver;
  EstablishConnection(  driver );

  // 2. Advance time by 4000 ms and verify focuser isn't synced yet
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 4000 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "HOME_STATUS"), "Not Synced" );
  }

  // 3. Advance time by 200 ms and verify focuser is now synced
  {
    ITH::StdoutCapture outCap;
    AdvanceTimeForward( driver, 250 );
    ITH::XMLCapture xml( outCap.getOutput() );
    ASSERT_EQ( xml.lastState( "HOME_STATUS"), "Synced" );
  }
}
示例#9
0
//--------------------------------------------------------------------------------------------------
le_result_t pa_mdc_StartSessionIPV4
(
    uint32_t profileIndex        ///< [IN] The profile to use
)
{
    le_result_t result=LE_FAULT;

    if ( GetCurrentDataSessionIndex() != INVALID_PROFILE_INDEX )
    {
        return LE_DUPLICATE;
    }

    // Always executed because:
    //   - if GPRS is already attached it doesn't do anything and then it returns OK
    //   - if GPRS is not attached it will attach it and then it returns OK on success
    if ( AttachGPRS(true) != LE_OK )
    {
        return LE_FAULT;
    }

    // Always executed because:
    //   - if the context is already activated it doesn't do anything and then it returns OK
    //   - if the context is not activated it will attach it and then it returns OK on success
    if ( ActivateContext(profileIndex,true) != LE_OK )
    {
        return LE_FAULT;
    }

    if ( (result = EstablishConnection(profileIndex)) != LE_OK )
    {
        SetCurrentDataSessionIndex(INVALID_PROFILE_INDEX);
        return LE_FAULT;
    }

    SetCurrentDataSessionIndex(profileIndex);

    return result;
}
示例#10
0
FPerforceConnection::FPerforceConnection(const FPerforceConnectionInfo& InConnectionInfo)
:	bEstablishedConnection(false)
,	bIsUnicode(false)
{
	EstablishConnection(InConnectionInfo);
}
示例#11
0
// Do a transaction with server
// returns received bytes, -1 if transaction failed
static int DoTransactionToServer(char *txbuf, unsigned int txbuflen, char *rxbuf, unsigned int maxrxbuflen)
{
  SOCKET s = INVALID_SOCKET;
  unsigned int sent = 0;
  int tmpres;
  int rxfsm = 0;
  unsigned int rxlen = 0;
  char recvbuf[BUFSIZ];
  unsigned char cdata;

  s = EstablishConnection(_server_name, _server_port);
  if ( s==INVALID_SOCKET ) return -1;

  //Send the query to the server
  while(sent < txbuflen) {
    tmpres = send(s, txbuf+sent, txbuflen-sent, 0);
    if( tmpres == SOCKET_ERROR ) {
      rxlen = -1;
      goto cleanup;
    }
    sent += tmpres;
  }

  //Receive the page
  while( (tmpres = recv(s, recvbuf, BUFSIZ, 0)) > 0) {
    for (int i=0; i<tmpres; i++) {
      cdata = recvbuf[i];
      switch (rxfsm) {
        default:
        case 0:
          if (cdata=='\r') rxfsm++;
          break;
        case 1:
          if (cdata=='\n') { rxfsm++; break; }
          rxfsm=0;
          break;
        case 2:
          if (cdata=='\r') { rxfsm++; break; }
          rxfsm=0;
          break;
        case 3:
          if (cdata=='\n') { rxfsm++; rxlen=0; break; }
          rxfsm=0;
          break;
        case 4:
          //Content chr
          rxbuf[rxlen] = cdata;
          if (rxlen<maxrxbuflen) rxlen++;
          break;
      }//sw
    } //for
  } //wh

  if(tmpres == SOCKET_ERROR) {
    rxlen = -1;
    goto cleanup;
  }  

  rxbuf[rxlen]=0;
  #ifdef LT_DEBUG
  TCHAR urxbuf[500];
  ascii2unicode(rxbuf,urxbuf,400);
  StartupStore(TEXT("Livetracker recv len=%d: %s%s"), rxlen, urxbuf, NEWLINE);
  #endif
cleanup:
  closesocket(s);
  return rxlen;
}
示例#12
0
int opensocket()
{
	//open a connect to 10.30.200.190 //helen's netbook
	helen = EstablishConnection();
}