浏览代码

数据模块更新

样式分支
pry 2 年前
父节点
当前提交
264f96188e
共有 2 个文件被更改,包括 28 次插入8 次删除
  1. +14
    -0
      BPASmart.Model/RedisDataModel.cs
  2. +14
    -8
      BPASmart.Server/CommunicationServer.cs

+ 14
- 0
BPASmart.Model/RedisDataModel.cs 查看文件

@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace BPASmart.Model
{
public class ReeisDataModel
{
public string VarName { get; set; }
public string VarVaule { get; set; }
}
}

+ 14
- 8
BPASmart.Server/CommunicationServer.cs 查看文件

@@ -83,9 +83,6 @@ namespace BPASmart.Server
}
}), $"{item.DeviceName} 初始化连接");
});



}

private void SetValue<TArray>(TArray[] arrays, string DeviceName, ReadDataModel readDataModel, ushort by)
@@ -101,14 +98,23 @@ namespace BPASmart.Server
int varIndex = Array.FindIndex(tempArray, p => p.RealAddress == readDataModel.StartAddress + (i * by));
if (varIndex >= 0 && varIndex < tempArray.Length)
{
var Devicename = Json<CommunicationPar>.Data.CommunicationDevices[index].DeviceName;
var varname = Json<CommunicationPar>.Data.CommunicationDevices[index].VarTableModels[varIndex].VarName;
RedisHelper.GetInstance.SetValue($"{Devicename}.{varname}", arrays[i]);

Json<CommunicationPar>.Data.CommunicationDevices.ElementAt(index).VarTableModels.ElementAt(varIndex).CurrentValue = arrays[i].ToString();
}
}

var Devicename = Json<CommunicationPar>.Data.CommunicationDevices[index].DeviceName;
List<ReeisDataModel> reeisDataModels = new List<ReeisDataModel>();
Json<CommunicationPar>.Data.CommunicationDevices[index].VarTableModels.ToList().ForEach(tempVar =>
{
if (tempVar.VarName.Length > 0)
{
reeisDataModels.Add(new ReeisDataModel()
{
VarName = tempVar.VarName,
VarVaule = tempVar.CurrentValue
});
}
});
RedisHelper.GetInstance.SetValue($"{Devicename}", reeisDataModels);
}
}
}


正在加载...
取消
保存