|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using DataBlockHelper.Entity.DB2104Entity;
|
|
|
|
|
|
|
|
|
|
namespace DataBlockHelper.DBHelpers
|
|
|
|
|
{
|
|
|
|
|
public class Db2104WriteHelper
|
|
|
|
|
{
|
|
|
|
|
private static readonly string DbName = "DB2104";
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 写入水 写入集合顺序 A热水 B热水 冷水A 冷水B
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ls"></param>
|
|
|
|
|
public static bool Write(List<WaterEntity> ls)
|
|
|
|
|
{
|
|
|
|
|
int start = 3578;
|
|
|
|
|
for (int i = 0; i < ls.Count; i++)
|
|
|
|
|
{
|
|
|
|
|
int no = start + (i * 10);
|
|
|
|
|
Write(no, ls[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// A热水
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
|
|
|
|
|
|
public static void WriteAHostWater(WaterEntity entity)
|
|
|
|
|
{
|
|
|
|
|
Write(3578, entity);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// B热水
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
|
public static void WriteBHostWater(WaterEntity entity)
|
|
|
|
|
{
|
|
|
|
|
Write(3588, entity);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 冷水A
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
|
public static void WriteAColWater(WaterEntity entity)
|
|
|
|
|
{
|
|
|
|
|
Write(3598, entity);
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 冷水B
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="entity"></param>
|
|
|
|
|
public static void WriteBColWater(WaterEntity entity)
|
|
|
|
|
{
|
|
|
|
|
Write(3608, entity);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void Write(int start, WaterEntity entity)
|
|
|
|
|
{
|
|
|
|
|
var siemensS7Net = PlcConnect.Instance;
|
|
|
|
|
siemensS7Net.Write($"{DbName}.{start}.0", entity.Bin);
|
|
|
|
|
siemensS7Net.Write($"{DbName}.{start+2}.0", entity.Set);
|
|
|
|
|
siemensS7Net.Write($"{DbName}.{start+6}.0", entity.Tolerance);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|