Télécharger Imprimer la page

Novus DIGIRAIL OEE Mode D'emploi page 99

Masquer les pouces Voir aussi pour DIGIRAIL OEE:

Publicité

} channel_digital_event_index_t;
typedef
enum
e_event_type
{
EVENT_TYPE_NONE,
EVENT_TYPE_FALLING_EDGE,
EVENT_TYPE_RISING_EDGE,
} event_type_t;
#define COLLECTED_DATA_SIZE 21
/*********************************************************************//**
* @brief
Gets the next record index to be requested based on the last record already collected
* @param[in]
actualIndex
* @return
uint16_t
*********************************************************************/
uint16_t u16GetNextIndex(uint16_t
{
uint16_t
lastRecord
uint16_t
firstRecord
uint16_t
recordsQtty
// when the index of collected record is different from the index of last record in memory
if
(actualIndex
{
// no record has been overwritten
if
(lastRecord
{
}
// records circulated the memory
else if
{
memory capacity
memory capacity
}
}
return
actualIndex;
}
/*********************************************************************//**
* @brief
Thread to monitor new records and collect when needed
* @param[in]
None
* @return
None
*********************************************************************/
(void)
void
TaskReadMem
{
uint16_t
actualIndex
while
(1)
{
// reads the index of the last record in memory
lastRecord
// if the index of collected record is different from the index of last record in memory
if
(lastRecord
{
NOVUS AUTOMATION
Record index from register already collected
Next record index to be collected
actualIndex)
= FncReadSingleRegisterModbus(ADDR_LAST_RECORD);
= FncReadSingleRegisterModbus(ADDR_FIRST_RECORD_REGISTER);
= FncReadSingleRegisterModbus(ADDR_MAX_RECORDS_QTTY);
!= lastRecord)
> firstRecord)
// collected record index is less than the index of last record in memory
if
(actualIndex
< lastRecord)
{
return
actualIndex
}
(lastRecord
< firstRecord)
// collected record index is less than the index of last record in memory
if
(actualIndex
< lastRecord)
{
return
actualIndex
}
// collected record index is higher than the most recent record and LESS than
else if
(actualIndex
< recordsQtty)
{
return
actualIndex
}
// collected record index is higher than the most recent record and HIGHER than
else
{
return
1;
// first record address
}
= 0, nextIndex, lastRecord, buf[COLLECTED_DATA_SIZE];
= FncReadSingleRegisterModbus(ADDR_LAST_RECORD);
!= actualIndex)
= u16GetNextIndex(actualIndex);
nextIndex
// requests a record by writing the index through a modbus register
FncWriteSingleRegisterModbus(ADDR_REQUESTED_RECORD, nextIndex);
// collects record data from requested index
FncReadBufferModbus(buf, ADDR_TIMESTAMP_UNIX_HIGH, COLLECTED_DATA_SIZE);
// after app uses the record, should update the index
if
(FncUseColletedData(buf) == FNC_SUCCESS)
{
= nextIndex;
actualIndex
+ 1;
+ 1;
+ 1;
99/102

Publicité

loading