示例#1
0
  TracLight_c::SendMessage_e TracLight_c::sendLightingData()
  { // there is no need to check for address claim in tractor mode because this is already done in the timeEvent
    // function of base class BaseCommon_c
    CanPkgExt_c pkg;

    // precondition checks for sending as implement
    if (!mb_cmdWait4Response) return MessageNotSent;

    if( ( ! getIdentItem() ) || ( ! getIdentItem()->isClaimedAddress() ) ) {
      return MessageNotSent;
    }

    pkg.setIsoPgn(LIGHTING_DATA_PGN);
    //reset flag because msg will now be send
    mb_cmdWait4Response = false;

    pkg.setIsoPri(6);

    uint16_t ui16_temp = 0;
    ui16_temp =
      (mt_cmd.implOEMOpt2          <<  0) +
      (mt_cmd.implOEMOpt1          <<  2) +
      (mt_cmd.implRightForwardWork <<  4) +
      (mt_cmd.implLeftForwardWork  <<  6) +
      (0                          <<  8) +    //reserved field in lighting data
      (mt_cmd.implRightFacingWork  << 10) +
      (mt_cmd.implLeftFacingWork   << 12) +
      (mt_cmd.implRearWork         << 14);
    pkg.setUint16Data(6, ui16_temp);

    return helpSendMessage( pkg );
  }
  bool ProprietaryMessageB_c::sendWithPrio( uint8_t ps, unsigned prio, const IsoName_c& a_overwrite_remote ) {

    isoaglib_assert( prio <= 7 );
    isoaglib_assert(m_ident);
    // do not allow overwrite to a different target if m_remote is specified
    isoaglib_assert(!m_remote.isSpecified() || a_overwrite_remote.isUnspecified() || (a_overwrite_remote == m_remote));

    const uint32_t pgn = ( uint32_t( m_dp ) << 16) | PROPRIETARY_B_PGN | ps;
    if (getDataSend().getLen() <= 8)
    {
      CanPkgExt_c pkg;

      pkg.setIsoPri( static_cast<uint8_t>( prio ) );
      pkg.setIsoPgn( pgn );
      pkg.setMonitorItemForSA( m_ident->getIsoItem() );
      pkg.setDataFromString ( getDataSend().getDataStream(), static_cast<uint8_t>( getDataSend().getLen() ) );
      getIsoBusInstance( m_ident->getMultitonInst() ) << pkg;
      return true;
    }
    else
    { /** multi-packet */
      /** variable should be evaluated */
      // const bool cb_couldStartMultiSend =
      // we could catch the information if the sending succeeded, but what to do with it anyway?
      return getMultiSendInstance( m_ident->getMultitonInst() ).sendIsoTarget(
         m_ident->isoName(),
         a_overwrite_remote.isSpecified() ? a_overwrite_remote : m_remote,
         getDataSend().getDataStream(0),
         getDataSend().getLen(),
         pgn,
         this );
    }
  }
  bool ProprietaryMessageB_c::send( uint8_t ps ) {

    isoaglib_assert(m_ident);

    const uint32_t pgn = ( uint32_t( m_dp ) << 16) | PROPRIETARY_B_PGN | ps;
    if (getDataSend().getLen() <= 8)
    {
      CanPkgExt_c pkg;

      pkg.setIsoPri( 6 );
      pkg.setIsoPgn( pgn );
      pkg.setMonitorItemForSA( m_ident->getIsoItem() );
      pkg.setDataFromString ( getDataSend().getDataStream(), static_cast<uint8_t>( getDataSend().getLen() ) );
      getIsoBusInstance( m_ident->getMultitonInst() ) << pkg;
      return true;
    }
    else
    { /** multi-packet */
      /** variable should be evaluated */
      // const bool cb_couldStartMultiSend =
      // we could catch the information if the sending succeeded, but what to do with it anyway?
      return getMultiSendInstance( m_ident->getMultitonInst() ).sendIsoTarget(
         m_ident->isoName(),
         m_remote,
         getDataSend().getDataStream(0),
         getDataSend().getLen(),
         pgn,
         this );
    }
  }
