• No results found

Collecting data example

N/A
N/A
Protected

Academic year: 2022

Share "Collecting data example"

Copied!
5
0
0

Loading.... (view fulltext now)

Full text

(1)

Collecting data example

Form and Database combination is used to store the data of measurements in a Database,

"collectingdata.db". We place the data in a database through the form, then read the data from the database and plot graphs of this data and sort them into groups. Time taken from the last sample is then transformed into a decimal number of hours and used as the x-axis values for the graphs.

set pos

c

l11 , 150 , 30

d

l21:= label

c

w , "Unit"

d

set pos

c

l21 , 150 , 80

d

set size

c

li21 , 65 , 22

d

set pos

c

li1 , 20 , 50

d

// data type li2:= line text box

c

w , ""

d

l1:= label

c

w , "Select Equipment"

d

set size

c

li2 , 65 , 22

d

set pos

c

l2 , 20 , 80

d

w:= widget

c

0 , "Collecting data"

d

set size

c

w , 290 , 340

d

base:= "collectingbase.db"

// unit li21:= line text box

c

w , ""

d

set pos

c

li21 , 150 , 100

d

set pos

c

l1 , 20 , 30

d

l2:= label

c

w , "Data Type"

d

set pos

c

li2 , 20 , 100

d

t:=

names "Group 1"

"Group 2"

"Group 3"

// equipment li1:= combo box

c

w , tt

d

set pos

c

li11 , 150 , 50

d

l11:= label

c

w , "Select Group"

d

// group li11:= combo box

c

w , t

d

set size

c

li11 , 70 , 22

d

tt:=

names "Equipment 1"

"Equipment 2"

"Equipment 3"

Creates Select Equipment label and appropriate combo box

Set positions for label and combo box

Creates Select Group label and appropriate combo box

Set positions and size for label and combo box

Data for Select equipment and group

combo boxes Creates widget and set

his size Name of database file

we are working with

Creates Data Type label and appropriate line text box Set positions and size for

label and line text box

Creates Unit label and appropriate line text box Set positions and size for

label and line text box

www.labdeck.com

(2)

set pos

c

b , 110 , 300

d

set pos

c

l4 , 20 , 30

d

set pos

c

l5 , 20 , 80

d

set pos

c

g1 , 20 , 140

d

set size

c

g1 , 250 , 150

d

set pos

c

li5 , 20 , 100

d

set size

c

li5 , 80 , 22

d

b:= button

c

w , "Submit"

d

//data li5:= line text box

c

g1 , ""

d

l4:= label

c

g1 , "Time from last sample (hh:mm)"

d

set pos

c

li4 , 20 , 50

d

set size

c

li4 , 80 , 22

d

l5:= label

c

g1 , "Data"

d

// time li4:= line text box

c

g1 , ""

d

g1:= group box

c

w , "Data"

d

Creates group, name it Data and set positions and size for

group

Creates label and appropriate line text box Set positions and size for

label and line text box

Creates label Data and appropriate line text box Set positions and size for

label and line text box

Creates Submit button and set his position

query1:= "CREATE TABLE 'data table1' (id integer primary key, equipment TEXT, dgroup TEXT, "

query1+= "data_type TEXT, unit TEXT, time TEXT, data TEXT)"

database query

c

base , query1

d

on event

c

b , onSubmit

c d d

Creates query string that will be executed in function database query

If table exist do nothing, if it does't create table

"data table1" with appropriate columns

Execute query that we have created above, first argument is database name, second is query

Define what to do on Submit button press, b - button variable created earlier, onSubmit() - custom function defined in

following canvas

(3)

onSubmit

c d

{

}

q1 := "INSERT INTO 'data table1' (equipment, dgroup, data_type, unit, time, data) VALUES ("

q1 += "'" + widget value

c

li1 + "'" + ", '" + widget value

d c

li11 + "', '" + widget value

d c

li2

d

q1 += "', '" + widget value

c

