private RouteComponent createReducer(bool counter) { if (!counter) { if (source.attributes.length() <= 0) { throw new IllegalRouteOperationException("Cannot accumulate null data"); } if (source.attributes.length() > 4) { throw new IllegalRouteOperationException("Cannot accumulate data longer than 4 bytes"); } } byte output = 4; DataAttributes attributes = new DataAttributes(new byte[] { output }, 1, 0, !counter && source.attributes.signed); DataTypeBase processor = counter ? new IntegralDataType(source, DATA_PROCESSOR, DataProcessor.NOTIFY, attributes) : source.dataProcessorCopy(source, attributes); byte[] config = new byte[] { 0x2, (byte)(((output - 1) & 0x3) | (((source.attributes.length() - 1) & 0x3) << 2) | (counter ? 0x10 : 0)) }; EditorImplBase editor = counter ? new CounterEditorInner(config, processor, state.bridge) as EditorImplBase : new AccumulatorEditorInner(config, processor, state.bridge) as EditorImplBase; DataTypeBase processorState = counter ? new IntegralDataType(null, DATA_PROCESSOR, Util.setRead(DataProcessor.STATE), attributes) : processor.dataProcessorStateCopy(source, attributes); return(postCreate(processorState, editor)); }
private RouteComponent createReducer(bool counter) { if (!counter) { if (source.attributes.length() <= 0) { throw new IllegalRouteOperationException("Cannot accumulate null data"); } if (source.attributes.length() > 4) { throw new IllegalRouteOperationException("Cannot accumulate data longer than 4 bytes"); } } byte output = 4; DataProcessorConfig config = new DataProcessorConfig.AccumulatorConfig(counter, output, source.attributes.length()); var next = source.transform(config); EditorImplBase editor = counter ? new CounterEditorInner(config, next.Item1, state.bridge) as EditorImplBase : new AccumulatorEditorInner(config, next.Item1, state.bridge) as EditorImplBase; return(postCreate(next.Item2, editor)); }
private RouteComponent postCreate(DataTypeBase processorState, EditorImplBase editor) { state.dataProcessors.AddLast(Tuple.Create(processorState, editor)); return(new RouteComponent(editor.source, this)); }