示例#4
0
  void
  TractorHitch_c::setValues( const CanPkgExt_c& pkg )
  {
    mui8_position       = pkg.getUint8Data( 0 );
    mui8_linkForce      = pkg.getUint8Data( 2 );
    mui16_draft         = static_cast<uint16_t>(pkg.getUint8Data( 3 ) ) + (static_cast<uint16_t>(pkg.getUint8Data( 4 ) ) << 8);
    mui8_exitReasonCode = pkg.getUint8Data( 5 ) & 0x3F;

    mt_inWorkIndication = IsoAgLib::IsoHitchInWorkIndicationFlag_t( pkg.getUint8Data( 1 ) >> 6 );
    mt_posLimitStatus   = IsoAgLib::IsoLimitFlag_t( ( pkg.getUint8Data( 1 ) >> 3 ) & 0x07 );
  }
示例#5
0
void FsManager_c::FsServerManager_c::processFsToGlobal( const CanPkgExt_c& pkg ) {
  for (STL_NAMESPACE::vector<FsServerInstance_c *>::iterator it = m_serverInstances.begin(); it != m_serverInstances.end(); ++it) {
    if( pkg.getMonitorItemForSA() == &(*it)->getIsoItem() ) {
      (*it)->processFsToGlobal( pkg ); 
    }
  }
}
示例#6
0
  TracLight_c::SendMessage_e TracLight_c::helpSendMessage( CanPkgExt_c& pkg )
  {
    // there is no need to check for address claim in tractor mode because this is already done in the timeEvent
    // function of base class BaseCommon_c

    pkg.setMonitorItemForSA( getIdentItem()->getIsoItem() );
    pkg.setLen(8);

    uint16_t ui16_temp = 0;
    ui16_temp =
      (mt_cmd.daytimeRunning <<  0) +
      (mt_cmd.alternateHead  <<  2) +
      (mt_cmd.lowBeamHead    <<  4) +
      (mt_cmd.highBeamHead   <<  6) +
      (mt_cmd.frontFog       <<  8) +
      (mt_cmd.beacon         << 10) +
      (mt_cmd.rightTurn      << 12) +
      (mt_cmd.leftTurn       << 14);
    pkg.setUint16Data(0, ui16_temp);
    ui16_temp = 0;
    ui16_temp =
      (mt_cmd.backUpLightAlarmHorn <<  0) +
      (mt_cmd.centerStop           <<  2) +
      (mt_cmd.rightStop            <<  4) +
      (mt_cmd.leftStop             <<  6) +
      (mt_cmd.implClearance        <<  8) +
      (mt_cmd.tracClearance        << 10) +
      (mt_cmd.implMarker           << 12) +
      (mt_cmd.tracMarker           << 14);
    pkg.setUint16Data(2, ui16_temp);
    ui16_temp = 0;
    ui16_temp =
      (mt_cmd.rearFog       <<  0) +
      (mt_cmd.undersideWork <<  2) +
      (mt_cmd.rearLowWork   <<  4) +
      (mt_cmd.rearHighWork  <<  6) +
      (mt_cmd.sideLowWork   <<  8) +
      (mt_cmd.sideHighWork  << 10) +
      (mt_cmd.frontLowWork  << 12) +
      (mt_cmd.frontHighWork << 14);
    pkg.setUint16Data(4, ui16_temp);

    // CanIo_c::operator<< retreives the information with the help of CanPkg_c::getData
    // then it sends the data
    getIsoBusInstance4Comm() << pkg;
    return MessageSent;
  }
