diff --git a/HighWayIot.Plc/PlcConnect.cs b/HighWayIot.Plc/PlcConnect.cs index ce57b0c..9da2a3a 100644 --- a/HighWayIot.Plc/PlcConnect.cs +++ b/HighWayIot.Plc/PlcConnect.cs @@ -7,6 +7,16 @@ namespace HighWayIot.Plc { public class PlcConnect { + private static readonly Lazy lazy = new Lazy(() => new PlcConnect()); + + public static PlcConnect Instance + { + get + { + return lazy.Value; + } + } + private static LogHelper logHelper = LogHelper.Instance; /// diff --git a/HighWayIot.Plc/PlcEntity/RgvStationEnum.cs b/HighWayIot.Plc/PlcEntity/RgvStationEnum.cs index ea801d8..34028ce 100644 --- a/HighWayIot.Plc/PlcEntity/RgvStationEnum.cs +++ b/HighWayIot.Plc/PlcEntity/RgvStationEnum.cs @@ -10,7 +10,7 @@ namespace HighWayIot.Plc.PlcEntity public enum RgvStationEnum { [Description("裝圈工位RIFD触发")] - RgvRingInstallStation = 1, + RgvRingInstallStation = 0, [Description("1#工位RIFD触发")] Rgv1Station, diff --git a/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs b/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs index 023b5fe..0d01c11 100644 --- a/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs +++ b/HighWayIot.Plc/PlcHelper/BasePlcHelper.cs @@ -8,5 +8,12 @@ namespace HighWayIot.Plc.PlcHelper { public class BasePlcHelper { + public PlcConnect PlcInstance = PlcConnect.Instance; + + public BasePlcHelper() + { + + } + } } diff --git a/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs new file mode 100644 index 0000000..9eec30d --- /dev/null +++ b/HighWayIot.Plc/PlcHelper/WorkStationHelper.cs @@ -0,0 +1,47 @@ +using HighWayIot.Plc.PlcEntity; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Plc.PlcHelper +{ + public class WorkStationHelper + { + /// + /// RFID10小车工位识别点位写入 + /// + /// + /// + public bool WriteStationSingal(RgvStationEnum rgvStation, int deviceNo) + { + int point = 0x600; + point += deviceNo * 32; + point += (int)rgvStation; + + bool result = PlcConnect.PlcWrite($"B{point.ToString("X")}", true, DataTypeEnum.Bool).IsSuccess; + + return result; + } + + /// + /// RFID固定工位识别点位读取 + /// + /// + /// + public bool[] ReadStationSingal() + { + bool[] result = new bool[17]; + + for (int i = 0x230; i <= 0x240; i++) + { + int j = 0; + result[j] = PlcConnect.ReadBool($"B{i.ToString("X")}"); + j++; + } + + return result; + } + } +} diff --git a/HighWayIot.Plc/PlcHelper/WorkStationWrite.cs b/HighWayIot.Plc/PlcHelper/WorkStationWrite.cs deleted file mode 100644 index df6c892..0000000 --- a/HighWayIot.Plc/PlcHelper/WorkStationWrite.cs +++ /dev/null @@ -1,22 +0,0 @@ -using HighWayIot.Plc.PlcEntity; -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace HighWayIot.Plc.PlcHelper -{ - public class WorkStationWrite - { - /// - /// RFID工位识别写入 - /// - /// - /// - public bool WriteStationSingal(RgvStationEnum rgvStation) - { - return false; - } - } -} diff --git a/HighWayIot.Winform/Business/WorkStationBusiness.cs b/HighWayIot.Winform/Business/WorkStationBusiness.cs new file mode 100644 index 0000000..4d6d0fb --- /dev/null +++ b/HighWayIot.Winform/Business/WorkStationBusiness.cs @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace HighWayIot.Winform.Business +{ + public class WorkStationBusiness + { + } +}