You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
lj_plc/DataBlockHelper/DBHelpers/Db3000Helper.cs

62 lines
1.5 KiB
C#

using System.Collections.Generic;
using HslCommunication;
namespace DataBlockHelper.DBHelpers
{
public class Db3000Helper
{
public static List<bool> ReadDb()
{
List<bool> ls = new List<bool>();
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);
}
}
return ls;
}
/// <summary>
/// 维修模式 是不是停机
/// </summary>
/// <returns></returns>
public static List<bool> ReadModel() {
List<bool> ls = new List<bool>();
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);
}
}
return ls;
}
public static void WriteModel(int no,bool b)
{
int id = no - 1;
string address = $"DB3000.2.{id}";
PlcConnect.Instance.Write(address,b);
}
}
}