-
http://i1231.photobucket.com/albums/...0Server/40.png
<Hình 40>
Lần lượt chèn các Oject để hiển thị cho 2 Tag còn lại và thiết lập một số các thuộc tính hiển thị khác.
1.3 Tạo bảng dữ liệu
Mở chương trình SQL Server tạo thêm bảng dữ liệu trong Database “AutoBaseVina” như hình sau:
http://i1231.photobucket.com/albums/...0Server/41.png
<Hình 41>
http://i1231.photobucket.com/albums/...0Server/42.png
<Hình 42>
Taoj bảng dữ liệu có 4 cột:
“Date_Time” lưu thời gian lúc dữ liệu được ghi kiểu dữ liệu là datetime
“Temp1” Lưu giá trị của Tag “temperature1” kiểu dữ liệu là float
“Temp2” Lưu giá trị của Tag “temperature2” kiểu dữ liệu là float
“Temp3” Lưu giá trị của Tag “temperature3” kiểu dữ liệu là float
http://i1231.photobucket.com/albums/...0Server/43.png
<Hình 43>
Bảng dữ liệu đã được tạo ra đã xong.
-
http://i1231.photobucket.com/albums/...0Server/44.png
<Hình 44>
1.4 Tạo Script để lưu dữ liệu tự động.
Để viết script ta làm như sau:
http://i1231.photobucket.com/albums/...0Server/45.png
<Hình 45>
http://i1231.photobucket.com/albums/...0Server/46.png
<hình 46>
http://i1231.photobucket.com/albums/...0Server/47.png
<Hình 47>
//-------thay đổi giá trị của 3Tag Memory----
$temperature1= @rand();
$temperature2= @rand();
$temperature3= @rand();
if ($AutoSave == 1)
{
//-------Lấy thời gian của hệ thống----------------
y = @GetDateYear();
mon = @GetDateMon();
d = @GetDateDay();
h = @GetTimeHour();
m = @GetTimeMin();
s = @GetTimeSec();
@sprintf(buf,"%02d/%02d/%04d %02d:%02d:%02d",mon,d,y,h,m,s);
@sprintf(query,"INSERT INTO Temp_Table (Date_Time,Temp1,Temp2,Temp3) VALUES('%s',%08d,%08d,%08d)",buf,$temperature1,$te mperature2,$temperature3);
@DbCommand("SQL_connect", query);
}
-
http://i1231.photobucket.com/albums/...erver/48-1.png
<Hình 48>
Sau đó nhấn nút “Close” để thoát và nhấn nút ON trên màn hình để ghi dữ liệu, mở bảng dữ liệu để xem kết quả.
Kết quả Video:
http://www.youtube.com/watch?v=XjeRTmGoYAI
-
thanks bác nhé! tài liệu khá hay!