|
|
@@ -8,6 +8,7 @@ using System.Text;
|
|
|
using System.Net;
|
|
|
using System.Net.Sockets;
|
|
|
using System.IO.Ports;
|
|
|
+using HslCommunication;
|
|
|
|
|
|
namespace FileWatcher
|
|
|
{
|
|
|
@@ -45,6 +46,8 @@ namespace FileWatcher
|
|
|
|
|
|
ftpOperater ftp = new ftpOperater();
|
|
|
|
|
|
+ HslCommunication.Profinet.Panasonic.PanasonicMewtocol plc;
|
|
|
+
|
|
|
public AutoSMTRXY()
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
@@ -182,7 +185,7 @@ namespace FileWatcher
|
|
|
" sum(dsl_madeqty)allmadeqty from devsmtlocation group by DSL_LINECODE,Dsl_Location)A on " +
|
|
|
" alllincode=devsmtlocation.dsl_linecode and allLocation=dsl_location left join barcode " +
|
|
|
" on dsl_barcode = bar_code where dsl_status=0 and dsl_usable=1) ");
|
|
|
- DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
+ System.Data.DataTable dt = (DataTable)dh.ExecuteSql(sql.ToString(), "select");
|
|
|
for (int i = 0; i < dt.Rows.Count; i++)
|
|
|
{
|
|
|
string 站位 = dt.Rows[i]["站位"].ToString();
|
|
|
@@ -282,9 +285,15 @@ namespace FileWatcher
|
|
|
StopWatch.Enabled = true;
|
|
|
try
|
|
|
{
|
|
|
- serialPort1.PortName = ComPort.Text;
|
|
|
- serialPort1.BaudRate = int.Parse(BaudRate.Text);
|
|
|
- serialPort1.Open();
|
|
|
+ plc = new HslCommunication.Profinet.Panasonic.PanasonicMewtocol();
|
|
|
+ plc.Station = 238;
|
|
|
+ HslCommunication.Core.Pipe.PipeSerialPort pipe = new HslCommunication.Core.Pipe.PipeSerialPort();
|
|
|
+ pipe.SerialPortInni(ComPort.Text, 9600, 8, StopBits.One, Parity.Odd);
|
|
|
+ pipe.RtsEnable = false;
|
|
|
+ pipe.DtrEnable = false;
|
|
|
+ pipe.SleepTime = 20;
|
|
|
+ pipe.ReceiveTimeOut = 5000;
|
|
|
+ plc.CommunicationPipe = pipe;
|
|
|
Timer.Start();
|
|
|
}
|
|
|
catch (Exception mes)
|
|
|
@@ -309,14 +318,40 @@ namespace FileWatcher
|
|
|
|
|
|
private void Timer_Tick(object sender, EventArgs e)
|
|
|
{
|
|
|
- if (serialPort1.IsOpen)
|
|
|
+ string error = "";
|
|
|
+ OperateResult<short> read = plc.ReadInt16("D60");
|
|
|
+ if (read.IsSuccess)
|
|
|
{
|
|
|
- if (!realwritedata)
|
|
|
+ if (read.Content != 0)
|
|
|
{
|
|
|
- byte[] data = HexStringToBytes("01 03 00 01 00 06 94 08");
|
|
|
- serialPort1.Write(data, 0, data.Length);
|
|
|
+ double qty = Convert.ToInt32(read.Content);
|
|
|
+ if (lastqty > qty)
|
|
|
+ {
|
|
|
+ lastqty = 0;
|
|
|
+ }
|
|
|
+ NowQTY.Text = qty.ToString();
|
|
|
+ if (Type.Text == "投入")
|
|
|
+ {
|
|
|
+ string ma_inqty = dh.getFieldDataByCondition("make", "nvl(ma_inqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
|
|
|
+ dh.ExecuteSql("update make set ma_inqty=nvl(ma_inqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
|
|
|
+ dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
|
|
|
+ "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ string ma_endqty = dh.getFieldDataByCondition("make", "nvl(ma_endqty,0)", "ma_code='" + ma_code.Text + "'").ToString();
|
|
|
+ dh.ExecuteSql("update make set ma_endqty=nvl(ma_endqty,0)+'" + (qty - lastqty) + "' where ma_code='" + ma_code.Text + "' ", "update");
|
|
|
+ dh.ExecuteSql("insert into makehourcount(mhc_id,mhc_macode,mhc_indate,mhc_type,mhc_qty,mhc_linecode,mhc_pcbcount)" +
|
|
|
+ "values(makehourcount_seq.nextval,'" + ma_code.Text + "',sysdate,'" + Type.Text + "','" + (qty - lastqty) + "','" + li_code.Text + "','" + pr_pcbacount.Value + "')", "insert");
|
|
|
+ }
|
|
|
+ LogicHandler.CS_SetResult(ma_code.Text, li_code.Text, "", qty.ToString(), li_code.Text, "OK", out error);
|
|
|
+ lastqty = qty;
|
|
|
}
|
|
|
}
|
|
|
+ else
|
|
|
+ {
|
|
|
+ MessageBox.Show("Read [D60] failed: " + read.Message);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private byte[] HexStringToBytes(string hs)//十六进制字符串转byte
|