地磅稱重 車牌識別 和erp mes wms 聯動閉環管理


                     

1.用戶需求和 功能初步規划

                     

                     

功能改造點確認

節點4 車牌識別和稱重數據采集

4.1舊的稱重軟件 ,稱重儀表 和 串口 設置

地磅接線圖 : 地磅傳感器==>(圓形電纜)=>稱重儀表==(rs232)=>舊稱重軟件(串口)

                     

4.2新的 自開發 稱重界面

設備連接方式:車牌識別 : 臻識車牌識別攝像機 ===>辦公網絡===>稱重系統(臻識攝像頭SDK)

地磅采集: 地磅傳感器===>(圓形電纜)=>稱重儀表===>康耐得 rs232轉以太網模塊===>辦公網絡===>稱重軟件(tcpip協議)

車頭車尾影像: TP-Link TL-IPC544H-W6 室外監控攝像頭 ===>辦公網絡===>稱重系統(onvif協議)

 

 

4.3稱重畫面連接 稱重儀表獲取 重量

Com1 波特率 9600 數據位 8 停止位 1 奇偶校驗 無    連接到康耐得模塊 康耐得模塊ip 10.8.20.252 端口8000

byte[] recvData = new byte[1024 * 10];

TcpClient client = new TcpClient();

//連接

client.BeginConnect("10.8.20.252", 8000, ConnectCallBack, client);

#region 連接康耐得模塊 采集地磅數據

private void ConnectCallBack(IAsyncResult result)

{

TcpClient client = result.AsyncState as TcpClient;

try

{

client.EndConnect(result);

}

catch (Exception ex)

{

Console.WriteLine("which is " + ex.ToString());

return;

}

client.Client.BeginReceive(recvData, 0, recvData.Length, SocketFlags.None, RecvCallBack, client);

                 

}

public void RecvCallBack(IAsyncResult result)

{

int count = -1;

try

{

count = client.Client.EndReceive(result);

}

catch (Exception ex)

{

//Console.WriteLine("遠程計算機關閉");

return;

}

string msg = Encoding.ASCII.GetString(recvData, 0, count);

//Console.WriteLine("接到消息:");

//Console.WriteLine(msg);

SetText(msg);

client.Client.BeginReceive(recvData, 0, recvData.Length, SocketFlags.None, RecvCallBack, client);

}

private delegate void SetTextCallback(string text);

private void SetText(string text)

{

// InvokeRequired需要比較調用線程ID和創建線程ID

// 如果它們不相同則返回true

if (this.textBox6.InvokeRequired)

{

SetTextCallback d = new SetTextCallback(SetText);

this.Invoke(d, new object[] { text });

}

else

{

char[] arr = text.ToCharArray();

Array.Reverse(arr);

text = new string(arr);

                 

this.textBox6.Text = text;

listBox1.Items.Insert(0, DateTime.Now + "地磅重量" + text);

}

}

#endregion

4.4稱重畫面 連接 攝像頭獲取車牌照號

short nPort = Int16.Parse(txtPort.Text);

int handle = VzClientSDK.VzLPRClient_Open(txtIP.Text, (ushort)nPort, txtUserName.Text, txtPwd.Text);

if (handle == 0)

{

MessageBox.Show("打開設備失敗!");

return;

}  

protected override void DefWndProc(ref Message m)

