forked from sfeakes/AqualinkD
-
Notifications
You must be signed in to change notification settings - Fork 2
/
aq_programmer.h
175 lines (146 loc) · 5.46 KB
/
aq_programmer.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
#ifndef AQ_PROGRAMMER_H_
#define AQ_PROGRAMMER_H_
#include <pthread.h>
//#include "aqualink.h"
#define PROGRAMMING_POLL_DELAY_TIME 10
//#define PROGRAMMING_POLL_DELAY_TIME 2
//#define PROGRAMMING_POLL_DELAY_TIME 5
#define PROGRAMMING_POLL_COUNTER 200
// need to get the C values from aqualink manual and add those just incase
// someone has the controller set to C.
#define HEATER_MAX_F 104
#define HEATER_MIN_F 36
#define FREEZE_PT_MAX_F 42
#define FREEZE_PT_MIN_F 34
#define HEATER_MAX_C 40
#define HEATER_MIN_C 0
#define FREEZE_PT_MAX_C 5
#define FREEZE_PT_MIN_C 1
#define SWG_PERCENT_MAX 101
#define SWG_PERCENT_MIN 0
#define PTHREAD_ARG 25
#define LIGHT_MODE_BUFER PTHREAD_ARG
typedef enum emulation_type{
SIM_NONE = -1,
ALLBUTTON,
RSSADAPTER,
ONETOUCH,
IAQTOUCH,
AQUAPDA, // AQUAPALM and PDA are taken as specific type.
JANDY_DEVICE, // Very rarley used.
SIMULATOR
} emulation_type;
typedef enum {
AQP_NULL = -1,
AQ_GET_POOL_SPA_HEATER_TEMPS,
AQ_GET_FREEZE_PROTECT_TEMP,
AQ_SET_TIME,
AQ_SET_POOL_HEATER_TEMP,
AQ_SET_SPA_HEATER_TEMP,
AQ_SET_FRZ_PROTECTION_TEMP,
AQ_GET_DIAGNOSTICS_MODEL,
//AQ_SEND_CMD,
AQ_GET_PROGRAMS,
AQ_SET_LIGHTPROGRAM_MODE,
AQ_SET_LIGHTCOLOR_MODE,
AQ_SET_SWG_PERCENT,
AQ_PDA_DEVICE_STATUS,
AQ_PDA_DEVICE_ON_OFF,
AQ_GET_AUX_LABELS,
AQ_SET_BOOST,
AQ_SET_PUMP_RPM,
AQ_SET_PUMP_VS_PROGRAM,
// ******** Delimiter make sure to change MAX/MIN below
// NSF Need to add Specific ALL Button ones here
// ******** Delimiter make sure to change MAX/MIN below
// NSF Need to add ALL Specific PDA ones here
AQ_PDA_INIT,
AQ_PDA_WAKE_INIT,
// ******** Delimiter make sure to change MAX/MIN below
AQ_SET_ONETOUCH_PUMP_RPM,
AQ_SET_ONETOUCH_MACRO,
AQ_GET_ONETOUCH_SETPOINTS,
AQ_SET_ONETOUCH_POOL_HEATER_TEMP,
AQ_SET_ONETOUCH_SPA_HEATER_TEMP,
AQ_GET_ONETOUCH_FREEZEPROTECT,
AQ_SET_ONETOUCH_FREEZEPROTECT,
AQ_SET_ONETOUCH_TIME,
AQ_SET_ONETOUCH_BOOST,
AQ_SET_ONETOUCH_SWG_PERCENT,
// ******** Delimiter make sure to change MAX/MIN below
AQ_SET_IAQTOUCH_PUMP_RPM,
AQ_SET_IAQTOUCH_PUMP_VS_PROGRAM,
AQ_GET_IAQTOUCH_VSP_ASSIGNMENT,
AQ_GET_IAQTOUCH_SETPOINTS,
AQ_GET_IAQTOUCH_FREEZEPROTECT,
AQ_SET_IAQTOUCH_FREEZEPROTECT,
AQ_GET_IAQTOUCH_AUX_LABELS,
AQ_SET_IAQTOUCH_SWG_PERCENT,
AQ_SET_IAQTOUCH_SWG_BOOST,
AQ_SET_IAQTOUCH_POOL_HEATER_TEMP,
AQ_SET_IAQTOUCH_SPA_HEATER_TEMP,
AQ_SET_IAQTOUCH_SET_TIME,
AQ_SET_IAQTOUCH_DEVICE_ON_OFF,
AQ_SET_IAQTOUCH_LIGHTCOLOR_MODE,
// ******** Delimiter make sure to change MAX/MIN below
AQ_GET_RSSADAPTER_SETPOINTS,
AQ_SET_RSSADAPTER_POOL_HEATER_TEMP,
AQ_SET_RSSADAPTER_SPA_HEATER_TEMP,
AQ_ADD_RSSADAPTER_POOL_HEATER_TEMP,
AQ_ADD_RSSADAPTER_SPA_HEATER_TEMP,
// ******** Delimiter make sure to change MAX/MIN below
} program_type;
#define AQP_GENERIC_MIN AQ_GET_POOL_SPA_HEATER_TEMPS
#define AQP_GENERIC_MAX AQ_SET_PUMP_VS_PROGRAM
#define AQP_ALLBUTTON_MIN AQP_NULL
#define AQP_ALLBUTTONL_MAX AQP_NULL
#define AQP_PDA_MIN AQ_PDA_INIT
#define AQP_PDA_MAX AQ_PDA_WAKE_INIT
#define AQP_ONETOUCH_MIN AQ_SET_ONETOUCH_PUMP_RPM
#define AQP_ONETOUCH_MAX AQ_SET_ONETOUCH_SWG_PERCENT
#define AQP_IAQTOUCH_MIN AQ_SET_IAQTOUCH_PUMP_RPM
#define AQP_IAQTOUCH_MAX AQ_SET_IAQTOUCH_LIGHTCOLOR_MODE
#define AQP_RSSADAPTER_MIN AQ_GET_RSSADAPTER_SETPOINTS
#define AQP_RSSADAPTER_MAX AQ_ADD_RSSADAPTER_SPA_HEATER_TEMP
struct programmingThreadCtrl {
pthread_t thread_id;
//void *thread_args;
char thread_args[PTHREAD_ARG];
struct aqualinkdata *aq_data;
};
typedef enum pump_type {
PT_UNKNOWN = -1,
EPUMP, // = ePump AC & Jandy ePUMP
VSPUMP, // = Intelliflo VS
VFPUMP // = Intelliflo VF
} pump_type;
//void aq_programmer(program_type type, void *args, struct aqualinkdata *aq_data);
void aq_programmer(program_type type, char *args, struct aqualinkdata *aq_data);
//void kick_aq_program_thread(struct aqualinkdata *aq_data);
void kick_aq_program_thread(struct aqualinkdata *aq_data, emulation_type source_type);
bool in_programming_mode(struct aqualinkdata *aq_data);
bool in_ot_programming_mode(struct aqualinkdata *aq_data);
bool in_iaqt_programming_mode(struct aqualinkdata *aq_data);
bool in_swg_programming_mode(struct aqualinkdata *aq_data);
bool in_light_programming_mode(struct aqualinkdata *aq_data);
bool in_allb_programming_mode(struct aqualinkdata *aq_data);
void aq_send_cmd(unsigned char cmd);
void queueGetProgramData(emulation_type source_type, struct aqualinkdata *aq_data);
//void queueGetExtendedProgramData(emulation_type source_type, struct aqualinkdata *aq_data, bool labels);
unsigned char pop_aq_cmd(struct aqualinkdata *aq_data);
void waitForSingleThreadOrTerminate(struct programmingThreadCtrl *threadCtrl, program_type type);
void cleanAndTerminateThread(struct programmingThreadCtrl *threadCtrl);
//void force_queue_delete() // Yes I want compiler warning if this is used.
//bool push_aq_cmd(unsigned char cmd);
//void send_cmd(unsigned char cmd, struct aqualinkdata *aq_data);
//void cancel_menu(struct aqualinkdata *aq_data);
//void *set_aqualink_time( void *ptr );
//void *get_aqualink_pool_spa_heater_temps( void *ptr );
int get_aq_cmd_length();
int setpoint_check(int type, int value, struct aqualinkdata *aqdata);
int RPM_check(pump_type type, int value, struct aqualinkdata *aqdata);
//int RPM_check(int type, int value, struct aqualinkdata *aqdata);
const char *ptypeName(program_type type);
const char *programtypeDisplayName(program_type type);
void force_queue_delete();
#endif