當前位置:首頁 » 數據倉庫 » 資料庫採集串口數據
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

資料庫採集串口數據

發布時間: 2022-08-21 15:51:23

⑴ 如何 用資料庫保存串口採集到的數據

假設你有表test={ID,數值} 假設你已經連接上了資料庫,你的連接對象為cnn 假設你的數組為arrlngData(),裡面存了數據 8,寫入資料庫 dim i as long dim strsql as string dim rst as objec...

⑵ VB2010中如何將串口採集的數據存入到資料庫中,並用資料庫中數據畫實時曲線和歷史曲線

使用串口控制項獲取數據流並存入字元串變數中。
按照預先制定的數據規則解析獲取到的數據流,爾後通過SQL語句存入資料庫。
而至於曲線圖的作法,則是通過SQL語句取出結果集,然後通過VB的CHART控制項作出。相關的設置請自己查閱文檔。

⑶ 串口數據採集程序

直接上參考程序:

DimavAsVariant
DimdatacountAsLong

PrivateSubcmdClear_Click()
txtData.Text=""
EndSub

PrivateSubcmdStop_Click()

'關閉埠
IfMSComm.PortOpen=TrueThen
MSComm.InBufferCount=0'清空緩沖區
MSComm.PortOpen=False
EndIf

cmdReceive.Enabled=True
lblStatus.Caption="停止接收,空閑"

EndSub

PrivateSubcmdReceive_Click()

'串口設置
WithMSComm
.CommPort=1
.Settings="9600,N,8,1"
.RThreshold=1'接收1位元組觸發oncomm事件
.InputMode=comInputModeBinary
.InputLen=1'輸入長度為1
.InBufferCount=0'清除接收緩沖區
EndWith

'打開埠
IfMSComm.PortOpen=FalseThen
MSComm.PortOpen=True
IfErrThen
MsgBox(Err.Description)
ExitSub
EndIf
EndIf

lblStatus.Caption="打開埠,等待接收"
datacount=0
cmdReceive.Enabled=False
EndSub

PrivateSubcmdSave_Click()

DimoutfnAsString

MsgBox("接收了"+CStr(datacount)+"組數據")
lblStatus.Caption="接收完成,請選擇輸出文件"

cmdReceive.Enabled=True

'選擇輸出文件
CommonDialog1.FileName=CStr(Date)+".txt"
CommonDialog1.Filter="TextFiles|*.txt"
CommonDialog1.Flags=CommonDialog1.FlagsOrcdlOFNOverwritePrompt
CommonDialog1.CancelError=True
OnErrorGoToerrhandler
CommonDialog1.ShowSave
outfn=CommonDialog1.FileName

OpenoutfnForOutputAs#1
Print#1,txtData.Text
Close#1

'txtData.SaveFileoutfn
lblStatus.Caption="輸出完成,空閑"

errhandler:
ExitSub
EndSub

PrivateSubForm_Load()
lblStatus.Caption="空閑"
EndSub

PrivateSubForm_Unload(CancelAsInteger)

'關閉埠
IfMSComm.PortOpen=TrueThen
MSComm.InBufferCount=0'清空緩沖區
MSComm.PortOpen=False
EndIf

EndSub

PrivateSubMSComm_OnComm()
DimT1,T2AsLong
SelectCaseMSComm.CommEvent

CasecomEvReceive'收到Rthreshold個位元組產生的接收事件

MSComm.RThreshold=0'關閉OnComm事件接收

lblStatus.Caption="接收"
av=MSComm.Input'讀取一個接收位元組
dataframe(1)=av(0)'轉換為位元組

Ifdataframe(1)=&HAThen'接收到T1

Do
DoEvents
LoopUntilMSComm.InBufferCount>=2'循環等待接收緩沖區>=2個位元組

av=MSComm.Input
dataframe(2)=av(0)
av=MSComm.Input
dataframe(3)=av(0)'接收T1
T1=dataframe(2)+CLng(dataframe(3))*256'計算T1
EndIf

Do
DoEvents
LoopUntilMSComm.InBufferCount>=1'循環等待接收緩沖區>=1個位元組

av=MSComm.Input'讀取一個接收位元組
dataframe(4)=av(0)'轉換為位元組

'接收到T2
Ifdataframe(4)=&HA0Then
'MSComm.RThreshold=0'關閉OnComm事件接收

'循環等待接收緩沖區>=2個位元組
Do
DoEvents
LoopUntilMSComm.InBufferCount>=2

