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)
- Blank Widgets HOT 10
- mycodo ERROR - mycodo.influx - Unknown Influxdb version: HOT 3
- Action - Ramp Value
- add ability to copy a function
- Request to add DFRobot i2c Fermion: LWLP5000 Differential Pressure Sensor (Β±500pa)
- Allow setting the same output fΓΌr PID Controller and PID Autotune
- request add Days Counter with advanced functions
- PID widgets display null instead of negative values HOT 12
- Volume Flow Rate in Gallons as well as Liters HOT 1
- Reverse pumping using trigger function with volume not permitted
- Upgrade problem HOT 6
- fswebcam and config file HOT 1
- Installing dependency `bluepy` results in `Could not build wheels for bluepy` HOT 2
- Introducing a Version of the Enhanced Mycodo Integration for Home Assistant HACS HOT 3
- Error with I2C OLED: NameError 'DigitalInOut' is not defined in spi_device.py HOT 3
- Please add MQTT Publish Action to Vapor Pressure Deficit Function, or a Function that can publish mult-values in JSON packet format.
- CCS811 measures continuosly rising
- BME680 co2 measurment
- Running 2 BME680 on 1 i2c bus with master/slave address - second sensor not initializing
- MAX31855 thermocouple input library errors HOT 5
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.