oee相关修改
This commit is contained in:
1 parent
9c5ef7bb31
commit
4419a4de3c
9 files changed
+422
-121
No files matched your search
@@ -36,7 +36,7 @@
|
|||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="CsvHelper">
|
<Reference Include="CsvHelper">
|
||||||
<HintPath>..\..\CsvHelper.dll</HintPath>
|
<HintPath>Z:\WHProjects\CsvHelper.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="HslCommunication, Version=7.0.1.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
|
<Reference Include="HslCommunication, Version=7.0.1.0, Culture=neutral, PublicKeyToken=cdb2261fa039ed67, processorArchitecture=MSIL">
|
||||||
<HintPath>..\packages\HslCommunication.7.0.1\lib\net451\HslCommunication.dll</HintPath>
|
<HintPath>..\packages\HslCommunication.7.0.1\lib\net451\HslCommunication.dll</HintPath>
|
||||||
|
|||||||
@@ -48,6 +48,8 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
// 在MainForm类的成员变量部分添加一个定时器
|
// 在MainForm类的成员变量部分添加一个定时器
|
||||||
private System.Windows.Forms.Timer statusReportTimer = new System.Windows.Forms.Timer();
|
private System.Windows.Forms.Timer statusReportTimer = new System.Windows.Forms.Timer();
|
||||||
|
|
||||||
|
private System.Windows.Forms.Timer screwReportTimer = new System.Windows.Forms.Timer();
|
||||||
private ApiClient statusApiClient = new ApiClient(); // 专用于状态上报的API客户端
|
private ApiClient statusApiClient = new ApiClient(); // 专用于状态上报的API客户端
|
||||||
private object curingLock = new object();
|
private object curingLock = new object();
|
||||||
private Dictionary<int, int> OldPlcTrigger = new Dictionary<int, int>();
|
private Dictionary<int, int> OldPlcTrigger = new Dictionary<int, int>();
|
||||||
@@ -121,6 +123,9 @@ namespace WindowsFormsApp1
|
|||||||
// 初始化状态上报定时器
|
// 初始化状态上报定时器
|
||||||
statusReportTimer.Interval = int.Parse(Init.t_Keyvalues.First(x => x.key == "StatusTime").value) * 1000; // 15秒
|
statusReportTimer.Interval = int.Parse(Init.t_Keyvalues.First(x => x.key == "StatusTime").value) * 1000; // 15秒
|
||||||
statusReportTimer.Tick += StatusReportTimer_Tick;
|
statusReportTimer.Tick += StatusReportTimer_Tick;
|
||||||
|
|
||||||
|
screwReportTimer.Interval = 8000;
|
||||||
|
screwReportTimer.Tick += ScrewReportTimer_Tick;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void build(t_plc Plc, CancellationToken token)
|
public void build(t_plc Plc, CancellationToken token)
|
||||||
@@ -307,12 +312,22 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
//反馈状态
|
//反馈状态
|
||||||
Init.Plcstatus = PlcData.Read_Status;
|
Init.Plcstatus = PlcData.Read_Status;
|
||||||
|
|
||||||
Init.Plcstatus_LastTime = DateTime.Now;
|
Init.Plcstatus_LastTime = DateTime.Now;
|
||||||
otherdata.Plc_Status = PlcData.Read_Status.ToString();
|
otherdata.Plc_Status = PlcData.Read_Status.ToString();
|
||||||
|
if (PlcData.Read_Status == 2)
|
||||||
|
{
|
||||||
|
// 报警的时候 赋值报警代码
|
||||||
|
var oeeresult1 = siemensHelp.ReadAddress(oeeaddresses);
|
||||||
|
|
||||||
|
Init.ErrorCode = oeeresult1.Data.FirstOrDefault(x => x.value.ToLower() == "true")?.code;
|
||||||
|
|
||||||
|
otherdata.Plc_Status = $"{PlcData.Read_Status}_{Init.ErrorCode}";
|
||||||
|
}
|
||||||
var statusresult = apiClient.CallFunctionByName("Status", PlcData, otherdata);
|
var statusresult = apiClient.CallFunctionByName("Status", PlcData, otherdata);
|
||||||
if (statusresult.Success)
|
if (statusresult.Success)
|
||||||
{
|
{
|
||||||
LogExecute.OEElogNet.WriteDebug($"上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)}");
|
LogExecute.OEElogNet.WriteDebug($"上报机台状态成功: {plcstatus.GetName(typeof(plcstatus), Init.Plcstatus)} {Init.ErrorCode}");
|
||||||
|
|
||||||
MES_MsgfORM("Status", statusresult, statusresult.Requesttime);
|
MES_MsgfORM("Status", statusresult, statusresult.Requesttime);
|
||||||
if (statusresult.Mesresult != mesresult.PASS)
|
if (statusresult.Mesresult != mesresult.PASS)
|
||||||
@@ -338,10 +353,6 @@ namespace WindowsFormsApp1
|
|||||||
if (oldstatus != (short)plcstatus.停机)
|
if (oldstatus != (short)plcstatus.停机)
|
||||||
{
|
{
|
||||||
//反馈报警
|
//反馈报警
|
||||||
var oeeresult = siemensHelp.ReadAddress(oeeaddresses);
|
|
||||||
|
|
||||||
Init.ErrorCode = oeeresult.Data?.FirstOrDefault(x => x.value == "True")?.code ?? "";
|
|
||||||
|
|
||||||
Init.Plcstatus = PlcData.Read_Status;
|
Init.Plcstatus = PlcData.Read_Status;
|
||||||
Init.Plcstatus_LastTime = DateTime.Now;
|
Init.Plcstatus_LastTime = DateTime.Now;
|
||||||
var statusresult = apiClient.CallFunctionByName("Alarm", PlcData, otherdata);
|
var statusresult = apiClient.CallFunctionByName("Alarm", PlcData, otherdata);
|
||||||
@@ -423,7 +434,6 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
|
||||||
#region 根据流程,判断是否需要扫码、气密、扭力等
|
#region 根据流程,判断是否需要扫码、气密、扭力等
|
||||||
if (nowflow.scan)
|
if (nowflow.scan)
|
||||||
@@ -586,6 +596,9 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
//文件上传
|
//文件上传
|
||||||
}
|
}
|
||||||
|
// oeedatacollection
|
||||||
|
var oeeresult = siemensHelp.ReadAddress(oeeaddresses);
|
||||||
|
otherdata.Oeeaddresses = oeeaddresses;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 判断物料调用次数 固化站,抽真空
|
#region 判断物料调用次数 固化站,抽真空
|
||||||
@@ -892,6 +905,7 @@ namespace WindowsFormsApp1
|
|||||||
|
|
||||||
// 启动状态上报定时器
|
// 启动状态上报定时器
|
||||||
statusReportTimer.Start();
|
statusReportTimer.Start();
|
||||||
|
screwReportTimer.Start();
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -1058,6 +1072,7 @@ namespace WindowsFormsApp1
|
|||||||
{
|
{
|
||||||
// 停止状态上报定时器
|
// 停止状态上报定时器
|
||||||
statusReportTimer.Stop();
|
statusReportTimer.Stop();
|
||||||
|
screwReportTimer.Stop();
|
||||||
|
|
||||||
// 停止所有线程
|
// 停止所有线程
|
||||||
if (Init.threadHelps != null)
|
if (Init.threadHelps != null)
|
||||||
@@ -1769,7 +1784,7 @@ namespace WindowsFormsApp1
|
|||||||
if (Init.Plcstatus == 2)
|
if (Init.Plcstatus == 2)
|
||||||
{
|
{
|
||||||
//报警
|
//报警
|
||||||
statusOtherData.Plc_Status = $"{Init.Plcstatus.ToString()}_{Init.ErrorCode}";
|
statusOtherData.Plc_Status = $"{Init.Plcstatus}_{Init.ErrorCode}";
|
||||||
}
|
}
|
||||||
var statusResult = statusApiClient.CallFunctionByName("Status", new plcdata(), statusOtherData);
|
var statusResult = statusApiClient.CallFunctionByName("Status", new plcdata(), statusOtherData);
|
||||||
if (statusResult.Success)
|
if (statusResult.Success)
|
||||||
@@ -1792,6 +1807,35 @@ namespace WindowsFormsApp1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//螺丝扭力上传定时器
|
||||||
|
private void ScrewReportTimer_Tick(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
SQLiteHelper<t_materialupload> sQLiteHelper_upload = new db.SQLiteHelper<t_materialupload>();
|
||||||
|
var material_sqlresult = sQLiteHelper_upload
|
||||||
|
.Query(x => x.datacollectionUploaded == 1);
|
||||||
|
if (material_sqlresult.Success)
|
||||||
|
{
|
||||||
|
ApiClient apiClient = new ApiClient();
|
||||||
|
var materialList = material_sqlresult.Data.Take(5);
|
||||||
|
foreach(var material in materialList)
|
||||||
|
{
|
||||||
|
otherdata OtherData = new otherdata();
|
||||||
|
OtherData.material = material;
|
||||||
|
var result = apiClient.CallFunctionByName("Data_Collection", new plcdata(), OtherData);
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
MES_MsgfORM("Data_Collection", result, result.Requesttime);
|
||||||
|
if(result.Mesresult == mesresult.PASS)
|
||||||
|
{
|
||||||
|
//标记该物料已上传
|
||||||
|
material.datacollectionUploaded = 2;
|
||||||
|
sQLiteHelper_upload.Update(material);
|
||||||
|
LogExecute.OEElogNet.WriteDebug($"{material.sn} 扭力上报成功!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
// 定时扫描 周期扫描未上传 图片,视频等 sn,然后调用上传文件接口 todo
|
// 定时扫描 周期扫描未上传 图片,视频等 sn,然后调用上传文件接口 todo
|
||||||
#endregion 定时器
|
#endregion 定时器
|
||||||
|
|
||||||
|
|||||||
@@ -45,6 +45,42 @@ namespace WindowsFormsApp1.db
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据插入
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">要插入的数据项</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public BllResult InsertAll(List<T> item)
|
||||||
|
{
|
||||||
|
if (_connection.InsertAll(item) > 0)
|
||||||
|
{
|
||||||
|
return BllResult.Sucess();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BllResult.Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 数据删除
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="item">要插入的数据项</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public BllResult DeleteAll()
|
||||||
|
{
|
||||||
|
if (_connection.DeleteAll<T>() > 0)
|
||||||
|
{
|
||||||
|
return BllResult.Sucess();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return BllResult.Error();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 数据删除
|
/// 数据删除
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
+36
-16
@@ -38,10 +38,12 @@ namespace WindowsFormsApp1.form
|
|||||||
this.addresstypelegth = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.addresstypelegth = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.addressoffset = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.addressdecimal = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
this.addressdecimal = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
|
this.remark = new System.Windows.Forms.DataGridViewTextBoxColumn();
|
||||||
this.button1 = new System.Windows.Forms.Button();
|
this.button1 = new System.Windows.Forms.Button();
|
||||||
this.查询 = new System.Windows.Forms.Button();
|
this.查询 = new System.Windows.Forms.Button();
|
||||||
this.保存 = new System.Windows.Forms.Button();
|
this.清空 = new System.Windows.Forms.Button(); // 将保存改为清空
|
||||||
this.关闭 = new System.Windows.Forms.Button();
|
this.关闭 = new System.Windows.Forms.Button();
|
||||||
|
this.导入 = new System.Windows.Forms.Button();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
@@ -57,11 +59,12 @@ namespace WindowsFormsApp1.form
|
|||||||
this.addresstype,
|
this.addresstype,
|
||||||
this.addresstypelegth,
|
this.addresstypelegth,
|
||||||
this.addressoffset,
|
this.addressoffset,
|
||||||
this.addressdecimal});
|
this.addressdecimal,
|
||||||
|
this.remark});
|
||||||
this.dataGridView1.Location = new System.Drawing.Point(12, 41);
|
this.dataGridView1.Location = new System.Drawing.Point(12, 41);
|
||||||
this.dataGridView1.Name = "dataGridView1";
|
this.dataGridView1.Name = "dataGridView1";
|
||||||
this.dataGridView1.RowTemplate.Height = 23;
|
this.dataGridView1.RowTemplate.Height = 23;
|
||||||
this.dataGridView1.Size = new System.Drawing.Size(1044, 397);
|
this.dataGridView1.Size = new System.Drawing.Size(1200, 397);
|
||||||
this.dataGridView1.TabIndex = 0;
|
this.dataGridView1.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// id
|
// id
|
||||||
@@ -111,7 +114,6 @@ namespace WindowsFormsApp1.form
|
|||||||
this.addressoffset.DataPropertyName = "addressoffset";
|
this.addressoffset.DataPropertyName = "addressoffset";
|
||||||
this.addressoffset.HeaderText = "地址偏移";
|
this.addressoffset.HeaderText = "地址偏移";
|
||||||
this.addressoffset.Name = "addressoffset";
|
this.addressoffset.Name = "addressoffset";
|
||||||
|
|
||||||
//
|
//
|
||||||
// addressdecimal
|
// addressdecimal
|
||||||
//
|
//
|
||||||
@@ -119,6 +121,12 @@ namespace WindowsFormsApp1.form
|
|||||||
this.addressdecimal.HeaderText = "位地址";
|
this.addressdecimal.HeaderText = "位地址";
|
||||||
this.addressdecimal.Name = "addressdecimal";
|
this.addressdecimal.Name = "addressdecimal";
|
||||||
//
|
//
|
||||||
|
// remark
|
||||||
|
//
|
||||||
|
this.remark.DataPropertyName = "remark";
|
||||||
|
this.remark.HeaderText = "备注";
|
||||||
|
this.remark.Name = "remark";
|
||||||
|
//
|
||||||
// button1
|
// button1
|
||||||
//
|
//
|
||||||
this.button1.Location = new System.Drawing.Point(12, 12);
|
this.button1.Location = new System.Drawing.Point(12, 12);
|
||||||
@@ -139,15 +147,15 @@ namespace WindowsFormsApp1.form
|
|||||||
this.查询.UseVisualStyleBackColor = true;
|
this.查询.UseVisualStyleBackColor = true;
|
||||||
this.查询.Click += new System.EventHandler(this.查询_Click);
|
this.查询.Click += new System.EventHandler(this.查询_Click);
|
||||||
//
|
//
|
||||||
// 保存
|
// 清空
|
||||||
//
|
//
|
||||||
this.保存.Location = new System.Drawing.Point(174, 12);
|
this.清空.Location = new System.Drawing.Point(174, 12);
|
||||||
this.保存.Name = "保存";
|
this.清空.Name = "清空";
|
||||||
this.保存.Size = new System.Drawing.Size(75, 23);
|
this.清空.Size = new System.Drawing.Size(75, 23);
|
||||||
this.保存.TabIndex = 3;
|
this.清空.TabIndex = 3;
|
||||||
this.保存.Text = "保存";
|
this.清空.Text = "清空";
|
||||||
this.保存.UseVisualStyleBackColor = true;
|
this.清空.UseVisualStyleBackColor = true;
|
||||||
this.保存.Click += new System.EventHandler(this.保存_Click);
|
this.清空.Click += new System.EventHandler(this.清空_Click);
|
||||||
//
|
//
|
||||||
// 关闭
|
// 关闭
|
||||||
//
|
//
|
||||||
@@ -159,13 +167,24 @@ namespace WindowsFormsApp1.form
|
|||||||
this.关闭.UseVisualStyleBackColor = true;
|
this.关闭.UseVisualStyleBackColor = true;
|
||||||
this.关闭.Click += new System.EventHandler(this.关闭_Click);
|
this.关闭.Click += new System.EventHandler(this.关闭_Click);
|
||||||
//
|
//
|
||||||
|
// 导入
|
||||||
|
//
|
||||||
|
this.导入.Location = new System.Drawing.Point(336, 12);
|
||||||
|
this.导入.Name = "导入";
|
||||||
|
this.导入.Size = new System.Drawing.Size(75, 23);
|
||||||
|
this.导入.TabIndex = 5;
|
||||||
|
this.导入.Text = "导入";
|
||||||
|
this.导入.UseVisualStyleBackColor = true;
|
||||||
|
this.导入.Click += new System.EventHandler(this.导入_Click);
|
||||||
|
//
|
||||||
// OEEaddress_Manage
|
// OEEaddress_Manage
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(1068, 450);
|
this.ClientSize = new System.Drawing.Size(1210, 450);
|
||||||
|
this.Controls.Add(this.导入);
|
||||||
this.Controls.Add(this.关闭);
|
this.Controls.Add(this.关闭);
|
||||||
this.Controls.Add(this.保存);
|
this.Controls.Add(this.清空);
|
||||||
this.Controls.Add(this.查询);
|
this.Controls.Add(this.查询);
|
||||||
this.Controls.Add(this.button1);
|
this.Controls.Add(this.button1);
|
||||||
this.Controls.Add(this.dataGridView1);
|
this.Controls.Add(this.dataGridView1);
|
||||||
@@ -182,17 +201,18 @@ namespace WindowsFormsApp1.form
|
|||||||
private System.Windows.Forms.DataGridView dataGridView1;
|
private System.Windows.Forms.DataGridView dataGridView1;
|
||||||
private System.Windows.Forms.Button button1;
|
private System.Windows.Forms.Button button1;
|
||||||
private System.Windows.Forms.Button 查询;
|
private System.Windows.Forms.Button 查询;
|
||||||
private System.Windows.Forms.Button 保存;
|
private System.Windows.Forms.Button 清空; // 将保存改为清空
|
||||||
private System.Windows.Forms.Button 关闭;
|
private System.Windows.Forms.Button 关闭;
|
||||||
|
private System.Windows.Forms.Button 导入;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn id;
|
private System.Windows.Forms.DataGridViewTextBoxColumn id;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn plcid;
|
private System.Windows.Forms.DataGridViewTextBoxColumn plcid;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn code;
|
private System.Windows.Forms.DataGridViewTextBoxColumn code;
|
||||||
private System.Windows.Forms.DataGridViewComboBoxColumn type;
|
private System.Windows.Forms.DataGridViewComboBoxColumn type;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress;
|
private System.Windows.Forms.DataGridViewTextBoxColumn dbaddress;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn plcname;
|
|
||||||
private System.Windows.Forms.DataGridViewComboBoxColumn addresstype;
|
private System.Windows.Forms.DataGridViewComboBoxColumn addresstype;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn addresstypelegth;
|
private System.Windows.Forms.DataGridViewTextBoxColumn addresstypelegth;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset;
|
private System.Windows.Forms.DataGridViewTextBoxColumn addressoffset;
|
||||||
private System.Windows.Forms.DataGridViewTextBoxColumn addressdecimal;
|
private System.Windows.Forms.DataGridViewTextBoxColumn addressdecimal;
|
||||||
|
private System.Windows.Forms.DataGridViewTextBoxColumn remark;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
@@ -24,28 +24,6 @@ namespace WindowsFormsApp1.form
|
|||||||
GetInfo();
|
GetInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void 保存_Click(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
|
|
||||||
var result = sQLiteHelper.UpdateAll((List<t_oeeaddress>)dataGridView1.DataSource);
|
|
||||||
if (result.Success)
|
|
||||||
{
|
|
||||||
MessageBox.Show("更新成功");
|
|
||||||
GetInfo();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
MessageBox.Show("更新失败");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
MessageBox.Show($"更新失败,错误原因{ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void 关闭_Click(object sender, EventArgs e)
|
private void 关闭_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
this.Close();
|
this.Close();
|
||||||
@@ -85,7 +63,7 @@ namespace WindowsFormsApp1.form
|
|||||||
comboBoxColumn.DisplayMember = "name";
|
comboBoxColumn.DisplayMember = "name";
|
||||||
comboBoxColumn.ValueMember = "value";
|
comboBoxColumn.ValueMember = "value";
|
||||||
|
|
||||||
comboBoxColumn.DataPropertyName = "type";
|
comboBoxColumn.DataPropertyName = "type";
|
||||||
|
|
||||||
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
|
var comboBoxColumn1 = (DataGridViewComboBoxColumn)dataGridView1.Columns[5];
|
||||||
// 绑定数据源到 ComboBox
|
// 绑定数据源到 ComboBox
|
||||||
@@ -114,10 +92,10 @@ namespace WindowsFormsApp1.form
|
|||||||
dataGridView1.CellContentClick += DataGridView1_CellContentClick;
|
dataGridView1.CellContentClick += DataGridView1_CellContentClick;
|
||||||
|
|
||||||
dataGridView1.Columns.Add(deleteColumn);
|
dataGridView1.Columns.Add(deleteColumn);
|
||||||
|
|
||||||
GetInfo();
|
GetInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
private void DataGridView1_CellContentClick(object sender, DataGridViewCellEventArgs e)
|
||||||
{
|
{
|
||||||
// 检查点击的是否为按钮列
|
// 检查点击的是否为按钮列
|
||||||
@@ -127,7 +105,7 @@ namespace WindowsFormsApp1.form
|
|||||||
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
DataGridViewRow row = dataGridView.Rows[e.RowIndex];
|
||||||
|
|
||||||
int selectid = int.Parse(row.Cells[0].Value.ToString());
|
int selectid = int.Parse(row.Cells[0].Value.ToString());
|
||||||
if (e.ColumnIndex == 9)
|
if (e.ColumnIndex == 10)
|
||||||
{
|
{
|
||||||
OEEaddress_Insert oeeInsert = new OEEaddress_Insert();
|
OEEaddress_Insert oeeInsert = new OEEaddress_Insert();
|
||||||
oeeInsert.dataid = selectid;
|
oeeInsert.dataid = selectid;
|
||||||
@@ -135,7 +113,7 @@ namespace WindowsFormsApp1.form
|
|||||||
oeeInsert.ShowDialog();
|
oeeInsert.ShowDialog();
|
||||||
GetInfo();
|
GetInfo();
|
||||||
}
|
}
|
||||||
else if (e.ColumnIndex == 10)
|
else if (e.ColumnIndex == 11)
|
||||||
{
|
{
|
||||||
DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
DialogResult result = MessageBox.Show("你确定要删除数据吗?", "确认提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
|
||||||
|
|
||||||
@@ -156,7 +134,7 @@ namespace WindowsFormsApp1.form
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetInfo()
|
public void GetInfo()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@@ -200,5 +178,219 @@ namespace WindowsFormsApp1.form
|
|||||||
oeeInsert.ShowDialog();
|
oeeInsert.ShowDialog();
|
||||||
GetInfo();
|
GetInfo();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 添加导入按钮点击事件处理
|
||||||
|
private void 导入_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
OpenFileDialog openFileDialog = new OpenFileDialog();
|
||||||
|
openFileDialog.Filter = "CSV文件|*.csv";
|
||||||
|
openFileDialog.Title = "选择要导入的CSV文件";
|
||||||
|
|
||||||
|
if (openFileDialog.ShowDialog() == DialogResult.OK)
|
||||||
|
{
|
||||||
|
string filePath = openFileDialog.FileName;
|
||||||
|
ImportFromCSV(filePath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"导入失败,错误原因:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void ImportFromCSV(string filePath)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
List<t_oeeaddress> addressList = new List<t_oeeaddress>();
|
||||||
|
|
||||||
|
// 读取CSV文件 - 修改编码方式
|
||||||
|
// 尝试使用UTF-8编码读取
|
||||||
|
string[] lines = System.IO.File.ReadAllLines(filePath, Encoding.UTF8);
|
||||||
|
|
||||||
|
// 如果检测到乱码,可以尝试其他编码
|
||||||
|
if (ContainsGarbledText(lines))
|
||||||
|
{
|
||||||
|
// 尝试使用GB2312编码
|
||||||
|
lines = System.IO.File.ReadAllLines(filePath, Encoding.GetEncoding("gb2312"));
|
||||||
|
|
||||||
|
// 如果仍然乱码,再尝试其他编码
|
||||||
|
if (ContainsGarbledText(lines))
|
||||||
|
{
|
||||||
|
// 尝试使用GBK编码
|
||||||
|
lines = System.IO.File.ReadAllLines(filePath, Encoding.GetEncoding("gbk"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 从第2行开始读取数据(假设第1行是标题)
|
||||||
|
for (int i = 1; i < lines.Length; i++)
|
||||||
|
{
|
||||||
|
string line = lines[i];
|
||||||
|
if (string.IsNullOrWhiteSpace(line))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// 分割CSV行并去除双引号
|
||||||
|
string[] values = SplitCsvLineAndRemoveQuotes(line);
|
||||||
|
|
||||||
|
if (values.Length < 10)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"第{i + 1}行数据格式不正确,请检查CSV文件格式");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
var test = values[0];
|
||||||
|
try
|
||||||
|
{
|
||||||
|
t_oeeaddress address = new t_oeeaddress
|
||||||
|
{
|
||||||
|
plcid = Convert.ToInt32(values[0]),
|
||||||
|
code = values[1],
|
||||||
|
type = values[2],
|
||||||
|
dbaddress = values[3],
|
||||||
|
addresstype = values[4],
|
||||||
|
addresstypelegth = Convert.ToInt32(values[5]),
|
||||||
|
addressoffset = Convert.ToInt32(values[6]),
|
||||||
|
addressdecimal = Convert.ToInt32(values[7]),
|
||||||
|
remark = values[8] ?? "",
|
||||||
|
};
|
||||||
|
|
||||||
|
addressList.Add(address);
|
||||||
|
}
|
||||||
|
catch (FormatException)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"第{i + 1}行数据格式转换错误,请检查数据类型是否正确");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
SaveImportedData(addressList);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"CSV导入失败,错误原因:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加一个方法来分割CSV行并去除双引号
|
||||||
|
private string[] SplitCsvLineAndRemoveQuotes(string line)
|
||||||
|
{
|
||||||
|
// 使用正则表达式处理CSV,考虑引号内的逗号
|
||||||
|
List<string> result = new List<string>();
|
||||||
|
bool inQuotes = false;
|
||||||
|
StringBuilder field = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < line.Length; i++)
|
||||||
|
{
|
||||||
|
char c = line[i];
|
||||||
|
|
||||||
|
if (c == '"')
|
||||||
|
{
|
||||||
|
// 如果是引号,切换引号状态
|
||||||
|
inQuotes = !inQuotes;
|
||||||
|
// 不将引号添加到结果中
|
||||||
|
}
|
||||||
|
else if (c == ',' && !inQuotes)
|
||||||
|
{
|
||||||
|
// 如果是逗号且不在引号内,则添加当前字段并重置
|
||||||
|
result.Add(field.ToString().Trim());
|
||||||
|
field.Clear();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// 其他字符直接添加
|
||||||
|
field.Append(c);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加最后一个字段
|
||||||
|
result.Add(field.ToString().Trim());
|
||||||
|
|
||||||
|
return result.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// 添加一个辅助方法检测文本是否包含乱码
|
||||||
|
private bool ContainsGarbledText(string[] lines)
|
||||||
|
{
|
||||||
|
// 简单检测:如果包含特定的乱码字符,则认为是乱码
|
||||||
|
// 这里只是一个简单的示例,可能需要根据实际情况调整
|
||||||
|
string pattern = @"[\u0000-\u001F\u007F-\u009F]"; // 控制字符
|
||||||
|
|
||||||
|
foreach (string line in lines)
|
||||||
|
{
|
||||||
|
if (System.Text.RegularExpressions.Regex.IsMatch(line, pattern))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SaveImportedData(List<t_oeeaddress> addressList)
|
||||||
|
{
|
||||||
|
if (addressList.Count == 0)
|
||||||
|
{
|
||||||
|
MessageBox.Show("没有有效数据可导入");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
|
||||||
|
var result = sQLiteHelper.InsertAll(addressList);
|
||||||
|
|
||||||
|
if (result.Success)
|
||||||
|
{
|
||||||
|
// 更新缓存
|
||||||
|
var allAddresses = sQLiteHelper.QueryAll();
|
||||||
|
if (allAddresses.Success)
|
||||||
|
{
|
||||||
|
Init.t_Oeeaddresses = allAddresses.Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
MessageBox.Show($"成功导入{addressList.Count}条数据");
|
||||||
|
GetInfo(); // 刷新数据显示
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show($"导入失败:{result.Msg}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"保存导入数据失败,错误原因:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// 添加清空按钮点击事件处理
|
||||||
|
private void 清空_Click(object sender, EventArgs e)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
DialogResult result = MessageBox.Show("确定要删除所有数据吗?此操作不可恢复!", "警告",
|
||||||
|
MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
|
||||||
|
|
||||||
|
if (result == DialogResult.OK)
|
||||||
|
{
|
||||||
|
SQLiteHelper<t_oeeaddress> sQLiteHelper = new db.SQLiteHelper<t_oeeaddress>();
|
||||||
|
var deleteResult = sQLiteHelper.DeleteAll();
|
||||||
|
|
||||||
|
if (deleteResult.Success)
|
||||||
|
{
|
||||||
|
MessageBox.Show("所有数据已成功删除!");
|
||||||
|
GetInfo(); // 刷新数据显示
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
MessageBox.Show($"删除失败:{deleteResult.Msg}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
MessageBox.Show($"清空数据失败,错误原因:{ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -107,6 +107,13 @@ namespace WindowsFormsApp1.form
|
|||||||
var result = sQLiteHelper.Update(t_Oeeaddress);
|
var result = sQLiteHelper.Update(t_Oeeaddress);
|
||||||
if (result.Success)
|
if (result.Success)
|
||||||
{
|
{
|
||||||
|
// 更新缓存
|
||||||
|
var cacheIndex = Init.t_Oeeaddresses.FindIndex(x => x.id == dataid);
|
||||||
|
if (cacheIndex != -1)
|
||||||
|
{
|
||||||
|
Init.t_Oeeaddresses[cacheIndex] = t_Oeeaddress;
|
||||||
|
}
|
||||||
|
|
||||||
MessageBox.Show("修改成功");
|
MessageBox.Show("修改成功");
|
||||||
this.Close();
|
this.Close();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -80,6 +80,11 @@ namespace WindowsFormsApp1.mod.server
|
|||||||
public int plcid { get; set; }
|
public int plcid { get; set; }
|
||||||
|
|
||||||
public t_materialupload material { get; set; }
|
public t_materialupload material { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// oee
|
||||||
|
/// </summary>
|
||||||
|
public List<t_oeeaddress> Oeeaddresses { get; set; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -525,14 +525,14 @@ namespace WindowsFormsApp1.server
|
|||||||
else if ("ScrewE,Assy2,Assy3,ScrewS,ScrewM,ScrewTC".ToLower().Contains(station))
|
else if ("ScrewE,Assy2,Assy3,ScrewS,ScrewM,ScrewTC".ToLower().Contains(station))
|
||||||
{
|
{
|
||||||
// 扭力 读马头服务器
|
// 扭力 读马头服务器
|
||||||
var geturl = $"http://10.50.12.41/getdata/v2/tighteningresults?startTime={OtherData.material.date}&endTime={DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")}&vin={OtherData.material.sn}&controllerName={Init.t_Line.lineremark3}@{Init.t_Line.linecode}&includeCurve=true&includeSteps=false";
|
var geturl = $"http://10.50.12.41/getdata/v2/tighteningresults?startTime={OtherData.material.date}&endTime={DateTime.Now.AddDays(1).ToString("yyyy-MM-dd")}&vin={OtherData.material.sn}&controllerName={Init.t_Line.lineremark2}@{Init.t_Line.linecode}&includeCurve=true&includeSteps=false";
|
||||||
//var geturl = "http://10.50.12.41/getdata/v2/tighteningresults?startTime=2025-04-11&endTime=2025-04-12&vin=ok&controllerName=OP1260%4010.50.247.110&includeCurve=true&includeSteps=false";
|
//var geturl = "http://10.50.12.41/getdata/v2/tighteningresults?startTime=2025-04-11&endTime=2025-04-12&vin=ok&controllerName=OP1260%4010.50.247.110&includeCurve=true&includeSteps=false";
|
||||||
|
|
||||||
var res = _httpClient.GetAsync(geturl).Result;
|
var res = _httpClient.GetAsync(geturl).Result;
|
||||||
if (res.StatusCode == System.Net.HttpStatusCode.OK)
|
if (res.StatusCode == System.Net.HttpStatusCode.OK)
|
||||||
{
|
{
|
||||||
//var getresult = JsonConvert.DeserializeObject(res.Content.ReadAsStringAsync().Result);
|
//var getresult = JsonConvert.DeserializeObject(res.Content.ReadAsStringAsync().Result);
|
||||||
// 扭力 读马头服务器 todo
|
// 扭力 读马头服务器
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// 反序列化 JSON 数据
|
// 反序列化 JSON 数据
|
||||||
@@ -579,7 +579,7 @@ namespace WindowsFormsApp1.server
|
|||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
Console.WriteLine($"发生错误: {ex.Message}");
|
LogExecute.logNet.WriteError($"解析马头数据,发生错误: {ex.Message}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -890,7 +890,7 @@ namespace WindowsFormsApp1.server
|
|||||||
material = new t_materialupload
|
material = new t_materialupload
|
||||||
{
|
{
|
||||||
sn = PlcData.Write_stSN,
|
sn = PlcData.Write_stSN,
|
||||||
CarrierID = PlcData.Write_stSN,
|
CarrierID = PlcData.Read_MaterialCode1,
|
||||||
datacollectionUploaded = 1,
|
datacollectionUploaded = 1,
|
||||||
result = logresult,
|
result = logresult,
|
||||||
date = DateTime.Now.ToString("yyyy-MM-dd")
|
date = DateTime.Now.ToString("yyyy-MM-dd")
|
||||||
@@ -1082,6 +1082,63 @@ namespace WindowsFormsApp1.server
|
|||||||
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
return ApiFormResult.Sucess(mesresult.PASS, false, "", PlcData, DateTime.Now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ApiFormResult OEEDataCollection(string url, plcdata PlcData, otherdata OtherData)
|
||||||
|
{
|
||||||
|
var request = new
|
||||||
|
{
|
||||||
|
EventID = "OEEDataCollection",
|
||||||
|
Line = _line,
|
||||||
|
StationID = _stationID,
|
||||||
|
MachineID = _machineID,
|
||||||
|
OPID = _opID,
|
||||||
|
SN = PlcData.Write_stSN,
|
||||||
|
CarrierID = PlcData.Read_MaterialCode1,
|
||||||
|
DC_INFO = new List<DataDCInfoItem>(),
|
||||||
|
CompList = new List<CompListItem>(),
|
||||||
|
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
||||||
|
};
|
||||||
|
|
||||||
|
// 工位最长ct
|
||||||
|
request.DC_INFO.Add(new DataDCInfoItem()
|
||||||
|
{
|
||||||
|
Item = "Cycle_Time",
|
||||||
|
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == "uiMAXCT")?.value //跟PLC定义好值从哪里获取
|
||||||
|
});
|
||||||
|
|
||||||
|
// 机台ct
|
||||||
|
request.DC_INFO.Add(new DataDCInfoItem()
|
||||||
|
{
|
||||||
|
Item = "Takt_Time",
|
||||||
|
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == "uiNEWCT")?.value //跟PLC定义好值从哪里获取
|
||||||
|
});
|
||||||
|
|
||||||
|
var tossing = DataListManager.DataList.Any(x => x.Name == _stationID);
|
||||||
|
if (tossing)
|
||||||
|
{
|
||||||
|
var materialList = DataListManager.DataList.First(x => x.Name == _stationID).Components;
|
||||||
|
var num = 0;
|
||||||
|
foreach (var material in materialList)
|
||||||
|
{
|
||||||
|
request.DC_INFO.Add(
|
||||||
|
new DataDCInfoItem()
|
||||||
|
{
|
||||||
|
Item = $"Toss_Count_{material}",
|
||||||
|
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == $"uiUnloadingNG[{num}]")?.value //跟PLC定义好值从哪里获取
|
||||||
|
}
|
||||||
|
);
|
||||||
|
request.DC_INFO.Add(
|
||||||
|
new DataDCInfoItem()
|
||||||
|
{
|
||||||
|
Item = $"TossRate_{material}",
|
||||||
|
Value = OtherData.Oeeaddresses.FirstOrDefault(x => x.code == $"uiUnloadingNGX[{num}]")?.value //跟PLC定义好值从哪里获取
|
||||||
|
}
|
||||||
|
);
|
||||||
|
num++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return CallApi(url, request, "OEEDataCollection", PlcData, PLC_Status.OEEDataCollection);
|
||||||
|
}
|
||||||
#region 暂时不用
|
#region 暂时不用
|
||||||
public ApiFormResult Test(string url, plcdata PlcData, otherdata OtherData)
|
public ApiFormResult Test(string url, plcdata PlcData, otherdata OtherData)
|
||||||
{
|
{
|
||||||
@@ -1098,68 +1155,6 @@ namespace WindowsFormsApp1.server
|
|||||||
return CallApi(url, request, "Test", PlcData, PLC_Status.Test);
|
return CallApi(url, request, "Test", PlcData, PLC_Status.Test);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiFormResult OEEDataCollection(string url, plcdata PlcData, otherdata OtherData)
|
|
||||||
{
|
|
||||||
//模穴 真空站两个穴位
|
|
||||||
var model = 1;
|
|
||||||
|
|
||||||
if (_stationID.ToLower() == "vacuum")
|
|
||||||
{
|
|
||||||
model = OtherData.plcid;
|
|
||||||
}
|
|
||||||
|
|
||||||
var request = new
|
|
||||||
{
|
|
||||||
EventID = "OEEDataCollection",
|
|
||||||
Line = _line,
|
|
||||||
StationID = _stationID,
|
|
||||||
MachineID = _machineID,
|
|
||||||
OPID = _opID,
|
|
||||||
SN = PlcData.Write_stSN,
|
|
||||||
CarrierID = PlcData.Read_MaterialCode1,
|
|
||||||
DC_INFO = new List<DataDCInfoItem>(),
|
|
||||||
CompList = new List<CompListItem>(),
|
|
||||||
SendTime = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss")
|
|
||||||
};
|
|
||||||
request.DC_INFO.Add(new DataDCInfoItem()
|
|
||||||
{
|
|
||||||
Item = "Eq_Active_Rate",
|
|
||||||
Value = "0"
|
|
||||||
});
|
|
||||||
|
|
||||||
// 工位最长ct
|
|
||||||
request.DC_INFO.Add(new DataDCInfoItem()
|
|
||||||
{
|
|
||||||
Item = "Cycle_Time",
|
|
||||||
Value = "0" //跟PLC定义好值从哪里获取
|
|
||||||
});
|
|
||||||
|
|
||||||
// 机台ct
|
|
||||||
request.DC_INFO.Add(new DataDCInfoItem()
|
|
||||||
{
|
|
||||||
Item = "Takt_Time",
|
|
||||||
Value = "0" //跟PLC定义好值从哪里获取
|
|
||||||
});
|
|
||||||
|
|
||||||
var tossing = DataListManager.DataList.Any(x => x.Name == _stationID);
|
|
||||||
if (tossing)
|
|
||||||
{
|
|
||||||
var materialList = DataListManager.DataList.First(x => x.Name == _stationID).Components;
|
|
||||||
foreach(var material in materialList)
|
|
||||||
{
|
|
||||||
request.DC_INFO.Add(
|
|
||||||
new DataDCInfoItem()
|
|
||||||
{
|
|
||||||
Item = $"Tossing_{material}",
|
|
||||||
Value = "1" //跟PLC定义好值从哪里获取
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return CallApi(url, request, "OEEDataCollection", PlcData, PLC_Status.OEEDataCollection);
|
|
||||||
}
|
|
||||||
|
|
||||||
public ApiFormResult Get_Para(string url, plcdata PlcData, otherdata OtherData)
|
public ApiFormResult Get_Para(string url, plcdata PlcData, otherdata OtherData)
|
||||||
{
|
{
|
||||||
var request = new
|
var request = new
|
||||||
|
|||||||
@@ -689,7 +689,9 @@ namespace WindowsFormsApp1.server
|
|||||||
#region 读取报警
|
#region 读取报警
|
||||||
private BllResult ReadOneDB(List<t_oeeaddress> address)
|
private BllResult ReadOneDB(List<t_oeeaddress> address)
|
||||||
{
|
{
|
||||||
address = address.OrderBy(a => a.dbaddress).ToList();
|
address = address.OrderBy(a => a.dbaddress)
|
||||||
|
.ThenBy(x => x.addressoffset)
|
||||||
|
.ToList();
|
||||||
OperateResult<byte[]> read;
|
OperateResult<byte[]> read;
|
||||||
if (address.Count == 1)
|
if (address.Count == 1)
|
||||||
{
|
{
|
||||||
@@ -700,7 +702,7 @@ namespace WindowsFormsApp1.server
|
|||||||
{
|
{
|
||||||
double admax = address.Select(a => a.addressoffset).Max();
|
double admax = address.Select(a => a.addressoffset).Max();
|
||||||
double admin = address.Select(a => a.addressoffset).Min();
|
double admin = address.Select(a => a.addressoffset).Min();
|
||||||
ushort length = (ushort)(Math.Floor(admax - admin) + (ushort)address[0].addressdecimal);
|
ushort length = (ushort)(Math.Floor(admax - admin) + address.Last().addresstypelegth);
|
||||||
string startaddress = address[0].dbaddress + "." + admin.ToString();
|
string startaddress = address[0].dbaddress + "." + admin.ToString();
|
||||||
read = siemensS7Net.Read(startaddress, length);
|
read = siemensS7Net.Read(startaddress, length);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user