dep_yangw
我叫锄头 10 months ago
parent 8b7a232a7d
commit 9daae8c89d

@ -639,20 +639,7 @@ namespace ProductionSystem.Forms
Thread.Sleep(Program.ReadPlcRate);
XTrace.WriteLine("开始步骤1");
Step1();
XTrace.WriteLine("开始步骤2");
Step2();
XTrace.WriteLine("开始步骤3");
Step3();
XTrace.WriteLine("开始步骤4");
Step4();
XTrace.WriteLine("开始步骤5");
Step5();
XTrace.WriteLine("开始步骤6");
Step6();
XTrace.WriteLine("开始步骤7");
Step7();
//自动模式 如果是手动模式就是false
if (D1004)
@ -753,7 +740,7 @@ namespace ProductionSystem.Forms
string name = GetCode() + action.Method.Name;
if (!_cache.ContainsKey(name))
{
_cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(5));
_cache.Set(name, DateTime.Now, TimeSpan.FromMinutes(10));
action();
}
}
@ -772,7 +759,7 @@ namespace ProductionSystem.Forms
{
//上位机将四通阀运行到模式1启动水泵1运行致设定转速反馈PLC=1或2可以/不可以测试)
EquipmentCacheManager.Init(GetCode());
// EquipmentCacheManager.Init(GetCode());
var ba = ModeTypeEnum.BZ1_DB;
@ -876,6 +863,8 @@ namespace ProductionSystem.Forms
uyTool.closeSend();
TmTool.WritePlc(TmTool.ShuiBeng1, 0);
XTrace.WriteLine("开始水泵2");
// Thread.Sleep(100);
@ -909,8 +898,6 @@ namespace ProductionSystem.Forms
step.EquipmentName =eqName;
stepService.AddProductStep(step);
TmTool.WritePlc(TmTool.ShuiBeng2, 1);

@ -1,70 +1,70 @@
using DevExpress.XtraEditors;
using NewLife.Caching;
using ProductionSystem_Model.Enum;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProductionSystem.Untils
{
public class EquipmentCacheManager
{
static ICache cache=Cache.Default;
public static void Init(string code)
{
cache.Remove(code);
cache.Set(code, new Dictionary<string, string>(), TimeSpan.FromMinutes(20));
}
public static void Add(string code,EquipmentEnum equipmentEnum, string value)
{
if(!cache.ContainsKey(code))
{
Init(code);
}
var dic = cache[code] as Dictionary<string, string>;
dic[equipmentEnum.ToString()] = value;
}
public static string GetCode(string code, EquipmentEnum equipmentEnum)
{
var dic = cache[code] as Dictionary<string, string>;
if (null == dic) return "-1";
if (dic.TryGetValue(equipmentEnum.ToString(), out var value))
{
return value;
}
return "-1";
}
public static void Remove(string code)
{
cache.Remove(code);
}
public static void CleanKey(string code)
{
var list= cache.Keys;
foreach (var item in list)
{
if (item != code)
{
Remove(item);
}
}
}
}
}
// using DevExpress.XtraEditors;
//
// using NewLife.Caching;
//
// using ProductionSystem_Model.Enum;
//
// using SqlSugar;
//
// using System;
// using System.Collections.Generic;
// using System.Linq;
// using System.Text;
// using System.Threading.Tasks;
//
// namespace ProductionSystem.Untils
// {
// public class EquipmentCacheManager
// {
// static ICache cache=Cache.Default;
//
//
// public static void Init(string code)
// {
// cache.Remove(code);
// cache.Set(code, new Dictionary<string, string>(), TimeSpan.FromMinutes(20));
// }
//
// public static void Add(string code,EquipmentEnum equipmentEnum, string value)
// {
// if(!cache.ContainsKey(code))
// {
// Init(code);
// }
// var dic = cache[code] as Dictionary<string, string>;
// dic[equipmentEnum.ToString()] = value;
//
// }
//
//
// public static string GetCode(string code, EquipmentEnum equipmentEnum)
// {
// var dic = cache[code] as Dictionary<string, string>;
// if (null == dic) return "-1";
// if (dic.TryGetValue(equipmentEnum.ToString(), out var value))
// {
// return value;
// }
// return "-1";
//
// }
//
// public static void Remove(string code)
// {
// cache.Remove(code);
// }
//
// public static void CleanKey(string code)
// {
// var list= cache.Keys;
// foreach (var item in list)
// {
// if (item != code)
// {
// Remove(item);
// }
// }
// }
//
// }
// }

@ -169,24 +169,10 @@ namespace ProductionSystem.Untils.Tool
}
SitongTool sitongTool = new SitongTool(stf1.Com, val);
bool b = false;
string cachevalue=EquipmentCacheManager.GetCode(step.ProductBarcode, eq);
if (cachevalue.ToDouble().ToInt() !=val)
{
b = sitongTool.ToAction();
sitongTool.Dispose();
if (b)
{
EquipmentCacheManager.Add(step.ProductBarcode, eq, sitongTool.Val);
}
}
else
{
sitongTool.Val = cachevalue;
}
var b = sitongTool.ToAction();
sitongTool.Dispose();
stopwatch.Stop();
step.Id = Guid.NewGuid().ToString("N");
step.ReturnValue = sitongTool.Val;

Loading…
Cancel
Save