示例#7
0
  TracLight_c::SendMessage_e TracLight_c::sendLightingCommand()
  {
    const ecutime_t ci32_now = System_c::getTime();

    CanPkgExt_c pkg;

    // tractor mode
    if ( ( ci32_now - marr_timeStamp[m_index] ) <= 1000 )
    { // WE ARE NOT ALLOWED TO SEND - EVEN IF REQUESTED
      return MessageNotSent;
    }
    else if ( (!mb_changeNeedBeSend) && ( (ci32_now - marr_timeStamp[(m_index+9)%10]) < 900 ) ) // (m_index+9)%10 -> youngest entry in array marr_timeStamp[];
    { // to send requested (i.e. no change occured) or not yet time to repeat last command
      return MessageNotSent;
    }
    mb_changeNeedBeSend = false;
    // now it's evident, that we have to send a command
    pkg.setIsoPgn(LIGHTING_COMMAND_PGN);
    setSelectedDataSourceISOName( getIdentItem()->isoName() );

    pkg.setIsoPri(3);
    uint16_t ui16_temp = 0;
    ui16_temp =
      (mt_cmd.implOEMOpt2          <<  0) +
      (mt_cmd.implOEMOpt1          <<  2) +
      (mt_cmd.implRightForwardWork <<  4) +
      (mt_cmd.implLeftForwardWork  <<  6) +
      (mt_cmd.dataMsgReq           <<  8) +
      (mt_cmd.implRightFacingWork  << 10) +
      (mt_cmd.implLeftFacingWork   << 12) +
      (mt_cmd.implRearWork         << 14);
    pkg.setUint16Data(6, ui16_temp);
    //overwrite the eldest time event with latest time event
    marr_timeStamp[m_index] = ci32_now;

    //set m_index to the eldest time event
    m_index = (m_index + 1) % 10;

    return helpSendMessage( pkg );
  }
示例#8
0
/** send a PGN request */
bool BaseCommon_c::sendPgnRequest(uint32_t ui32_requestedPGN)
{
  if( ( ! getIdentItem() ) || ( ! getIdentItem()->isClaimedAddress() ) )
    return false;

  IsoItem_c *dest = getSelectedDataSourceISONameConst().isSpecified()
    ? getIsoMonitorInstance( getIdentItem()->getMultitonInst() ).item( getSelectedDataSourceISONameConst(), true )
    : NULL; // --> ask to global

  CanPkgExt_c pkg;
  pkg.setIsoPri(6);
  pkg.setIsoPgn(REQUEST_PGN_MSG_PGN);
  pkg.setMonitorItemForSA( getIdentItem()->getIsoItem() );
  pkg.setMonitorItemForDA( dest );
  pkg.setLen( 3 );
  pkg.setUint32Data( 0 , ui32_requestedPGN );
  getIsoBusInstance( getIdentItem()->getMultitonInst() ) << pkg;
  return true;
}
示例#9
0
  /** send facilities data
      @see  TracFacilities_c::processMsgRequestPGN
      @see  CanIo_c::operator<<
    */
  void TracFacilities_c::sendFacilities( )
  {// there is no need to check for address claim because this is already done in the processMsgRequestPGN;
   // this function is only be called on request!!
    isoaglib_assert( getIdentItem() );

    IsoBus_c& c_can = getIsoBusInstance4Comm();

    CanPkgExt_c pkg;
    pkg.setMonitorItemForSA( getIdentItem()->getIsoItem() );
    setSelectedDataSourceISOName( getIdentItem()->isoName() );
    pkg.setIsoPri(3);
    pkg.setLen(8);

    pkg.setIsoPgn(TRACTOR_FACILITIES_PGN);

    for (uint8_t ui8_counter = 0;ui8_counter<sizeof(arrui8_facilitiesBitData)/sizeof(uint8_t);++ui8_counter)
      pkg.setUint8Data(ui8_counter,arrui8_facilitiesBitData[ui8_counter]);

    // CanIo_c::operator<< retreives the information with the help of CanPkg_c::getData
    // then it sends the data
    c_can << pkg;
  }