From 152a0224fbca38e44b8d5e82291bec3b0b3eab4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=88=91=E5=8F=AB=E9=94=84=E5=A4=B4?= Date: Sat, 2 Dec 2023 12:28:25 +0800 Subject: [PATCH] Db2119WriteHelper --- .../DBHelpers/DB2119WriteHelper.cs | 197 ++++++++++++++++++ DataBlockHelper/DataBlockHelper.csproj | 1 + 2 files changed, 198 insertions(+) create mode 100644 DataBlockHelper/DBHelpers/DB2119WriteHelper.cs diff --git a/DataBlockHelper/DBHelpers/DB2119WriteHelper.cs b/DataBlockHelper/DBHelpers/DB2119WriteHelper.cs new file mode 100644 index 0000000..3b906d5 --- /dev/null +++ b/DataBlockHelper/DBHelpers/DB2119WriteHelper.cs @@ -0,0 +1,197 @@ +namespace DataBlockHelper.DBHelpers +{ + public class Db2119WriteHelper + { + private static readonly string DbName = "DB2119"; + private static readonly int HaNo = 106; + public static readonly int HbNo = 114; + private static readonly int CaNo = 122; + private static readonly int CbNo = 130; + + + #region 添加方法Ha + + + public static void AddHaAddValue(short value) + { + AddValue(value, HaNo); + } + + public static void AddHaAddRemainValue(short value) + { + AddRemainValue(value, HaNo); + } + + public static void AddHaAddForceBin(short value) + { + AddForceBin(value, HaNo); + } + + public static void AddHaAddForceOn(bool value) + { + AddForceOn(value, HaNo); + } + + + public static void AddHaAddStartIn(bool value) + { + AddStartIn(value, HaNo); + } + + public static void AddHaAddStartOut(bool value) + { + AddStartOut(value, HaNo); + } + #endregion + + #region Hb 添加方法 + + + public static void AddHbAddValue(short value) + { + AddValue(value, HbNo); + } + + public static void AddHbAddRemainValue(short value) + { + AddRemainValue(value, HbNo); + } + + public static void AddHbAddForceBin(short value) + { + AddForceBin(value, HbNo); + } + + public static void AddHbAddForceOn(bool value) + { + AddForceOn(value, HbNo); + } + + + public static void AddHbAddStartIn(bool value) + { + AddStartIn(value, HbNo); + } + + public static void AddHbAddStartOut(bool value) + { + AddStartOut(value, HbNo); + } + #endregion + + #region Ca 添加方法 + + + public static void AddCaAddValue(short value) + { + AddValue(value, CaNo); + } + + public static void AddCaAddRemainValue(short value) + { + AddRemainValue(value, CaNo); + } + + public static void AddCaAddForceBin(short value) + { + AddForceBin(value, CaNo); + } + + public static void AddCaAddForceOn(bool value) + { + AddForceOn(value, CaNo); + } + + + public static void AddCaAddStartIn(bool value) + { + AddStartIn(value, CaNo); + } + + public static void AddCaAddStartOut(bool value) + { + AddStartOut(value, CaNo); + } + #endregion + + #region Cb 添加方法 + + + + + public static void AddCbAddValue(short value) + { + AddValue(value, CbNo); + } + + public static void AddCbAddRemainValue(short value) + { + AddRemainValue(value, CbNo); + } + + public static void AddCbAddForceBin(short value) + { + AddForceBin(value, CbNo); + } + + public static void AddCbAddForceOn(bool value) + { + AddForceOn(value, CbNo); + } + + + public static void AddCbAddStartIn(bool value) + { + AddStartIn(value, CbNo); + } + + public static void AddCbAddStartOut(bool value) + { + AddStartOut(value, CbNo); + } + #endregion + + + private static void AddValue(short value, int start) + { + //106 + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.{start}.0",value); + } + + private static void AddRemainValue(short value, int start) + { + int nu = start + 2; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.{nu}.0",value); + } + + private static void AddForceBin(short value, int start) + { + int nu = start + 4; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.{nu}.0",value); + } + + private static void AddForceOn(bool value, int start) + { + int nu = start + 6; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.{nu}.0",value); + } + + private static void AddStartIn(bool value, int start) + { + int nu = start + 6; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.{nu}.1",value); + } + + private static void AddStartOut(bool value, int start) + { + int nu = start + 6; + var siemensS7Net = PlcConnect.Instance; + siemensS7Net.Write($"{DbName}.{nu}.2",value); + } + } +} \ No newline at end of file diff --git a/DataBlockHelper/DataBlockHelper.csproj b/DataBlockHelper/DataBlockHelper.csproj index 8497862..90054c7 100644 --- a/DataBlockHelper/DataBlockHelper.csproj +++ b/DataBlockHelper/DataBlockHelper.csproj @@ -57,6 +57,7 @@ +