Skip to content

Commit

Permalink
ethercatmcIndexer.cpp: Remove compiler warnings
Browse files Browse the repository at this point in the history
Remove different compiler warnings.
Especially, make it compile under an old asyn, without int64 support.
If that is really needed, more code changes need to be done, for the
moment keep the ci happy
  • Loading branch information
tboegi committed Dec 6, 2023
1 parent 86d9f3d commit 0027748
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions ethercatmcApp/src/ethercatmcIndexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1787,10 +1787,11 @@ void
ethercatmcController::indexerSystemUTCtime(int function,
epicsTimeStamp *pTimePTP_MCU)
{
int axisNo = 0;
epicsInt64 oldValue;
getInteger64Param(axisNo, function, &oldValue);

int indexRd = 0;
epicsInt64 oldValue = 0;
#ifdef ETHERCATMC_ASYN_ASYNPARAMINT64
getInteger64Param(indexRd, function, &oldValue);
#endif
uint64_t nSec = (uint64_t)oldValue;
epicsTimeStamp timeIOC;
UTCtimeToEpicsTimeStamp(nSec, pTimePTP_MCU);
Expand All @@ -1799,25 +1800,27 @@ ethercatmcController::indexerSystemUTCtime(int function,
modNamEMC, nSec,
pTimePTP_MCU->secPastEpoch, pTimePTP_MCU->nsec);
setTimeStamp(pTimePTP_MCU);
ctrlLocal.callBackNeeded |= 1 << axisNo;
ctrlLocal.callBackNeeded |= 1 << indexRd;
int rtn = epicsTimeGetCurrent(&timeIOC);
if (!rtn) {
int function = defAsynPara.ethercatmcPTPdiffTimeIOC_MCU_;
double time_IOC_ms = (((double)timeIOC.secPastEpoch) * 1000.0) + (((double)timeIOC.nsec) / 1000000.0);
double time_MCU_ms = (((double)pTimePTP_MCU->secPastEpoch) * 1000.0) + (((double)pTimePTP_MCU->nsec) / 1000000.0);
double diffTimeIOC_MCU = time_IOC_ms - time_MCU_ms;
(void)setDoubleParam(axisNo, function, diffTimeIOC_MCU);
(void)setDoubleParam(indexRd, function, diffTimeIOC_MCU);
} else {
setAlarmStatusSeverityWrapper(axisNo, function, asynDisconnected);
setAlarmStatusSeverityWrapper(indexRd, function, asynDisconnected);
}
}

void
ethercatmcController::indexerTcUTCtime(int functionRd, int indexRd,
const epicsTimeStamp *pTimePTP_MCU)
{
epicsInt64 oldValue;
epicsInt64 oldValue = 0;
#ifdef ETHERCATMC_ASYN_ASYNPARAMINT64
getInteger64Param(indexRd, functionRd, &oldValue);
#endif

uint64_t nSec = (uint64_t)oldValue;
epicsTimeStamp timeTcUTC_MCU;
Expand All @@ -1842,21 +1845,22 @@ ethercatmcController::indexerNTtimePackedTimeStructBias(int function,
int functionStatusBits,
const epicsTimeStamp *pTimePTP_MCU)
{
int axisNo = 0;
asynStatus status;
int indexRd = 0;
idxStatusCodeType idxStatusCode = idxStatusCodeIDLE; // good case
if (functionStatusBits) {
epicsUInt32 statusReasonAux = 0;
getUIntDigitalParam(axisNo, functionStatusBits,
getUIntDigitalParam(indexRd, functionStatusBits,
&statusReasonAux, 0xFFFFFFFF);
idxStatusCode = (idxStatusCodeType)(statusReasonAux >> 28);
asynPrint(pasynUserController_, ASYN_TRACE_FLOW /* | ASYN_TRACE_INFO */,
"%sindexerPoll systemNTtimePackedTimeStructFunction statusReasonAux=0x%x idxStatusCode=%x functionStatusBits=%d\n",
modNamEMC, statusReasonAux, (unsigned)idxStatusCode, functionStatusBits);
}
if (idxStatusCode == idxStatusCodeIDLE) {
epicsInt64 oldValue;
status = getInteger64Param(axisNo, function, &oldValue);
epicsInt64 oldValue = 0;
#ifdef ETHERCATMC_ASYN_ASYNPARAMINT64
getInteger64Param(indexRd, function, &oldValue);
#endif
uint64_t packedTimeStruct = (uint64_t)oldValue;
struct tm tm;
epicsTimeStamp NTtime_MCU;
Expand Down Expand Up @@ -1888,14 +1892,14 @@ ethercatmcController::indexerNTtimePackedTimeStructBias(int function,
tm.tm_hour, tm.tm_min, tm.tm_sec,
millisec, (unsigned long)unix_epoch,
NTtime_MCU.secPastEpoch, NTtime_MCU.nsec);
indexerCalcPTPdiffXYtime_MCU(axisNo,
indexerCalcPTPdiffXYtime_MCU(indexRd,
defAsynPara.ethercatmcPTPdiffXYtime_MCU_,
&NTtime_MCU, pTimePTP_MCU);
}
}

void
ethercatmcController::indexerCalcPTPdiffXYtime_MCU(int axisNo,
ethercatmcController::indexerCalcPTPdiffXYtime_MCU(int indexRd,
int function,
const epicsTimeStamp *pNTtime_MCU,
const epicsTimeStamp *pTimePTP_MCU) {
Expand Down Expand Up @@ -1925,7 +1929,7 @@ ethercatmcController::indexerCalcPTPdiffXYtime_MCU(int axisNo,
modNamEMC,
pNTtime_MCU->secPastEpoch, pNTtime_MCU->nsec,
msecPTPdiffXYtime_MCU);
(void)setDoubleParam(axisNo, function, msecPTPdiffXYtime_MCU);
(void)setDoubleParam(indexRd, function, msecPTPdiffXYtime_MCU);
}

void ethercatmcController::indexerDisconnected(void)
Expand Down

0 comments on commit 0027748

Please sign in to comment.