profile.h
1 /*
2  * EEZ PSU Firmware
3  * Copyright (C) 2015-present, Envox d.o.o.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9 
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14 
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #pragma once
20 
21 #include "temperature.h"
22 
23 namespace eez {
24 namespace psu {
26 namespace profile {
27 
29 struct ChannelFlags {
30  unsigned output_enabled : 1;
31  unsigned sense_enabled : 1;
32  unsigned u_state : 1;
33  unsigned i_state : 1;
34  unsigned p_state : 1;
35  unsigned cal_enabled : 1;
36  unsigned rprog_enabled : 1;
37  unsigned reserverd10 : 1;
38  unsigned lripple_auto_enabled : 1;
39  unsigned parameters_are_valid : 1;
40  unsigned displayValue1 : 2;
41  unsigned displayValue2 : 2;
42  unsigned u_triggerMode : 2;
43  unsigned i_triggerMode : 2;
44  unsigned reserved: 14;
45 };
46 
49  ChannelFlags flags;
50  float u_set;
51  float u_step;
52  float u_limit;
53  float u_delay;
54  float u_level;
55  float i_set;
56  float i_step;
57  float i_limit;
58  float i_delay;
59  float p_limit;
60  float p_delay;
61  float p_level;
62  float ytViewRate;
63  float u_triggerValue;
64  float i_triggerValue;
65  uint16_t listCount;
66 #ifdef EEZ_PSU_SIMULATOR
67  bool load_enabled;
68  float load;
69  float voltProgExt;
70 #endif
71 };
72 
74 struct ProfileFlags {
75  unsigned isValid: 1;
76  unsigned powerIsUp: 1;
77  unsigned channelsCoupling : 2;
78  unsigned reserverd : 12;
79 };
80 
82 struct Parameters {
84  ProfileFlags flags;
85  char name[PROFILE_NAME_MAX_LENGTH + 1];
86  ChannelParameters channels[CH_MAX];
87  temperature::ProtectionConfiguration temp_prot[temp_sensor::MAX_NUM_TEMP_SENSORS];
88 };
89 
90 void tick(uint32_t tick_usec);
91 
92 void recallChannelsFromProfile(Parameters *profile, int location);
93 bool recallFromProfile(Parameters *profile, int location);
94 bool recall(int location);
95 
96 bool load(int location, Parameters *profile);
97 
98 void getSaveName(const Parameters *profile, char *name);
99 
100 bool enableSave(bool enable);
101 void save();
102 void saveImmediately();
103 void flush();
104 bool saveAtLocation(int location, char *name = 0);
105 
106 bool deleteLocation(int location);
107 bool deleteAll();
108 
109 bool isValid(int location);
110 
111 bool setName(int location, const char *name, size_t nameLength);
112 void getName(int location, char *name, int count);
113 
114 }
115 }
116 } // namespace eez::psu::profile
Channel binary flags stored in profile.
Definition: profile.h:29
Namespace for the everything from the EEZ.
Definition: actions.cpp:41
Profile parameters.
Definition: profile.h:82
Channel binary flags stored in profile.
Definition: profile.h:74
Channel parameters stored in profile.
Definition: profile.h:48
Configuration data for the temperature protection.
Definition: temperature.h:32
Header of the every block stored in EEPROM. It contains checksum and version.
Definition: persist_conf.h:40
#define PROFILE_NAME_MAX_LENGTH
Profile name maximum length in number of characters.
Definition: conf_advanced.h:148