Skip to content

Commit

Permalink
Fix ringbuffers that are not consumed: they need to have events pushe…
Browse files Browse the repository at this point in the history
…d regardless
  • Loading branch information
wegendt-bosch committed Nov 11, 2019
1 parent f94f34d commit f662355
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,23 +43,23 @@ class StartupGenerator implements IPlatformStartupGenerator {
StdlibTypeRegistry typeRegistry

override generateMain(CompilationContext context) {
val startupEventHandlers = context.allEventHandlers
val startupEventHandlersAndEvents = context.allEventHandlers
.map[it -> it.event]
.filter[it.value instanceof SystemEventSource]
.map[it.key -> it.value as SystemEventSource]
.map[it.key -> it.value.source]
.filter[it.value.name == "startup"]
.map[it.key]
.filter[it.payload !== null];
return codeFragmentProvider.create('''
Mita_initialize();
Mita_goLive();
int32_t exception = 0;
«FOR startupEventHandler: startupEventHandlers»
«FOR startupEventHandler_event: startupEventHandlersAndEvents»
«val startupEventHandler = startupEventHandler_event.key»
«val event = startupEventHandler_event.value»
«pushGenerator.generate(
startupEventHandler,
new CodeWithContext(
RingbufferGenerator.wrapInRingbuffer(typeRegistry, startupEventHandler, BaseUtils.getType(startupEventHandler.payload)),
RingbufferGenerator.wrapInRingbuffer(typeRegistry, startupEventHandler, BaseUtils.getType(event)),
Optional.empty,
codeFragmentProvider.create('''rb_«startupEventHandler.baseName»''')
),
Expand Down Expand Up @@ -89,8 +89,8 @@ class StartupGenerator implements IPlatformStartupGenerator {
return 0;
''')
.setPreamble('''
«FOR startupEventHandler: startupEventHandlers»
extern ringbuffer_int32_t rb_«startupEventHandler.baseName»;
«FOR startupEventHandler_event: startupEventHandlersAndEvents»
extern ringbuffer_int32_t rb_«startupEventHandler_event.key.baseName»;
«ENDFOR»
''')
.addHeader('time.h', true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import org.eclipse.mita.program.generator.CodeWithContext
import org.eclipse.mita.library.stdlib.RingbufferGenerator
import org.eclipse.mita.base.util.BaseUtils
import java.util.Optional
import static extension org.eclipse.mita.base.util.BaseUtils.castOrNull;

class ButtonGenerator extends AbstractSystemResourceGenerator {

Expand Down Expand Up @@ -80,7 +81,7 @@ class ButtonGenerator extends AbstractSystemResourceGenerator {
«pushGenerator.generate(
changedHandler,
new CodeWithContext(
RingbufferGenerator.wrapInRingbuffer(typeRegistry, changedHandler, BaseUtils.getType(changedHandler.payload)),
RingbufferGenerator.wrapInRingbuffer(typeRegistry, changedHandler, BaseUtils.getType(changedHandler.event.castOrNull(SystemEventSource).source)),
Optional.empty,
codeFragmentProvider.create('''rb_«changedHandler.baseName»''')
),
Expand Down

0 comments on commit f662355

Please sign in to comment.