Comments (11)
Heh... This may not be efficient at all, but it works. I am storing the variables for each conditional statement (may be multiple) for each sensor (may be multiple).
Directly after initializing the array, the arrays are set:
Lines 3116 though 3156.
Then on lines 768 and beyond it will check if the value is not 0 to determine if there is a conditional.
Why there is a range of 10, I'm not sure. This was a tricky section for me to get working and I believe I haven't put much more thought into it after I found the first working solution.
from mycodo.
Initialized to 0s based on how many conditional statements created for each sensor (line 3076):
cur.execute('SELECT id FROM tsensor')
for row in cur:
conditional_t_number_sensor.append(row[0])
cur.execute('SELECT id FROM tsensorconditional')
for row in cur:
conditional_t_number_conditional.append(row[0])
conditional_t_id = [[[0 for k in xrange(10)] for j in xrange(len(conditional_t_number_conditional))] for i in xrange(len(conditional_t_number_sensor))]
Set from 0 to value in SQLite DB (line 3134):
for row in cur:
conditional_t_id[j][count][0] = row[0]
Then check if != 0 (line 768):
#
# Check if T conditional statements are true
#
for j in range(0, len(conditional_t_number_sensor)):
for k in range(0, len(conditional_t_number_conditional)):
if conditional_t_id[j][k][0] != 0 and client_que != 'TerminateServer' and pause_daemon != 1 and PID_change != 1:
from mycodo.
Aha! I think I used 10 because at the time I was unsure how to define the proper length. I figured 10 would be enough conditional statements for each sensor and I would come back and fix this later. I actually am unsure what I was thinking and I'm still a little unsure how the code works, but I managed to get it working.
from mycodo.
Gotcha. Everybody has code like that sometimes. 😆
I rewrote some of this. You will need to test to make sure that it creates the same values you are expecting but I don't anticipate that it is any different.
from mycodo.
Thanks for the help. If you can assist me in understanding a little bit... Is what I'm trying to accomplish achieved by changing:
conditional_t_id = get_3d_array(10, len(conditional_t_number_conditional), len(conditional_t_number_sensor))
to
conditional_t_id = get_3d_array(len(conditional_t_number_sensor), len(conditional_t_number_conditional), 1)
Initial tests seem to work... Still testing, though.
from mycodo.
I'm fairly sure that did it. Because I'm only setting the first element of the third list, this needs to be 1?
The array is initialized with:
conditional_t_id = get_3d_array(len(conditional_t_number_sensor), len(conditional_t_number_conditional), 1)
Then the last element is set with:
conditional_t_id[j][count][0] = row[0]
from mycodo.
Nope. List out of range error when multiple sensors is use.
from mycodo.
Aha. After some rudimentary testing, I found that I was misinterpreting how I was declaring the 3d array. I was understanding it backwards. The following is the correct way to declare the array:
conditional_t_id = get_3d_array(1, len(conditional_t_number_conditional), len(conditional_t_number_sensor))
If I want to read it like:
conditional_t_id[sensor_number][conditional_number][0]
Fixed in fe583e9
from mycodo.
Perhaps x, y, and z of get_3d_array() should be reversed, to enhance readability.
from mycodo.
X Y and Z are arbitrary. I purposefully didn't put any of the sensor logic
into that function. It might be worthwhile to put some notes before the
blocks of initialization to say what you are using it for there. :)
On Mon, Nov 23, 2015 at 1:41 AM, Kyle Gabriel [email protected]
wrote:
Perhaps x, y, and z of get_3d_array() should be reversed, to enhance
readability.—
Reply to this email directly or view it on GitHub
#52 (comment).
from mycodo.
Good idea. I'll add some comments.
I was meaning with reversing x y, and z for readability, so the order of the function parameters is the same order as the array indexes. For instance, currently this is how the function and array is used:
conditional_array = get_3d_array(1, number_conditionals, number_sensors)
conditional_array[number of sensors][number of conditionals][0] = True
But if x, y, and z are reversed, it appears as:
conditional_array = get_3d_array(number_sensors, number_conditionals, 1)
conditional_array[number of sensors][number of conditionals][0] = True
from mycodo.
Related Issues (20)
- MS-SQL data as an input. HOT 1
- Input - loop() Error HOT 1
- No influxdb Sensor Data displayed in Mycodo | Numpy import error HOT 4
- GNU License Window Unresponsive HOT 6
- Failed to restart nginx.service HOT 6
- Error: dialog not installed. Install it then try the Mycodo setup again. HOT 2
- Add ability to edit measurement database entries HOT 3
- Dashboard camera Acquire Image (and save temporary file) permissions error HOT 6
- 1.3" Oled SSD1306 v SSH1106 HOT 1
- CAN Bus for sensors and relays HOT 6
- Error 500: Internal Server Error HOT 5
- sensors stop giving readings after an hour or two and wont reinitialize without a power cycle HOT 2
- urllib camera numpy issue HOT 21
- Permission denied when saving Conditional Controller Function HOT 4
- request to add Adafruit NeoKey 1x4 input board HOT 69
- Request to add DFRobot i2c DAC output module (0-10v) HOT 43
- PCF8575 activating multiple /wrong outputs on PCF8575 16 Channel Relay module HOT 11
- Add notes via API HOT 5
- Zigbee2MQTT Plugin for Mycodo HOT 3
- Bang-Bang controller hangs randomly. Can not acquire a measurement, but all inputs and calculation Functions are working with no errors. HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mycodo.