Beispiel #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 );
  }
Beispiel #2
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;
  }
Beispiel #3
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 );
  }