auto-sync

This commit is contained in:
rusEfi 2016-07-05 20:02:56 -04:00
parent 8d1cdf757e
commit 4e588ff8f1
7 changed files with 99 additions and 80 deletions

View File

@ -103,15 +103,18 @@ extern short currentPageId;
*/
LoggingWithStorage tsLogger("binary");
extern persistent_config_s configWorkingCopy;
/**
* this is a local copy of the configuration. Any changes to this copy
* have no effect until this copy is explicitly propagated to the main working copy
*/
persistent_config_s configWorkingCopy;
extern persistent_config_container_s persistentState;
static efitimems_t previousWriteReportMs = 0;
ts_channel_s tsChannel;
extern uint8_t crcWriteBuffer[300];
static int ts_serial_ready(bool isConsoleRedirect) {
#if EFI_PROD_CODE || defined(__DOXYGEN__)
if (isSerialOverUart() ^ isConsoleRedirect) {
@ -557,11 +560,6 @@ void syncTunerStudioCopy(void) {
tunerstudio_counters_s tsState;
TunerStudioOutputChannels tsOutputChannels;
/**
* this is a local copy of the configuration. Any changes to this copy
* have no effect until this copy is explicitly propagated to the main working copy
*/
persistent_config_s configWorkingCopy;
short currentPageId;

View File

@ -398,7 +398,7 @@ public:
* here we have all the listeners which should be notified about a configuration
* change
*/
IntListenerArray configurationListeners;
IntListenerArray<15> configurationListeners;
monitoring_timestamps_s m;

View File

@ -32,7 +32,7 @@ public:
efitick_t nowNt;
volatile efitime_t previousShaftEventTimeNt;
private:
IntListenerArray triggerListeneres;
IntListenerArray<15> triggerListeneres;
int hwEventCounters[HW_EVENT_TYPES];
};
#endif

View File

@ -19,10 +19,8 @@ typedef struct {
bool isActiveHigh; // false for ICU_INPUT_ACTIVE_LOW, true for ICU_INPUT_ACTIVE_HIGH
volatile bool started;
// todo: make this a template & reduce number of listeners?
// todo: would one listener be enough?
IntListenerArray widthListeners;
IntListenerArray periodListeners;
IntListenerArray<1> widthListeners;
IntListenerArray<1> periodListeners;
} digital_input_s;
void turnOnCapturePin(const char *msg, brain_pin_e brainPin);

View File

@ -289,14 +289,14 @@ void firmwareError(const char *errorMsg, ...) {
}
}
static char UNUSED_RAM_SIZE[100];
static char UNUSED_RAM_SIZE[2100];
static char UNUSED_CCM_SIZE[3600] CCM_OPTIONAL;
static char UNUSED_CCM_SIZE[8500] CCM_OPTIONAL;
int getRusEfiVersion(void) {
if (UNUSED_RAM_SIZE[0] != 0)
return 123; // this is here to make the compiler happy about the unused array
if (UNUSED_CCM_SIZE[0] * 0 != 0)
return 3211; // this is here to make the compiler happy about the unused array
return 20160630;
return 20160705;
}

View File

@ -8,58 +8,3 @@
#include "listener_array.h"
#include "main.h"
IntListenerArray::IntListenerArray() {
currentListenersCount = 0;
memset(&args, 0, sizeof(args));
memset(&callbacks, 0, sizeof(callbacks));
}
void IntListenerArray::registerCallback(VoidInt handler, void *arg) {
efiAssertVoid(currentListenersCount < MAX_INT_LISTENER_COUNT, "Too many callbacks");
int index = currentListenersCount++;
callbacks[index] = handler;
args[index] = arg;
}
void IntListenerArray::registerCallback(Void listener) {
registerCallback((VoidInt)listener, NULL);
}
void invokeCallbacks(IntListenerArray *array, int value) {
for (int i = 0; i < array->currentListenersCount; i++)
(array->callbacks[i])(value);
}
void IntListenerArray::invokeJustArgCallbacks() {
for (int i = 0; i < currentListenersCount; i++) {
VoidPtr listener = (VoidPtr)callbacks[i];
void *arg = args[i];
(listener)(arg);
}
}
void invokeArgIntCallbacks(IntListenerArray *array, int value) {
for (int i = 0; i < array->currentListenersCount; i++) {
ArgIntListener listener = (ArgIntListener)array->callbacks[i];
void *arg = array->args[i];
(listener)(arg, value);
}
}
void invokeIntIntCallbacks(IntListenerArray *array, int value, int value2) {
for (int i = 0; i < array->currentListenersCount; i++) {
VoidIntInt listener = (VoidIntInt)array->callbacks[i];
(listener)(value, value2);
}
}
void invokeIntIntVoidCallbacks(IntListenerArray *array, int value, int value2) {
for (int i = 0; i < array->currentListenersCount; i++) {
IntIntVoidListener listener = (IntIntVoidListener)array->callbacks[i];
(listener)(value, value2, array->args[i]);
}
}
void clearCallbacks(IntListenerArray *array) {
array->currentListenersCount = 0;
}

View File

@ -8,9 +8,9 @@
#ifndef LISTENER_ARRAY_H_
#define LISTENER_ARRAY_H_
#include <stddef.h>
#include "rusefi_types.h"
#define MAX_INT_LISTENER_COUNT 15
#include "error_handling.h"
// todo: reorder parameters for consistency?
typedef void (*IntIntVoidListener)(int value1, int value2, void *arg);
@ -20,6 +20,7 @@ typedef void (*ArgListener)(void *arg);
typedef void (*ArgIntListener)(void *arg, int value);
// todo: rename this class, that's not just 'callback(int param) anymore
template<int MAX_INT_LISTENER_COUNT>
class IntListenerArray {
public:
IntListenerArray();
@ -31,11 +32,88 @@ public:
void * args[MAX_INT_LISTENER_COUNT];
};
void invokeCallbacks(IntListenerArray *array, int value);
void invokeJustArgCallbacks(IntListenerArray *array);
void invokeArgIntCallbacks(IntListenerArray *array, int value);
void invokeIntIntCallbacks(IntListenerArray *array, int value, int value2);
void invokeIntIntVoidCallbacks(IntListenerArray *array, int value, int value2);
void clearCallbacks(IntListenerArray *array);
//template<int MAX_INT_LISTENER_COUNT>
//void invokeCallbacks(IntListenerArray *array, int value);
//
//template<int MAX_INT_LISTENER_COUNT>
//void invokeJustArgCallbacks(IntListenerArray *array);
//
//template<int MAX_INT_LISTENER_COUNT>
//void invokeArgIntCallbacks(IntListenerArray *array, int value);
//
//template<int MAX_INT_LISTENER_COUNT>
//void invokeIntIntCallbacks(IntListenerArray *array, int value, int value2);
//
//template<int MAX_INT_LISTENER_COUNT>
//void invokeIntIntVoidCallbacks(IntListenerArray *array, int value, int value2);
//template<int MAX_INT_LISTENER_COUNT>
//void clearCallbacks(IntListenerArray *array);
template<int MAX_INT_LISTENER_COUNT>
IntListenerArray<MAX_INT_LISTENER_COUNT>::IntListenerArray() {
currentListenersCount = 0;
memset(&args, 0, sizeof(args));
memset(&callbacks, 0, sizeof(callbacks));
}
template<int MAX_INT_LISTENER_COUNT>
void IntListenerArray<MAX_INT_LISTENER_COUNT>::registerCallback(VoidInt handler, void *arg) {
efiAssertVoid(currentListenersCount < MAX_INT_LISTENER_COUNT, "Too many callbacks");
int index = currentListenersCount++;
callbacks[index] = handler;
args[index] = arg;
}
template<int MAX_INT_LISTENER_COUNT>
void IntListenerArray<MAX_INT_LISTENER_COUNT>::registerCallback(Void listener) {
registerCallback((VoidInt)listener, NULL);
}
template<int MAX_INT_LISTENER_COUNT>
void invokeCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value) {
for (int i = 0; i < array->currentListenersCount; i++)
(array->callbacks[i])(value);
}
template<int MAX_INT_LISTENER_COUNT>
void IntListenerArray<MAX_INT_LISTENER_COUNT>::invokeJustArgCallbacks() {
for (int i = 0; i < currentListenersCount; i++) {
VoidPtr listener = (VoidPtr)callbacks[i];
void *arg = args[i];
(listener)(arg);
}
}
template<int MAX_INT_LISTENER_COUNT>
void invokeArgIntCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value) {
for (int i = 0; i < array->currentListenersCount; i++) {
ArgIntListener listener = (ArgIntListener)array->callbacks[i];
void *arg = array->args[i];
(listener)(arg, value);
}
}
template<int MAX_INT_LISTENER_COUNT>
void invokeIntIntCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value, int value2) {
for (int i = 0; i < array->currentListenersCount; i++) {
VoidIntInt listener = (VoidIntInt)array->callbacks[i];
(listener)(value, value2);
}
}
template<int MAX_INT_LISTENER_COUNT>
void invokeIntIntVoidCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array, int value, int value2) {
for (int i = 0; i < array->currentListenersCount; i++) {
IntIntVoidListener listener = (IntIntVoidListener)array->callbacks[i];
(listener)(value, value2, array->args[i]);
}
}
template<int MAX_INT_LISTENER_COUNT>
void clearCallbacks(IntListenerArray<MAX_INT_LISTENER_COUNT> *array) {
array->currentListenersCount = 0;
}
#endif /* LISTENER_ARRAY_H_ */