li21 + "', '" + widget value

d c

li4 + "', '" + widget value

d c

li5 + "')"

d

database query

c

base , q1

d

set tooltip

c

li2 , widget value

c

li2

d d

set tooltip

c

li4 , widget value

c

li4

d d

set tooltip

c

li5 , widget value

c

li5

d d

set tooltip

c

li21 , widget value

c

li21

d d

set widget value

c

li2 , ""

d

set widget value

c

li4 , ""

d

set widget value

c

li5 , ""

d

set widget value

c

li21 , ""

d

1 2 3 4 5 6 7 8 9 10 11 12

Above is function that triggers at Submit button press

q1 - query string created to save form data into the "data table1" table of database set tooltip - creates tooltip with data from last submit for each text box

set widget - deletes line text boxes values and set them to blank ("")

After submitting of values, a tooltip is created for each text box containing last submitted value for that text box.

(4)

xdata1:= timeToDec

c

time1

d

gdata1:= join mat cols

c

xdata1 , data1

d

data2:= database query

c

base , "SELECT data FROM 'data table1' WHERE dgroup = 'Group 2'"

d

time1:= database query

c

base , "SELECT time FROM 'data table1' WHERE dgroup = 'Group 1'"

d

gdata3:= join mat cols

c

xdata3 , data3

d

data1:= database query

c

base , "SELECT data FROM 'data table1' WHERE dgroup = 'Group 1'"

d

time2:= database query

c

base , "SELECT time FROM 'data table1' WHERE dgroup = 'Group 2'"

d

xdata2:= timeToDec

c

time2

d

gdata2:= join mat cols

c

xdata2 , data2

d

timeToDec

c

dataVec

d

{

}

rez:= vector create

c

size

c

dataVec

d

, false , 0

d

for

c

i:= 1 , i< size

c

dataVec

d

, i+= 1

d

{

}

pom:= dataVec[ ] i

h:= to number

c

split

c

pom , ":"

d

[ ] 0

d

n:= to number

c

split

c

pom , ":"

d

[ ] 1

d

[ ]

rez i = rez[ i- 1 ] + ( h 60 + n) / 60 1

2 3 4

return

c

rez

d

1

2

3

data3:= database query

c

base , "SELECT data FROM 'data table1' WHERE dgroup = 'Group 3'"

d

time3:= database query

c

base , "SELECT time FROM 'data table1' WHERE dgroup = 'Group 3'"

d

Read data for graphs y-axis from database and store them in variables

Read data for graphs x-axis from database and store them in variables

Function that transform 'Time from last sample' value,to decimal number of

hours format

xdata3:= timeToDec

c

time3

d

Transform data that we have read from database using

timeToDec() function

Join x-axis and y-axis data for graphs into the matrices

(5)

We plotted graphs that represents dependence of measurement data and time of measurement. Every group of measurements have it's own graph.

References

Related documents

En efecto, así como los libertarianos ven en cual- quier forma de intervención del Estado una fuente inevitable de interferencias arbitrarias –con la excepción de aquella acción

It was decided to intimate/inform students about “Know about healthcare services &amp; Health Insurance at Symbiosis” about process of health Insurance during:

Initially, I had difficulty understanding how it was that students were integrating the various disciplinary perspectives in their pursuit of the question, “What does it mean to

The profit per ha of potato if sold at Wukro market is Birr 15344 and if the product is sold at. Mekelle the profit will be

With the number of disciplinary actions rising by four-fold in the last three years, the current version of the Korean Code of Ethics for Attorneys is certainly a step in

Including, inter alia , financial statements prepared in accordance with national and international accounting principles, all types of special audits.

In recent years, there is a rapid increase in the use of functionally graded (FG) sandwich struc- tures in aerospace, marine and civil engineering due to high strength-to-weight

Funding: Black Butte Ranch pays full coost of the vanpool and hired VPSI to provide operation and administra- tive support.. VPSI provided (and continues to provide) the