Commit 343e10fe authored by 潘栩锋's avatar 潘栩锋 🚴

添加 PLCProxySystem 可以没有 设置obj 也能读数据

parent 6b9fde5f
......@@ -88,12 +88,19 @@ namespace FLY.OBJComponents.Server
}
try
{
object obj = null;
if (this.ObjNames.Count()!=0)
{
if(!this.ObjNames.ContainsKey(var.OwnerName))
throw new Exception($"配置文件出错,不能找到 对象 {var.OwnerName}");
obj = this.ObjNames[var.OwnerName];
}
DataToRegs dr = plc.MapDataToRegs(
ModbusMapper.TranslateToPLCAddressArea(var.Mode),
var.Addr,
reg_type,
var.Scale,
this.ObjNames[var.OwnerName],
obj,
var.PropertyName,
var.RegAddr,
var.OwnerName);
......@@ -138,7 +145,6 @@ namespace FLY.OBJComponents.Server
obj.PropertyChanged += Obj_PropertyChanged;
}
FObjBase.PollModule.Current.Poll_Config(FObjBase.PollModule.POLL_CONFIG.ADD,
OnPoll_plans, TimeSpan.FromSeconds(1));
......@@ -226,7 +232,10 @@ namespace FLY.OBJComponents.Server
FObjBase.PollModule.Current.Dispatcher.Invoke(() =>
{
isShield = true;
Misc.PropertiesManager.SetValue(dr.owner, dr.propertyName, dr.value);
if (dr.owner != null)
{
Misc.PropertiesManager.SetValue(dr.owner, dr.propertyName, dr.value);
}
isShield = false;
});
}
......@@ -274,6 +283,38 @@ namespace FLY.OBJComponents.Server
}
/// <summary>
/// 全更新
/// </summary>
/// <param name="planID"></param>
public void SetPlanAll(long planID)
{
Plan plan = planIDs.Find(p => p.ID == planID);
if (plan == null)
{
plan = new Plan() { ID = planID, FeedTime = DateTime.Now };
planIDs.Add(plan);
}
else
{
plan.FeedTime = DateTime.Now;
}
List<DataToRegs> drs = DRMap;
foreach (DataToRegs dr in drs)
{
dr.mapper.PlanAdd(planID, dr);
if (!plan.mappers.Contains(dr.mapper))
plan.mappers.Add(dr.mapper);
}
foreach (var mapper in plan.mappers)
{
mapper.PlanMake();
}
}
long freeplanid = 1;
long GetFreePlanID()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment