-
-
Notifications
You must be signed in to change notification settings - Fork 499
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
What does this code do? #52
Comments
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: 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. |
Initialized to 0s based on how many conditional statements created for each sensor (line 3076):
Set from 0 to value in SQLite DB (line 3134):
Then check if != 0 (line 768):
|
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. |
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. |
Thanks for the help. If you can assist me in understanding a little bit... Is what I'm trying to accomplish achieved by changing: |
I'm fairly sure that did it. Because I'm only setting the first element of the third list, this needs to be 1? |
Nope. List out of range error when multiple sensors is use. |
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: |
Perhaps x, y, and z of get_3d_array() should be reversed, to enhance readability. |
X Y and Z are arbitrary. I purposefully didn't put any of the sensor logic On Mon, Nov 23, 2015 at 1:41 AM, Kyle Gabriel notifications@github.com
|
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:
But if x, y, and z are reversed, it appears as:
|
Hello!
I am just curious about the code here:
Mycodo/3.5/cgi-bin/mycodo.py
Line 3305 in 7034895
on my system it seems to produce an array of zeroes. Something like this:
where
conditional_t_number_conditional has a length of 10 and
conditional_t_number_sensor has a length of 4
Could you help me understand this code?
The text was updated successfully, but these errors were encountered: