using System.Collections.Generic; using HslCommunication; namespace DataBlockHelper.DBHelpers { public class Db3000Helper { public static List ReadDb() { List ls = new List(); var operateResult = PlcConnect.Instance.Read("DB3000.0.0", 1); if (operateResult.IsSuccess) { var context = operateResult.Content; for (var i = 0; i < 6; i++) { var bo = context.GetBoolByIndex(i); ls.Add(bo); } } else { for (var i = 0; i < 6; i++) { ls.Add(false); } } return ls; } /// /// 维修模式 是不是停机 /// /// public static List ReadModel() { List ls = new List(); var operateResult = PlcConnect.Instance.Read("DB3000.2.0", 1); if (operateResult.IsSuccess) { var context = operateResult.Content; for (var i = 0; i < 8; i++) { var bo = context.GetBoolByIndex(i); ls.Add(bo); } } else { for (var i = 0; i < 8; i++) { ls.Add(false); } } return ls; } public static void WriteModel(int no, bool b) { int id = no - 1; string address = $"DB3000.2.{id}"; PlcConnect.Instance.Write(address, b); } } }