av=MSComm.Input
dataframe(5)=av(0)
av=MSComm.Input
dataframe(6)=av(0)'接收T2
T2=dataframe(5)+CLng(dataframe(6))*256'計算T2

'顯示T1T2enter
txtData.Text=txtData.Text+CStr(T1)+""+CStr(T2)+Chr(&HD)+Chr(&HA)

datacount=datacount+1'數據組數+1
EndIf

MSComm.RThreshold=1'打開OnComm事件接收

CaseElse

EndSelect

EndSub
  1. RS232串列通信的波特率設為9600,8位數據位,一位停止位,無校驗位。

    2. 每組數據包含T1(16位)和T2(16位),將每個數據分成2個8位的數據,先是低8位,然後是高8位。數據為無符號整型。

    先發T1,然後發T2,然後是下一組T1、T2。
    T1以頭數據0x0A(16進制,10進制位10)為頭位元組,然後是T1的低8位,T1的高8位。
    T2以頭數據0xA0(16進制,10進制位160)為頭位元組,然後是T2的低8位,T2的高8位。
    發送時序舉例:0x0A, t1低8位,t1高8位,0xA0, t2低8位,t2高8位……
    將收到的數據T1、T2的高低8位合並,轉換成10進制數,以每行T1 T2的形式存儲到txt文本文件中

如果需要 做其他『文件格式的處理, 數據已經拿到了,想怎麼弄就變通下吧。

⑷ 怎麼從串口讀取數據到資料庫呢

用C#編程,很方便。串口收發用System.IO.SerialPort組件,收到數據,解析出來需要的數,再操作資料庫就可以了。

⑸ 怎麼將虛擬串口的數據採集到資料庫裡面呢

寫成SELECT* FROM t WHERE object_id = decode(:OID,null,object_id,:OID) ;計劃與NVL的一樣(略)。現在的計劃,ORACLE實際是轉換成兩條語句,然後進行類似於UNION ALL的操作。注意看計劃中的FILTER操作,FILTER操作的子操作,如果是單個子操作,那麼就會先執行FILTER(父操作),滿足FILTER條件的,則執行子操作,否則不執行子操作(如果FILTER有2個子操作,則類似於NESTED LOOPS的操作)。看ID=2的FILTER條件是:OID IS NULL,ID=4的FILTER操作:OID IS NOT NULL,他們兩個完全是互斥條件,所以,對於傳入的:OID,肯定只能執行一個分支:要麼執行全表掃描(傳入NULL),要麼執行索引掃描(傳入非NULL值)。這也就實現了前面說的IF .... ELSE ....END IF的操作。

⑹ 利用ASP.net怎樣實現對串口數據的採集

簡單的說一下吧,爪機打字麻煩。
伺服器端對串口的操作可以用winform來完成也可以寫成一個服務,隨系統啟動而啟動,負責寫數據到資料庫或從響應用戶的命令,
而你說的b/s架構則僅僅提供數據瀏覽與提交命令,回顯命令的執行結果即可

⑺ 如何在web頁面上獲取客戶端的串口數據

web頁面上獲取客戶端的串口數據的方法:

可以寫一個串口代理程序,讀取本地串口,將獲取到的數據存入資料庫。web通過ajax+定時器獲取資料庫中的數據顯示就好了。

如果要交互,可以搞一個讓上面提到的串口程序開一個socket.將串口通信獲取的數據,通過socket發出去,web頁面可以用websocket。

下面一個通過flash操作ardiuno的demo.用的是類似於第二種交互的方法。只不過用的是ActionScript.原理是一樣的。

串列介面是一種可以將接收來自CPU的並行數據字元轉換為連續的串列數據流發送出去,同時可將接收的串列數據流轉換為並行的數據字元供給CPU的器件。一般完成這種功能的電路,我們稱為串列介面電路。

串口通信(Serial Communications)的概念非常簡單,串口按位(bit)發送和接收位元組的通信方式。

注意事項:

戶端的系統數據如果能隨便被web頁面讀取,那大家也不敢隨便打開網頁了,至於說用IE的ActiveX 控制項,這個也沒有前途,IE默認不開啟,現在有IE的也沒什麼人,當然如果是用於特定客戶的話可以了,反正你想幹嘛就幹嘛。



⑻ VB 串口數據採集

