Exemplo n.º 1
0
    void assertHasAdcEventWithSample(int      channelId,
                                     uint16_t value) {

        EventType   *adcEventType = AdcEventType_get();
        Event       *event        = EventSource_poll(_eventSource);

        CHECK( event != NULL);
        POINTERS_EQUAL(adcEventType, Event_getEventType(event));

        AdcEvent  *adcEvent = AdcEvent_fromEvent(event);
        AdcSample *sample   = AdcEvent_getSample(adcEvent);

        CHECK_EQUAL(channelId, AdcSample_getChannelId(sample));
        CHECK_EQUAL(value, AdcSample_getValue(sample))
    }
Exemplo n.º 2
0
static void BasicAdcService_onSample(
        BasicAdcService *self,
        AdcEvent *event) {

    AdcSample *sample          = AdcEvent_getSample(event);
    int        sampleChannelId = AdcSample_getChannelId(sample);

    for ( AdcChannel *channel = self->channelListHead;
          channel != NULL;
          channel = channel->next ) {

        int channelId = AdcChannel_getChannelId(channel);

        if ( channelId == sampleChannelId ) {
            AdcChannel_onSample(channel, sample);
        }
    }
}