Browse Source

数据模块更新

样式分支
pry 2 years ago
parent
commit
264f96188e
2 changed files with 28 additions and 8 deletions
  1. +14
    -0
      BPASmart.Model/RedisDataModel.cs
  2. +14
    -8
      BPASmart.Server/CommunicationServer.cs

+ 14
- 0
BPASmart.Model/RedisDataModel.cs View File

@@ -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 View File

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



} }


private void SetValue<TArray>(TArray[] arrays, string DeviceName, ReadDataModel readDataModel, ushort by) 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)); int varIndex = Array.FindIndex(tempArray, p => p.RealAddress == readDataModel.StartAddress + (i * by));
if (varIndex >= 0 && varIndex < tempArray.Length) 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(); 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);
} }
} }
} }


Loading…
Cancel
Save