實時採集的數據可直接用來畫曲線,但往往為了以後查詢,同時應按定時間隔寫入資料庫或文本文件。所以可在寫入資料庫後通過查詢做到實時顯示和更新。
'窗體載入時將已記錄的數據查詢後繪圖
Private Sub Form_Load()
chaxun1 = "select * from jishijilu where gyh_riqi='" & gongyi_sj(0) & "-" & record_rq & "'order by shijian "
mdh = chaxun1
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Ldgz\wd.mdb;Persist Security Info=False"
Adodc3.RecordSource = mdh
Adodc3.Refresh
zslNew = Adodc3.Recordset.RecordCount
Text4 = zslNew
If zslNew >= 1 Then
Adodc3.Recordset.MoveFirst
For i = 0 To zslNew - 1
quexian(0, i) = Adodc3.Recordset(0)
For j = 2 To 9
quexian(j, i) = Adodc3.Recordset(j)
Next j
Adodc3.Recordset.MoveNext
Next i
Adodc3.Recordset.MoveFirst
For j = 0 To zslNew - 1
Picture1.Line (j * 5 + 500, quexian(2, j) * -30 + 3399)-(j * 5 + 500, quexian(2, j) * -30 + 3401), vbRed, BF
Picture1.Line (j * 5 + 500, quexian(3, j) * -30 + 3399)-(j * 5 + 500, quexian(3, j) * -30 + 3401), QBColor(7), BF
Picture1.Line (j * 5 + 500, quexian(4, j) * -30 + 3399)-(j * 5 + 500, quexian(4, j) * -30 + 3401), vbWhite, BF
Picture1.Line (j * 5 + 500, quexian(5, j) * -30 + 3399)-(j * 5 + 500, quexian(5, j) * -30 + 3401), vbYellow, BF
Picture1.Line (j * 5 + 500, quexian(6, j) * -30 + 3399)-(j * 5 + 500, quexian(6, j) * -30 + 3401), vbGreen, BF
If quexian(8, j) < 1 Then
wy_wy = 0 + 166.7
br_br = 55
ElseIf quexian(8, j) >= 1 And quexian(8, j) < 10 Then
wy_wy = -1500 + 166.7
br_br = 5.5556
ElseIf quexian(8, j) >= 10 And quexian(8, j) < 100 Then
wy_wy = -3000 + 166.7
br_br = 0.5555
ElseIf quexian(8, j) >= 100 And quexian(8, j) < 1000 Then
wy_wy = -4500 + 166.7
br_br = 0.055555
End If
Picture1.Line (j * 5 + 500, quexian(8, j) * br_br * -30 + wy_wy + 3397 + 3000)-(j * 5 + 500, quexian(8, j) * br_br * -30 + wy_wy + 3403 + 3000), QBColor(11), BF
Next j
zslOld = zslNew
End If
'記錄時間最長75小時
Picture2.Height = 10000
Picture2.Visible = True
Picture1.Visible = True
colvb = vbWhite
xx = 100
yy = 150
txt = "℃"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "100"
wp = xp(colvb, xx, yy, txt)
xx = 200
yy = 1850
txt = "50"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 300
txt = "0"
wp = xp(colvb, xx, yy, txt)
xx = 100
yy = 4850
txt = "-50"
wp = xp(colvb, xx, yy, txt)
xx = 0
yy = 6350
txt = "-100"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 100
yy = 150
txt = "℃"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "100"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 200
yy = 1850
txt = "50"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 10800 + 300
txt = "0"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 100
yy = 4850
txt = "-50"
wp = xp(colvb, xx, yy, txt)
xx = 10800 + 0
yy = 6350
txt = "-100"
wp = xp(colvb, xx, yy, txt)
'真空坐標

colvb = vbRed
xx = 11400
yy = 150
txt = "Pa"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "1000"
wp = xp(colvb, xx, yy, txt)
xx = 11500
yy = 1850
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 11600
txt = "10"
wp = xp(colvb, xx, yy, txt)
xx = 11700
yy = 4850
txt = "1"
wp = xp(colvb, xx, yy, txt)
xx = 11500
yy = 6350
txt = "0.1"
wp = xp(colvb, xx, yy, txt)

xx = 500
yy = 150
txt = "Pa"
wp = xp(colvb, xx, yy, txt)
yy = 350
txt = "1000"
wp = xp(colvb, xx, yy, txt)
yy = 150
xx = 2200
txt = "6hr"
wp = xp(colvb, xx, yy, txt)
xx = 4000
txt = "12hr"
wp = xp(colvb, xx, yy, txt)
xx = 5800
txt = "18hr"
wp = xp(colvb, xx, yy, txt)
xx = 7600
txt = "24hr"
wp = xp(colvb, xx, yy, txt)
xx = 9400
txt = "30hr"
wp = xp(colvb, xx, yy, txt)
xx = 13000
txt = "42hr"
wp = xp(colvb, xx, yy, txt)
xx = 14800
txt = "48hr"
wp = xp(colvb, xx, yy, txt)
xx = 16600
txt = "54hr"
wp = xp(colvb, xx, yy, txt)
xx = 18400
txt = "60hr"
wp = xp(colvb, xx, yy, txt)
xx = 20200
txt = "66hr"
wp = xp(colvb, xx, yy, txt)
xx = 22000
txt = "72hr"
wp = xp(colvb, xx, yy, txt)
xx = 23800
txt = "78hr"
wp = xp(colvb, xx, yy, txt)
xx = 25600
txt = "84hr"
wp = xp(colvb, xx, yy, txt)
xx = 27400
txt = "90hr"
wp = xp(colvb, xx, yy, txt)
xx = 29200
txt = "96hr"
wp = xp(colvb, xx, yy, txt)
xx = 600
yy = 1850
txt = "100"
wp = xp(colvb, xx, yy, txt)
yy = 3350
xx = 11600
txt = "10"
wp = xp(colvb, xx, yy, txt)
xx = 700
yy = 4850
txt = "1"
wp = xp(colvb, xx, yy, txt)
xx = 600
yy = 6350
txt = "0.1"
wp = xp(colvb, xx, yy, txt)
xx = 22100
yy = 350
txt = "1000"
wp = xp(colvb, xx, yy, txt)
yy = 1850
txt = " 100"
wp = xp(colvb, xx, yy, txt)
yy = 3350
txt = " 10"
wp = xp(colvb, xx, yy, txt)
yy = 4850
txt = " 1"
wp = xp(colvb, xx, yy, txt)
yy = 6350
txt = " 0.1"
wp = xp(colvb, xx, yy, txt)
'畫格

Picture1.ForeColor = vbWhite
Picture1.Line (450, 700)-(500, 700)
Picture1.Line (450, 1000)-(500, 1000)
Picture1.Line (450, 1300)-(500, 1300)
Picture1.Line (450, 1600)-(500, 1600)
Picture1.ForeColor = vbRed

Picture1.Line (500, 566.7)-(550, 566.7)
Picture1.Line (500, 733.3)-(550, 733.3)
Picture1.Line (500, 900)-(550, 900)
Picture1.Line (500, 1066.7)-(550, 1066.7)
Picture1.Line (500, 1233.3)-(550, 1233.3)
Picture1.Line (500, 1400)-(550, 1400)
Picture1.Line (500, 1566.7)-(550, 1566.7)
Picture1.Line (500, 1733.3)-(550, 1733.3)
Picture1.Line (500, 2066.7)-(550, 2066.7)
Picture1.Line (500, 2233.3)-(550, 2233.3)
Picture1.Line (500, 2400)-(550, 2400)
Picture1.Line (500, 2566.7)-(550, 2566.7)
Picture1.Line (500, 2733.3)-(550, 2733.3)
Picture1.Line (500, 2900)-(550, 2900)
Picture1.Line (500, 3066.7)-(550, 3066.7)
Picture1.Line (500, 3233.3)-(550, 3233.3)
Picture1.Line (500, 3566.7)-(550, 3566.7)
Picture1.Line (500, 3733.3)-(550, 3733.3)
Picture1.Line (500, 3900)-(550, 3900)
Picture1.Line (500, 4066.7)-(550, 4066.7)
Picture1.Line (500, 4233.3)-(550, 4233.3)
Picture1.Line (500, 4400)-(550, 4400)
Picture1.Line (500, 4566.7)-(550, 4566.7)
Picture1.Line (500, 4733.3)-(550, 4733.3)
Picture1.Line (500, 5066.7)-(550, 5066.7)
Picture1.Line (500, 5233.3)-(550, 5233.3)
Picture1.Line (500, 5400)-(550, 5400)
Picture1.Line (500, 5566.7)-(550, 5566.7)
Picture1.Line (500, 5733.3)-(550, 5733.3)
Picture1.Line (500, 5900)-(550, 5900)
Picture1.Line (500, 6066.7)-(550, 6066.7)
Picture1.Line (500, 6233.3)-(550, 6233.3)
Picture1.ForeColor = vbWhite
Picture1.Line (450, 400)-(27500, 400)
Picture1.Line (450, 1900)-(27500, 1900)
Picture1.Line (450, 3400)-(27500, 3400)
Picture1.Line (450, 4900)-(27500, 4900)
Picture1.Line (450, 6400)-(27500, 6400)
Picture1.Line (450, 2200)-(500, 2200)
Picture1.Line (450, 2500)-(500, 2500)
Picture1.Line (450, 2800)-(500, 2800)
Picture1.Line (450, 3100)-(500, 3100)
Picture1.Line (450, 3700)-(500, 3700)
Picture1.Line (450, 4000)-(500, 4000)
Picture1.Line (450, 4300)-(500, 4300)
Picture1.Line (450, 4600)-(500, 4600)
Picture1.Line (450, 5200)-(500, 5200)
Picture1.Line (450, 5500)-(500, 5500)
Picture1.Line (450, 5800)-(500, 5800)
Picture1.Line (450, 6100)-(500, 6100)
Picture1.Line (500, 400)-(500, 6400)
Picture1.Line (500 + 0, 400)-(500 + 0, 6400)
Picture1.Line (1400 + 0, 400)-(1400 + 0, 6400)
Picture1.Line (2300 + 0, 400)-(2300 + 0, 6400)
Picture1.Line (3200 + 0, 400)-(3200 + 0, 6400)
Picture1.Line (4100 + 0, 400)-(4100 + 0, 6400)
Picture1.Line (5000 + 0, 400)-(5000 + 0, 6400)
Picture1.Line (5900 + 0, 400)-(5900 + 0, 6400)
Picture1.Line (6800 + 0, 400)-(6800 + 0, 6400)
Picture1.Line (7700 + 0, 400)-(7700 + 0, 6400)
Picture1.Line (8600 + 0, 400)-(8600 + 0, 6400)
Picture1.Line (9500 + 0, 400)-(9500 + 0, 6400)
Picture1.Line (10400 + 0, 400)-(10400 + 0, 6400)
Picture1.Line (11300, 400)-(11300, 6400)
Picture1.Line (12200, 400)-(12200, 6400)
Picture1.Line (13100, 400)-(13100, 6400)
Picture1.Line (14000, 400)-(14000, 6400)
Picture1.Line (14900, 400)-(14900, 6400)
Picture1.Line (15800, 400)-(15800, 6400)
Picture1.Line (16700, 400)-(16700, 6400)
Picture1.Line (17600, 400)-(17600, 6400)
Picture1.Line (18500, 400)-(18500, 6400)
Picture1.Line (19400, 400)-(19400, 6400)
Picture1.Line (20300, 400)-(20300, 6400)
Picture1.Line (21200, 400)-(21200, 6400)
Picture1.Line (22100, 400)-(22100, 6400)
Picture1.Line (23000, 400)-(23000, 6400)
Picture1.Line (23900, 400)-(23900, 6400)
Picture1.Line (24800, 400)-(24800, 6400)
Picture1.Line (25700, 400)-(25700, 6400)
Picture1.Line (26600, 400)-(26600, 6400)
Picture1.Line (27500, 400)-(27500, 6400)
Picture1.Line (0 * 5 + 500, 3400 - b(0) * 30)-(c(1) * 5 + 500, 3400 - b(0) * 30), QBColor(12)
Picture1.Line (c(1) * 5 + 498, 3400 - b(1) * 30)-(c(2) * 5 + 502, 3400 - b(1) * 30), QBColor(12)
Picture1.Line (c(2) * 5 + 498, 3400 - b(2) * 30)-(c(3) * 5 + 502, 3400 - b(2) * 30), QBColor(12)
Picture1.Line (c(3) * 5 + 498, 3400 - b(3) * 30)-(c(4) * 5 + 502, 3400 - b(3) * 30), QBColor(12)
Picture1.Line (c(4) * 5 + 498, 3400 - b(4) * 30)-(c(5) * 5 + 502, 3400 - b(4) * 30), QBColor(12)
Picture1.Line (c(5) * 5 + 498, 3400 - b(5) * 30)-(c(6) * 5 + 502, 3400 - b(5) * 30), QBColor(12)
Picture1.Line (c(6) * 5 + 498, 3400 - b(6) * 30)-(c(7) * 5 + 502, 3400 - b(6) * 30), QBColor(12)
Picture1.Line (c(7) * 5 + 498, 3400 - b(7) * 30)-(c(8) * 5 + 502, 3400 - b(7) * 30), QBColor(12)
Picture1.Line (c(8) * 5 + 498, 3400 - b(8) * 30)-(c(9) * 5 + 502, 3400 - b(8) * 30), QBColor(12)
Picture1.Line (c(9) * 5 + 498, 3400 - b(9) * 30)-(c(10) * 5 + 502, 3400 - b(9) * 30), QBColor(12)
Picture1.Line (c(10) * 5 + 498, 3400 - b(10) * 30)-(c(11) * 5 + 502, 3400 - b(10) * 30), QBColor(12)
Picture1.Line (c(11) * 5 + 498, 3400 - b(11) * 30)-(c(12) * 5 + 502, 3400 - b(11) * 30), QBColor(12)
Picture1.Line (c(12) * 5 + 498, 3400 - b(12) * 30)-(c(13) * 5 + 502, 3400 - b(12) * 30), QBColor(12)
Picture1.Line (c(13) * 5 + 498, 3400 - b(13) * 30)-(c(14) * 5 + 502, 3400 - b(13) * 30), QBColor(12)
Picture1.Line (c(14) * 5 + 498, 3400 - b(14) * 30)-(c(15) * 5 + 502, 3400 - b(14) * 30), QBColor(12)
Picture1.Line (c(15) * 5 + 498, 3400 - b(15) * 30)-(c(16) * 5 + 502, 3400 - b(15) * 30), QBColor(12)
chaxun1 = "select * from jishijilu where gyh_riqi='" & gongyi_sj(0) & "-" & record_rq & "'order by shijian "
mdh = chaxun1
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Ldgz\wd.mdb;Persist Security Info=False"
Adodc3.RecordSource = mdh
Adodc3.Refresh
zslNew = Adodc3.Recordset.RecordCount
Text4 = zslNew
If zslNew >= 1 Then
Adodc3.Recordset.MoveFirst
For i = 0 To zslNew - 1
quexian(0, i) = Adodc3.Recordset(0)
For j = 2 To 7
quexian(j, i) = Adodc3.Recordset(j)
Next j
Adodc3.Recordset.MoveNext
Next i
Adodc3.Recordset.MoveFirst
For j = 0 To zslNew - 1
Picture1.Line (j * 5 + 500, quexian(2, j) * -30 + 3399)-(j * 5 + 500, quexian(2, j) * -30 + 3401), vbRed, BF
Picture1.Line (j * 5 + 500, quexian(3, j) * -30 + 3399)-(j * 5 + 500, quexian(3, j) * -30 + 3401), QBColor(7), BF
Picture1.Line (j * 5 + 500, quexian(4, j) * -30 + 3399)-(j * 5 + 500, quexian(4, j) * -30 + 3401), vbWhite, BF
Picture1.Line (j * 5 + 500, quexian(5, j) * -30 + 3399)-(j * 5 + 500, quexian(5, j) * -30 + 3401), vbYellow, BF
Picture1.Line (j * 5 + 500, quexian(6, j) * -30 + 3399)-(j * 5 + 500, quexian(6, j) * -30 + 3401), vbGreen, BF
If quexian(8, j) < 1 Then
wy_wy = 0 + 166.7
br_br = 55
ElseIf quexian(8, j) >= 1 And quexian(8, j) < 10 Then
wy_wy = -1500 + 166.7
br_br = 5.5556
ElseIf quexian(8, j) >= 10 And quexian(8, j) < 100 Then
wy_wy = -3000 + 166.7
br_br = 0.5555
ElseIf quexian(8, j) >= 100 And quexian(8, j) < 1000 Then
wy_wy = -4500 + 166.7
br_br = 0.055555
End If
Picture1.Line (j * 5 + 500, quexian(8, j) * br_br * -30 + wy_wy + 3397 + 3000)-(j * 5 + 500, quexian(8, j) * br_br * -30 + wy_wy + 3403 + 3000), QBColor(11), BF
Next j
zslOld = zslNew
End If
zslOld = zslNew
End Sub
'通過計時器調用定時更新
Private Sub cmdRef_Click()
chaxun1 = "select * from jishijilu where gyh_riqi='" & gongyi_sj(0) & "-" & record_rq & "'order by shijian "
mdh = chaxun1
Adodc3.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Ldgz\wd.mdb;Persist Security Info=False"
Adodc3.RecordSource = mdh
Adodc3.Refresh
zslNew = Adodc3.Recordset.RecordCount
Text4 = zslNew
If zslNew > 1 Then
Adodc3.Recordset.MoveLast
For j = 2 To 7
quexian(j, i) = Adodc3.Recordset(j)
Next j
Picture2.Height = 10000
Picture1.Visible = True
If zslOld >= 1 Then
For j = zslOld - 1 To zslNew - 1
Picture1.Line (j * 5 + 500, quexian(2, j) * -30 + 3399)-(j * 5 + 500, quexian(2, j) * -30 + 3401), vbRed, BF
Picture1.Line (j * 5 + 500, quexian(3, j) * -30 + 3399)-(j * 5 + 500, quexian(3, j) * -30 + 3401), QBColor(7), BF
Picture1.Line (j * 5 + 500, quexian(4, j) * -30 + 3399)-(j * 5 + 500, quexian(4, j) * -30 + 3401), vbWhite, BF
Picture1.Line (j * 5 + 500, quexian(5, j) * -30 + 3399)-(j * 5 + 500, quexian(5, j) * -30 + 3401), vbYellow, BF
Picture1.Line (j * 5 + 500, quexian(6, j) * -30 + 3399)-(j * 5 + 500, quexian(6, j) * -30 + 3401), vbGreen, BF
If quexian(8, j) < 1 Then
wy_wy = 0 + 166.7
br_br = 55
ElseIf quexian(8, j) >= 1 And quexian(8, j) < 10 Then
wy_wy = -1500 + 166.7
br_br = 5.5556
ElseIf quexian(8, j) >= 10 And quexian(8, j) < 100 Then
wy_wy = -3000 + 166.7
br_br = 0.5555
ElseIf quexian(8, j) >= 100 And quexian(8, j) < 1000 Then
wy_wy = -4500 + 166.7
br_br = 0.055555
End If
Picture1.Line (j * 5 + 500, quexian(8, j) * br_br * -30 + wy_wy + 3395 + 3000)-(j * 5 + 500, quexian(8, j) * br_br * -30 + wy_wy + 3405 + 3000), QBColor(11), BF
Next j
End If
'記錄時間最長96小時
cmdPrint.Enabled = True
End If
zslOld = zslNew
End Sub

