|
|
@ -30,7 +30,7 @@ namespace PunchAndWeld |
|
|
|
|
|
|
|
private GridppReport Report = new GridppReport(); |
|
|
|
private string oneBarCode = "", stationNo ="", stationId = ""; |
|
|
|
|
|
|
|
private DataTable _collectParamTable = new DataTable(); |
|
|
|
|
|
|
|
public FrmProScreenBumperS() |
|
|
|
{ |
|
|
@ -39,6 +39,7 @@ namespace PunchAndWeld |
|
|
|
|
|
|
|
private void FrmProScreenBumper_Load(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
|
|
|
|
//this.WindowState = FormWindowState.Maximized;
|
|
|
|
stationNo = ConfigurationManager.AppSettings["StationNo"]; |
|
|
|
stationId = ProScreenFunc.GetStationId(stationNo); |
|
|
@ -85,21 +86,48 @@ namespace PunchAndWeld |
|
|
|
opcHelper.opcItems1 = opcHelper.opcGroup1.OPCItems; |
|
|
|
opcHelper.opcItems1.DefaultIsActive = true; |
|
|
|
|
|
|
|
DataTable dt = bll.SearchInfo(ConfigurationManager.AppSettings["DeviceNo"], 0); |
|
|
|
DataTable dt = bll.SearchInfo(ConfigurationManager.AppSettings["DeviceNo"], 0);//读 0:读 1:写
|
|
|
|
_collectParamTable = bll.SearchExtendInfo(ConfigurationManager.AppSettings["StationNo"], 0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (dt != null && dt.Rows.Count > 0) |
|
|
|
{ |
|
|
|
opcHelper.opcItemm1 = new OPCItem[dt.Rows.Count]; |
|
|
|
if (stationNo == "ZP66") |
|
|
|
{ |
|
|
|
opcHelper.opcItemm1 = new OPCItem[dt.Rows.Count + _collectParamTable.Rows.Count]; |
|
|
|
} |
|
|
|
for (int i = 0; i < dt.Rows.Count; i++) |
|
|
|
{ |
|
|
|
opcHelper.opcItemm1[i] = opcHelper.opcItems1.AddItem(dt.Rows[i]["Address"].ToString(), i); |
|
|
|
} |
|
|
|
} |
|
|
|
if (stationNo == "ZP66") |
|
|
|
{ |
|
|
|
int k = dt.Rows.Count;//延续原有参数数量
|
|
|
|
foreach (DataRow dr in _collectParamTable.Rows) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
if (!string.IsNullOrEmpty(dr["Address"].ToString())) |
|
|
|
{ |
|
|
|
opcHelper.opcItemm1[k] = opcHelper.opcItems1.AddItem(dr["Address"].ToString(), k); |
|
|
|
} |
|
|
|
k++; |
|
|
|
} |
|
|
|
catch(Exception ee) |
|
|
|
{ |
|
|
|
throw ee; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
opcHelper.opcItems2 = opcHelper.opcGroup2.OPCItems; |
|
|
|
opcHelper.opcItems2.DefaultIsActive = true; |
|
|
|
|
|
|
|
DataTable dt1 = bll.SearchInfo(ConfigurationManager.AppSettings["DeviceNo"], 1); |
|
|
|
DataTable dt1 = bll.SearchInfo(ConfigurationManager.AppSettings["DeviceNo"], 1);//写
|
|
|
|
if (dt1 != null && dt1.Rows.Count > 0) |
|
|
|
{ |
|
|
|
if (stationNo == "ZP61") |
|
|
@ -231,10 +259,17 @@ namespace PunchAndWeld |
|
|
|
} |
|
|
|
|
|
|
|
private void timer_Tick(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
label9.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); |
|
|
|
Thread.Sleep(500); |
|
|
|
} |
|
|
|
catch(Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void LoadScreen() |
|
|
|
{ |
|
|
@ -1731,12 +1766,26 @@ namespace PunchAndWeld |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
DataTable table = new DataTable(); |
|
|
|
DataRow dr = table.NewRow(); |
|
|
|
for (int i = 1; i <= NumItems; i++) |
|
|
|
{ |
|
|
|
int handle = Convert.ToInt32(ClientHandles.GetValue(i).ToString().Trim()); |
|
|
|
string value = ItemValues.GetValue(i).ToString(); |
|
|
|
string address = opcHelper.opcItemm1[(Convert.ToInt32(ClientHandles.GetValue(i)))].ItemID; |
|
|
|
int handle = 0; |
|
|
|
string value = ""; |
|
|
|
string address = ""; |
|
|
|
try |
|
|
|
{ |
|
|
|
handle = Convert.ToInt32(ClientHandles.GetValue(i).ToString().Trim()); |
|
|
|
value = ItemValues.GetValue(i).ToString(); |
|
|
|
address = opcHelper.opcItemm1[(Convert.ToInt32(ClientHandles.GetValue(i)))].ItemID; |
|
|
|
|
|
|
|
} |
|
|
|
catch(Exception exx) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
#region 原因功能
|
|
|
|
if (handle == 0) |
|
|
|
{ |
|
|
|
if (value == "1" || value.ToUpper() == "TRUE") |
|
|
@ -1807,8 +1856,63 @@ namespace PunchAndWeld |
|
|
|
lbOK.Text = "OK"; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 保存采集数据
|
|
|
|
if (NumItems > 100) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
foreach (DataRow collectRow in _collectParamTable.Rows) |
|
|
|
{ |
|
|
|
if (collectRow["Address"].ToString() == address && address.Contains("we")) |
|
|
|
{ |
|
|
|
string[] args = address.Split('.'); |
|
|
|
if (args.Length == 3) |
|
|
|
{ |
|
|
|
string columnName = args[2]; |
|
|
|
if (dr.Table.Columns.Contains(columnName) == false) |
|
|
|
{ |
|
|
|
dr.Table.Columns.Add(columnName); |
|
|
|
dr[columnName] = value; |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
catch(Exception ex) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
} |
|
|
|
if (NumItems > 100) |
|
|
|
{ |
|
|
|
if (dr.Table.Columns.Contains("DeviceCode") == false) |
|
|
|
{ |
|
|
|
dr.Table.Columns.Add("DeviceCode"); |
|
|
|
dr["DeviceCode"] = ConfigurationManager.AppSettings["DeviceNo"]; |
|
|
|
} |
|
|
|
if (dr.Table.Columns.Contains("StationNo") == false) |
|
|
|
{ |
|
|
|
dr.Table.Columns.Add("StationNo"); |
|
|
|
dr["StationNo"] = ConfigurationManager.AppSettings["StationNo"]; |
|
|
|
} |
|
|
|
if (dr.Table.Columns.Contains("ScreenMode") == false) |
|
|
|
{ |
|
|
|
dr.Table.Columns.Add("ScreenMode"); |
|
|
|
dr["ScreenMode"] = ConfigurationManager.AppSettings["ProScreenMode"]; |
|
|
|
} |
|
|
|
bll.AddDeviceRecord(dr); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
LogHelper.WriteErrLogBase(ex.ToString(), MethodBase.GetCurrentMethod().Name); |
|
|
@ -2103,7 +2207,61 @@ namespace PunchAndWeld |
|
|
|
|
|
|
|
private void label10_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
if (MessageBox.Show("确认保存焊接机返回结果?", "提示", MessageBoxButtons.OKCancel) == DialogResult.Cancel) |
|
|
|
return; |
|
|
|
|
|
|
|
int i = 1; |
|
|
|
int[] ClientHandlersInt = new int[_collectParamTable.Rows.Count+1]; |
|
|
|
string[] ItemValuesStr = new string[_collectParamTable.Rows.Count+1]; |
|
|
|
foreach (DataRow collectRow in _collectParamTable.Rows) |
|
|
|
{ |
|
|
|
ClientHandlersInt[i] = i + 11; |
|
|
|
if (collectRow["Address"].ToString().Contains("deep")) |
|
|
|
{ |
|
|
|
ItemValuesStr[i] = GetDecimalRodom().ToString(); |
|
|
|
} |
|
|
|
else if (collectRow["Address"].ToString().Contains("energy")) |
|
|
|
{ |
|
|
|
ItemValuesStr[i] = GetIntRodom().ToString(); |
|
|
|
} |
|
|
|
else if (collectRow["Address"].ToString().Contains("loc")) |
|
|
|
{ |
|
|
|
ItemValuesStr[i] = GetDecimalRodom().ToString(); |
|
|
|
} |
|
|
|
else if (collectRow["Address"].ToString().Contains("time")) |
|
|
|
{ |
|
|
|
ItemValuesStr[i] = GetDecimalRodom().ToString(); |
|
|
|
} |
|
|
|
else if (collectRow["Address"].ToString().Contains("state")) |
|
|
|
{ |
|
|
|
ItemValuesStr[i] = GetIntRodom().ToString(); |
|
|
|
} |
|
|
|
|
|
|
|
i++; |
|
|
|
} |
|
|
|
// int handle = Convert.ToInt32(ClientHandles.GetValue(i).ToString().Trim());
|
|
|
|
//string value = ItemValues.GetValue(i).ToString();
|
|
|
|
//string address = opcHelper.opcItemm1[(Convert.ToInt32(ClientHandles.GetValue(i)))].ItemID;
|
|
|
|
|
|
|
|
|
|
|
|
Array ClientHandlers = ClientHandlersInt; |
|
|
|
Array ItemValues = ItemValuesStr; |
|
|
|
Array c = null; |
|
|
|
Array d = null; |
|
|
|
opcGroup1_DataChange(1, 105, ref ClientHandlers, ref ItemValues, ref c, ref d); |
|
|
|
|
|
|
|
//更新说明 1:创建表tb_PunchDevice_Records用于记录设备输出结果
|
|
|
|
//2:创建 tb_PunchAddressExtend存储设备参数. 和 和原有配置表tb_PunchAddress共同起作用
|
|
|
|
//3.创建 Kepserver字段 必须和tb_PunchAddressExtendy一致.
|
|
|
|
} |
|
|
|
Random rd = new Random(); |
|
|
|
double GetDecimalRodom() |
|
|
|
{ |
|
|
|
return rd.NextDouble()+1; |
|
|
|
} |
|
|
|
int GetIntRodom() |
|
|
|
{ |
|
|
|
return rd.Next(1, 9); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|