About the temperature graphs
1. About the temperature graph
The temperature graphs are generated using the index.php file. The PHP file calls a .sh file to query the database and generates the .txt and another .sh file to graph the .png files display on the web page.
The index.php files checks the file time stamps, and regenerate the page periodically. The are refresh_all.sh accomplishes the same think, if you what to manually refresh the graphs. To start, it a good ideal to run refresh_all.sh, since it creates all the data files and set the proper file permissions.
2. MYSQL server notes
The IRTF mysql database server is 'irtfweb'. The user name 'spex' exist for the spex project. A database name 'spex' exist for the spex project. This was setup by the mysql admin, like so:
mysql> CREATE DATABASE spex; mysql> GRANT ALL ON spex.* TO 'spex'@'%' IDENTIFIED BY 'thepassword'; mysql> GRANT ALL ON spex.* TO 'spex'@'localhost' IDENTIFIED BY 'thepassword';The password for each projects is standard, see the mysql administrator.
3. Creating mysql Tables
# table for Data: # NOTE: Also create a Data_sim table for putting in test data. CREATE TABLE Data( SensorID varchar(10), # sensor Identification Timestamp int(10), # timestamp in unix seconds, 64-bit INT SensorData varchar(12) # sensor data collected, ); CREATE TABLE Data_sim( SensorID varchar(10), # sensor Identification Timestamp int(10), # timestamp in unix seconds, 64-bit INT SensorData varchar(12) # sensor data collected, ); # table for Sensors: CREATE TABLE Sensors ( SensorID varchar(10), # sensor Identification Notes varchar(250), # comments, descriptions, etc. PRIMARY KEY ( SensorID ) );
4. spex temperature tables
Spex saves it data using an Timestamp, SensorID, and Data record. Similar to IQUP databases. For spex's temperature we established the following SensorID:
tc330a - bigdog's temperature controller: 330a_cdat = bigdog control temperature, kelvin 330a_sdat = bigdog sample temperature, kelvin 330a_setpt = bigdog control set point, kelvin 330a_heat = bigdog heater output, 0-100, percent. 330a_range = bigdog heater range 0,1,2,3 for off, low, med, high. 330a_tune = bigdog tune mode 0=manual, 1=P, 2=PI, 3=PID 330a_p = bigdog P value 330a_i = bigdog I value 330a_d = bigdog D value tc330b - guidedog's temperature controller: 330b_cdat = guidedog control temperature, kelvin 330b_sdat = guidedog sample temperature, kelvin 330b_setpt = guidedog control set point, kelvin 330b_heat = guidedog heater output, 0-100, percent. 330b_range = guidedog heater range 0,1,2,3 for off, low, med, high. 330b_tune = guidedog tune mode 0=manual, 1=P, 2=PI, 3=PID 330b_p = guidedog P value 330b_i = guidedog I value 330b_d = guidedog D value tc208 - 8 channels of temperature data: 208_ch1 = spex dewar temperature channel 1, kelvin 208_ch2 = spex dewar temperature channel 2, kelvin 208_ch3 = spex dewar temperature channel 3, kelvin 208_ch4 = spex dewar temperature channel 4, kelvin 208_ch5 = spex dewar temperature channel 5, kelvin 208_ch6 = spex dewar temperature channel 6, kelvin 208_ch7 = spex dewar temperature channel 7, kelvin 208_ch8 = spex dewar temperature channel 8, kelvin# table for Sensors: CREATE TABLE Sensors ( SensorID varchar(10), # sensor Identification Notes varchar(250), # comments, descriptions, etc. PRIMARY KEY ( SensorID ) );
4. spex temperature tables
Spex saves it data using an Timestamp, SensorID, and Data record. Similar to IQUP databases. For spex's temperature we established the following SensorID:
tc330a - bigdog's temperature controller: 330a_cdat = bigdog control temperature, kelvin 330a_sdat = bigdog sample temperature, kelvin 330a_setpt = bigdog control set point, kelvin 330a_heat = bigdog heater output, 0-100, percent. 330a_range = bigdog heater range 0,1,2,3 for off, low, med, high. 330a_tune = bigdog tune mode 0=manual, 1=P, 2=PI, 3=PID 330a_p = bigdog P value 330a_i = bigdog I value 330a_d = bigdog D value tc330b - guidedog's temperature controller: 330b_cdat = guidedog control temperature, kelvin 330b_sdat = guidedog sample temperature, kelvin 330b_setpt = guidedog control set point, kelvin 330b_heat = guidedog heater output, 0-100, percent. 330b_range = guidedog heater range 0,1,2,3 for off, low, med, high. 330b_tune = guidedog tune mode 0=manual, 1=P, 2=PI, 3=PID 330b_p = guidedog P value 330b_i = guidedog I value 330b_d = guidedog D value tc208 - 8 channels of temperature data: 208_ch1 = spex dewar temperature channel 1, kelvin 208_ch2 = spex dewar temperature channel 2, kelvin 208_ch3 = spex dewar temperature channel 3, kelvin 208_ch4 = spex dewar temperature channel 4, kelvin 208_ch5 = spex dewar temperature channel 5, kelvin 208_ch6 = spex dewar temperature channel 6, kelvin 208_ch7 = spex dewar temperature channel 7, kelvin 208_ch8 = spex dewar temperature channel 8, kelvinThere how to add the records to the Sensor's ID.
INSERT INTO Sensors VALUES ('330a_cdat', 'bigdog control temperature, kelvin'); INSERT INTO Sensors VALUES ('330a_sdat', 'bigdog sample temperature, kelvin'); INSERT INTO Sensors VALUES ('330a_setpt', 'bigdog control set point, kelvin'); INSERT INTO Sensors VALUES ('330a_heat', 'bigdog heater output, 0-100, percent.'); INSERT INTO Sensors VALUES ('330a_range', 'bigdog heater range 0,1,2,3 for off, low, med, high.'); INSERT INTO Sensors VALUES ('330a_tune', 'bigdog tune mode 0=manual, 1=P, 2=PI, 3=PID'); INSERT INTO Sensors VALUES ('330a_p', 'bigdog P value'); INSERT INTO Sensors VALUES ('330a_i', 'bigdog I value'); INSERT INTO Sensors VALUES ('330a_d', 'bigdog D value'); INSERT INTO Sensors VALUES ('330b_cdat', 'guidedog control temperature, kelvin'); INSERT INTO Sensors VALUES ('330b_sdat', 'guidedog sample temperature, kelvin'); INSERT INTO Sensors VALUES ('330b_setpt', 'guidedog control set point, kelvin'); INSERT INTO Sensors VALUES ('330b_heater', 'guidedog heater output, 0-100, percent.'); INSERT INTO Sensors VALUES ('330b_range', 'guidedog heater range 0,1,2,3 for off, low, med, high.'); INSERT INTO Sensors VALUES ('330b_tune', 'guidedog tune mode 0=manual, 1=P, 2=PI, 3=PID'); INSERT INTO Sensors VALUES ('330b_p', 'guidedog P value'); INSERT INTO Sensors VALUES ('330b_i', 'guidedog I value'); INSERT INTO Sensors VALUES ('330b_d', 'guidedog D value'); INSERT INTO Sensors VALUES ('208_ch1', 'spex dewar temperature channel 1, kelvin'); INSERT INTO Sensors VALUES ('208_ch2', 'spex dewar temperature channel 2, kelvin'); INSERT INTO Sensors VALUES ('208_ch3', 'spex dewar temperature channel 3, kelvin'); INSERT INTO Sensors VALUES ('208_ch4', 'spex dewar temperature channel 4, kelvin'); INSERT INTO Sensors VALUES ('208_ch5', 'spex dewar temperature channel 5, kelvin'); INSERT INTO Sensors VALUES ('208_ch6', 'spex dewar temperature channel 6, kelvin'); INSERT INTO Sensors VALUES ('208_ch7', 'spex dewar temperature channel 7, kelvin'); INSERT INTO Sensors VALUES ('208_ch8', 'spex dewar temperature channel 8, kelvin');5. Adding Data, Quering Data
Shell (sh) scripts are used to add records and query data from the mysql database. The following scripts illustrate how to perform these functions. (NOTE: replace password with 'XXXXX' , and append '.txt' to file so that it can be viewed in your browser.)
mysql_query.sh.txt
mysql_tc208_insert.sh.txt
mysql_tc330_insert.sh.txt
6. Doing your own query
The following command will query the Data table for 1 hour of data on 11/6/2009:: You can also use the '-s' option when you sign on to mysql to NOT display the data in its default tabular format:
mysql -h irtfweb -u spex -p SHOW DATABASES; USE spex; SHOW TABLES; SELECT Timestamp, FROM_UNIXTIME(Timestamp) AS Date, GROUP_CONCAT(SensorData ORDER BY SensorID SEPARATOR ' ') AS SensorData FROM Data WHERE (Timestamp > UNIX_TIMESTAMP('2009-11-06 00:00:00')) AND (Timestamp < UNIX_TIMESTAMP('2009-11-06 01:00:00')) AND SensorID LIKE 'spex%' GROUP BY Timestamp DESC;To query all the data, you can leave out the WHERE Timestamp... options: Below is an example: example.html