⑼ 如何採集單片機串口發送過來的數據,怎麼編程實現溫度數據的WEB顯示,數據類型32.1℃,求完整代碼

PC端用 C++/Delphi 之類軟體寫個小程序

一般情況利用串口RS232 與你的硬體通訊讀到溫度值寫入資料庫

建議用Delphi 有現成組件,個把小時就可以搞定

網頁哪塊就是標準的網頁編程了,使用 ASP/PHP/JAVA 都可以

如果你是多個硬體採集點的話,可考慮485匯流排

如果採集點非常分散距離很遠的話,這就需要考慮 RS232轉TCP/IP模塊

硬體都有了? 看起來你對需求根本沒考慮過。
至少:
硬體通訊介面,供電方式
採集點數目
採集點分布
數據組織形式
數據顯示形式
控制要求
要搞清楚

⑽ 如何實現串口數據採集,如何分析這些數據

MSCOMM控制項在VB6的企業版中有,需通過部件添加方式載入。

Private Sub MSComm_OnComm()
Dim bytInput() As Byte
Dim intInputLen As Integer
Select Case frmMain.ctrMSComm.CommEvent
Case comEvReceive
If blnReceiveFlag Then
If Not frmMain.ctrMSComm.PortOpen Then
frmMain.ctrMSComm.CommPort = intPort
frmMain.ctrMSComm.Settings = strSet
frmMain.ctrMSComm.PortOpen = True
End If
'此處添加處理接收的代碼
frmMain.ctrMSComm.InputMode = comInputModeText '按ASCII接收
intInputLen = frmMain.ctrMSComm.InBufferCount
ReDim bytInput(intInputLen)
bytInput = frmMain.ctrMSComm.Input
Text1 = bytInput
Text2 = Text1
jscd = Len(Text1)
If Left(Text1, 1) <> Chr(27) Or jscd > 25 Then '
frmMain.Label3.BackColor = vbRed
frmMain.Label3.ForeColor = vbWhite
frmMain.Label3.Caption = "接收信號出錯!"
ElseIf Left(Text2, 1) = Chr(27) And Mid(Text2, 25, 1) = Chr(13) Then
frmMain.Label3.BackColor = vbGreen
frmMain.Label3.ForeColor = vbBlack
frmMain.Label3.Caption = "接收信號正常!"
If Left(Text2, 6) = Chr(27) & "R0032" And jscd = 25 Then
If Val(fa2) >= 0 And Len(fa2) = 4 Then
fa2 = "0" & Mid(fa2, 2, 3)
End If
frmMain.txtSend = Chr(27) & fa0 & fa1 & "9999" & zhenkong & fa2 & fa3 & fa4 & Chr(13)
lenTxtSend = Len(txtSend)
frmJishi.Label8.Caption = txtSend
frmJishi.Label11.Caption = lenTxtSend
If lenTxtSend = 24 Then
Call commFasong
Else
frmMain.Label3.BackColor = vbRed
frmMain.Label3.ForeColor = vbWhite
frmMain.Label3.Caption = "發送信號出錯!"
End If
blL1 = Mid$(Text2, 19, 2)
If blL1 = "01" Then
record_jmm(0) = Val(Mid$(Text2, 21, 4)) / 10 '製品1溫度
ElseIf blL1 = "02" Then
record_jmm(1) = Val(Mid$(Text2, 21, 4)) / 10 '製品2溫度
ElseIf blL1 = "03" Then
record_jmm(2) = Val(Mid$(Text2, 21, 4)) / 10 '製品3溫度
ElseIf blL1 = "04" Then
record_jmm(3) = Val(Mid$(Text2, 21, 4)) / 10 '製品4溫度
ElseIf blL1 = "05" Then
record_jmm(4) = Val(Mid$(Text2, 21, 4)) / 10 '製品5溫度
ElseIf blL1 = "06" Then
record_jmm(5) = Val(Mid$(Text2, 21, 4)) / 10 '製品6溫度
End If
record_jm(0) = Val(record_jmm(0))
record_jm(1) = Val(record_jmm(1))
record_jm(2) = Val(record_jmm(2))
record_jm(3) = Val(record_jmm(3))
record_jm(4) = Val(record_jmm(4))
record_jm(5) = Val(record_jmm(5))
blL = Mid$(Text2, 7, 6)
Call Hex_bin '輸出口狀態鑒別
blLg = Mid$(Text2, 13, 6)
Call hex_bin1 '輸出口故障狀態鑒別
txtSend = ""
Else
txtSend = ""
End If
End If
If Not blnAutoSendFlag And Not blnReceiveFlag Then
frmMain.ctrMSComm.PortOpen = False
End If
End If
End Select
End Sub

