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.
|
|
|
|
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 < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
var bo = context.GetBoolByIndex(i);
|
|
|
|
|
ls.Add(bo);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
for (var i = 0; i < 8; i++)
|
|
|
|
|
{
|
|
|
|
|
ls.Add(false);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|