定时器采集数据

dep_yangw
我叫锄头 10 months ago
parent abc11778c7
commit 47dfdd4e50

@ -735,7 +735,7 @@ namespace ProductionSystem.Forms
public bool Over { get; set; } = false;
private CurveTool _curveTool = new CurveTool();
public void ToCache(Action action)
{
string name = GetCode() +":"+ action.Method.Name;
@ -819,6 +819,9 @@ namespace ProductionSystem.Forms
uyTool.Send();
_curveTool.Step = "BZ1";
_curveTool.Code = GetCode();
_curveTool.Start();
step.Id = Guid.NewGuid().ToString("N");
step.ReturnValue = uyTool.Val;
step.WriteValue = uyTool.Val;
@ -844,6 +847,8 @@ namespace ProductionSystem.Forms
PWMHelper.Close();
//清理状态
TmTool.CleanStatus();
_curveTool.Stop();
}
@ -894,6 +899,8 @@ namespace ProductionSystem.Forms
uyTool.closeSend();
TmTool.WritePlc(TmTool.ShuiBeng1, 0);
_curveTool.Stop();
}
XTrace.WriteLine("开始水泵2");
@ -931,6 +938,10 @@ namespace ProductionSystem.Forms
stepService.AddProductStep(step);
TmTool.WritePlc(TmTool.ShuiBeng2, 1);
_curveTool.Step = "BZ2";
_curveTool.Code = GetCode();
_curveTool.Start();
}
}
@ -959,6 +970,9 @@ namespace ProductionSystem.Forms
//水泵2关闭
_uxTool.closeSend();
TmTool.WritePlc(TmTool.ShuiBeng2, 0);
_curveTool.Stop();
}
if (D1004)
@ -980,6 +994,10 @@ namespace ProductionSystem.Forms
step.Ms = "0";
step.EquipmentName ="SB3ZS_DB";
stepService.AddProductStep(step);
_curveTool.Step = "BZ3";
_curveTool.Code = GetCode();
_curveTool.Start();
}
@ -1241,14 +1259,14 @@ namespace ProductionSystem.Forms
GetPlc(Program.BZ8, "BZ8");
Collect("BZ1");
Collect("BZ2");
Collect("BZ3");
Collect("BZ4");
Collect("BZ5");
Collect("BZ6");
Collect("BZ7");
Collect("BZ8");
// Collect("BZ1");
// Collect("BZ2");
// Collect("BZ3");
// Collect("BZ4");
// Collect("BZ5");
// Collect("BZ6");
// Collect("BZ7");
// Collect("BZ8");
SetMiddleData("BZ1_DB");
SetMiddleData("BZ2_DB");
@ -1267,24 +1285,24 @@ namespace ProductionSystem.Forms
}
private TResult2Service _result2Service = new TResult2Service();
private void Collect(string par)
{
var tagDict = GetTagDict();
var entity =
Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == tagDict[par]);
if (entity != null)
{
string productBarCode = GetCode();
var value = OmronHelper.GetPlcVal(entity.DataType, entity.Address);
if (value.Item2.ToDouble().ToInt() == 1)
{
}
}
}
// private void Collect(string par)
// {
// var tagDict = GetTagDict();
// var entity =
// Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == tagDict[par]);
// if (entity != null)
// {
// string productBarCode = GetCode();
//
// var value = OmronHelper.GetPlcVal(entity.DataType, entity.Address);
// if (value.Item2.ToDouble().ToInt() == 1)
// {
//
//
//
// }
// }
// }
public string GetPlcValue(string key)
{
@ -1299,7 +1317,7 @@ namespace ProductionSystem.Forms
}
public bool D1004
private bool D1004
{
get
{
@ -1966,45 +1984,7 @@ namespace ProductionSystem.Forms
Program.MiddlePointKeyValues.ForEach(m => m.Val = "");
}
/// <summary>
/// 初始化曲线区域数据
/// </summary>
private void InitCurveSectionData()
{
//曲线区域的开始索引
sectionStartIndex1 = 0;
sectionStartIndex2 = 0;
sectionStartIndex3 = 0;
sectionStartIndex4 = 0;
sectionStartIndex5 = 0;
sectionStartIndex6 = 0;
sectionStartIndex7 = 0;
sectionStartIndex8 = 0;
sectionStartIndex9 = 0;
//曲线区域的结束索引
sectionEndIndex1 = -1;
sectionEndIndex2 = -1;
sectionEndIndex3 = -1;
sectionEndIndex4 = -1;
sectionEndIndex5 = -1;
sectionEndIndex6 = -1;
sectionEndIndex7 = -1;
sectionEndIndex8 = -1;
sectionEndIndex9 = -1;
stepName1 = "";
stepName2 = "";
stepName3 = "";
stepName4 = "";
stepName5 = "";
stepName6 = "";
stepName7 = "";
stepName8 = "";
stepName9 = "";
stepChangeCount = 0;//步序变化次数
tempStepNum = 0;//临时存储步序号
}
/// <summary>
/// 心跳监测

@ -422,6 +422,7 @@
<Compile Include="Untils\System\BindDropDownHelper.cs" />
<Compile Include="Untils\System\CustomMessageBoxHelper.cs" />
<Compile Include="Untils\System\RegexCheckHelper.cs" />
<Compile Include="Untils\Tool\CurveTool.cs" />
<Compile Include="Untils\Tool\ExvTool.cs" />
<Compile Include="Untils\Tool\SitongTool.cs" />
<Compile Include="Untils\Tool\StateTool.cs" />

@ -0,0 +1,68 @@
using System;
using System.ComponentModel.Design;
using System.Linq;
using Custom.Communication.Framework.MyPlc;
using NewLife.Log;
using NewLife.Threading;
using ProductionSystem_Model.DbModel;
using ProductionSystem_Service;
namespace ProductionSystem.Untils.Tool
{
public class CurveTool
{
/// <summary>
/// 模式1
/// </summary>
public string Step { get; set; }
public string Code { get; set; }
private TimerX _timer;
public void Start()
{
_timer= new TimerX(DoBackup,"", 100, 200) { Async = true };
}
public void Stop()
{
_timer.Dispose();
_timer = null;
}
TCurveService tc = new TCurveService();
//D1252 电压 D1250 电流
private void DoBackup(Object state)
{
XTrace.WriteLine("电流采集");
T_Curve step=new T_Curve
{
Id=Guid.NewGuid().ToString("N"),
ProductType = Program.ProductType,
ProductBarcode = Code,
CreateTime = DateTime.Now,
Step = Step,
Voltage = GetPlcValue("D1252"),
Electricity = GetPlcValue("D1250")
};
tc.AddTResult2(step);
}
private string GetPlcValue(string key)
{
var entity= Program.CommandPointKeyValues.FirstOrDefault(m => m.Key == key);
if (entity != null)
{
return OmronHelper.GetPlcVal(entity.DataType, entity.Address).val;
}
return "";
}
}
}
Loading…
Cancel
Save