以上是一段MSCOMM的ONCOMM事件代碼,接收的數據按上下位機約定取出賦值於全局變數,在其它窗體進行數據記錄(寫入資料庫).至於數據分析確如一樓說的可以海闊天空,通過數據控制項及SQL語句來完成任務.

以下提供MSDN參考:
OnComm 常數
常數 值 描述
comEvSend 1 發送事件。
comEvReceive 2 接收事件。
comEvCTS 3 clear-to-send 線變化。
comEvDSR 4 data-set ready 線變化。
comEvCD 5 carrier detect 線變化。
comEvRing 6 振鈴檢測。
comEvEOF 7 文件結束。

MSComm 控制項提供下列兩種處理通訊的方式:

事件驅動通訊是處理串列埠交互作用的一種非常有效的方法。在許多情況下,在事件發生時需要得到通知,例如,在 Carrier Detect (CD) 或 Request To Send (RTS) 線上一個字元到達或一個變化發生時。在這些情況下,可以利用 MSComm 控制項的 OnComm 事件捕獲並處理這些通訊事件。OnComm 事件還可以檢查和處理通訊錯誤。所有通訊事件和通訊錯誤的列表,參閱 CommEvent 屬性。
在程序的每個關鍵功能之後,可以通過檢查 CommEvent 屬性的值來查詢事件和錯誤。如果應用程序較小,並且是自保持的,這種方法可能是更可取的。例如,如果寫一個簡單的電話撥號程序,則沒有必要對每接收一個字元都產生事件,因為唯一等待接收的字元是數據機的「確定」響應。
SThreshold 屬性
在 MSComm 控制項設置 CommEvent 屬性為 comEvSend 並產生 OnComm 事件之前,設置並返回傳輸緩沖區中允許的最小字元數。
說明
若設置 Sthreshold 屬性為 0(預設值),數據傳輸事件不會產生 OnComm 事件。若設置 Sthreshold 屬性為 1,當傳輸緩沖區完全空時,MSComm 控制項產生 OnComm 事件。
如果在傳輸緩沖區中的字元數小於 value,CommEvent 屬性設置為 comEvSend,並產生 OnComm 事件。comEvSend 事件僅當字元數與 Sthreshold 交叉時被激活一次。例如,如果 Sthreshold 等於 5,僅當在輸出隊列中字元數從 5 降到 4 時,comEvSend 才發生。如果在輸出隊列中從沒有比 Sthreshold 多的字元,comEvSend 事件將絕不會發生。

CommEvent 屬性包含實際錯誤或產生 OnComm 事件的數碼。注意,設置 Rthreshold 或 Sthreshold 屬性為 0,分別使捕獲 comEvReceive 和 comEvSend 事件無效。