{

IntPtr intptr;

VzClientSDK.VZ_LPR_MSG_PLATE_INFO plateInfo;

VzClientSDK.VZ_LPR_DEVICE_INFO deviceInfo;

int handle = 0;

switch (m.Msg)

{

case MSG_PLATE_INFO:

intptr = (IntPtr)m.WParam.ToInt32();

handle = m.LParam.ToInt32();

if (intptr != null)

{

plateInfo = (VzClientSDK.VZ_LPR_MSG_PLATE_INFO)Marshal.PtrToStructure(intptr, typeof(VzClientSDK.VZ_LPR_MSG_PLATE_INFO));

if (handle == GetPicBox1Handle())

{

// 顯示車牌號

if (plateInfo.plate != "")

{

lblPlate.Text = plateInfo.plate;

textBoxX1.Text = plateInfo.plate;

listBox1.Items.Insert(0, lblPlate.Text);

msg(lblPlate.Text);

}

}

Marshal.FreeHGlobal(intptr);

}

break;

                     

case MSG_DEVICE_INFO:

intptr = (IntPtr)m.WParam.ToInt32();

if (intptr != null)

{

deviceInfo = (VzClientSDK.VZ_LPR_DEVICE_INFO)Marshal.PtrToStructure(intptr, typeof(VzClientSDK.VZ_LPR_DEVICE_INFO));

ShowDevice(deviceInfo.device_ip, deviceInfo.serial_no);

                     

Marshal.FreeHGlobal(intptr);

}

break;

                     

default:

base.DefWndProc(ref m);

break;

}

}

4.5連接監控攝像頭進行拍照,使用的EmguCV 組件 ,攝像頭是 onvif協議

Install-Package EmguCV -Version 3.1.0.1

獲取監控圖像代碼如下

string url = "rtsp://admin:admin@10.8.5.105:554/stream1";

Mat mat = new Mat();

Capture capture;

Thread GetImage;

               

Control.CheckForIllegalCrossThreadCalls = false;

GetImage = new Thread(GetFpsImg);

GetImage.Start();

               

private void GetFpsImg()

{

capture = new Capture(url);

while (true)

{

try

{

bool grab = capture.Grab();

bool isSuccess = capture.Retrieve(mat);

Thread.Sleep(130);

ParentpictureBox.Image = mat;//1080*1920

imageBox1.Image = mat;//1080*1920

}

catch (Exception)

{

}

}

}

攝像頭安裝方位 

    

               

4.6程序邏輯    

4.5.1車輛到到地磅指定位置 則車牌號自動填充到 車牌文本框 ;

4.5.2送貨單號通過 彈窗 選擇 取自 erp 800環境 (客戶端需要安裝hana驅動 "必須安裝hana_odbc驅動_X86_64_20190112.zip")

select ekko.bedat, ekpo.ebeln, ekpo.ebelp, ekko.lifnr, lfa1.name1, ekpo.matnr, makt.maktx, ekpo.menge, t1.wemng

from saphanadb.ekpo

left join saphanadb.ekko on ekpo.ebeln = ekko.ebeln

left join saphanadb.makt on ekpo.matnr = makt.matnr

and makt.spras = '1'

left join saphanadb.lfa1 on ekko.lifnr = lfa1.lifnr

left join (select eket.ebeln, eket.ebelp, sum(eket.wemng) as wemng from saphanadb.eket group by eket.ebeln, eket.ebelp) as t1 on ekpo.ebeln =

t1.ebeln

and

ekpo.ebelp =

t1.ebelp

where saphanadb.ekpo.matnr = '000000001000017077'

and ekpo.menge > t1.wemng

order by ekko.bedat, ekpo.ebeln, ekpo.ebelp

       

4.5.3 通過上面的步驟 帶出 送貨單對應供應商

4.5.4物料號 需要按實際送貨物料號由用戶按實際送貨情況選擇,自動帶出 品名規格

4.5.5 當 重量數據穩定了后 點重量寫入 保存到數據庫 ,同時 加入到下方表格第一行

節點5 水分檢測/顆粒度檢測 app  

5.1

水分采用設備采集方式連接到系統

水分儀==(串口)康耐得模塊=辦公網絡

數據采集采用一致獨立的程序 放在服務器,水分儀測試完成 會主動上報報文給串口, 從而采集程序能自動拿到這個信息,然后保存到數據庫即可

5.2

App中點采集

(未完待續)

點擊加入群聊【SAP_MES行業交流


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM