using DataBlockHelper;
using HslCommunication.Profinet.Siemens;
using Mesnac.Action.ChemicalWeighing.AutoControl.Entity;
using Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard.Entity;
using Mesnac.Action.ChemicalWeighing.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MCRadioButtonEntity = Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard.Entity.MCRadioButtonEntity;
namespace Mesnac.Action.ChemicalWeighing.LjDeliverControlBoard
{
public class ControlsHelper : ControlsImprot
{
private static SiemensS7Net siemensS7Net = PlcConnect.Instance;
public static int BottleSelectA(MCRadioButtonEntity RadioButtonE)
{
int no = 0;
if (Convert.ToBoolean(RadioButtonE.SingleBottle1A.MCValue))
{
no = 1;
}
else if (Convert.ToBoolean(RadioButtonE.SingleBottle2A.MCValue))
{
no = 2;
}
else if (Convert.ToBoolean(RadioButtonE.DoubleBottleA.MCValue))
{
no = 3;
}
return no;
}
public static int BottleSelectB(MCRadioButtonEntity RadioButtonE)
{
int no = 0;
if (Convert.ToBoolean(RadioButtonE.SingleBottle1B.MCValue))
{
no = 1;
}
else if (Convert.ToBoolean(RadioButtonE.SingleBottle2B.MCValue))
{
no = 2;
}
else if (Convert.ToBoolean(RadioButtonE.DoubleBottleB.MCValue))
{
no = 3;
}
return no;
}
public static int BottleSelectC(MCRadioButtonEntity RadioButtonE)
{
int no = 0;
if (Convert.ToBoolean(RadioButtonE.SingleBottle1C.MCValue))
{
no = 1;
}
else if (Convert.ToBoolean(RadioButtonE.SingleBottle2C.MCValue))
{
no = 2;
}
else if (Convert.ToBoolean(RadioButtonE.DoubleBottleC.MCValue))
{
no = 3;
}
return no;
}
///
/// 读取手自动模式状态
///
///
///
public static byte ReadMode(string str)
{
var bytes = PlcConnect.Instance.Read($"DB91.{str}.0", 1).Content;
return bytes[0];
}
///
/// 写入手自动模式
///
///
/// 第一位为state 第二位相反
public static void WriteMode(string str, bool state)
{
siemensS7Net.Write($"DB91.{str}.0", state);
siemensS7Net.Write($"DB91.{str}.1", !state);
}
///
/// 写入34位置
///
///
/// 第一位为state 第二位相反
public static void WriteModeP1(string str, bool state)
{
siemensS7Net.Write($"DB91.{str}.2", state);
siemensS7Net.Write($"DB91.{str}.3", !state);
}
///
/// 写入56位置
///
///
/// 第一位为state 第二位相反
public static void WriteModeP2(string str, bool state)
{
siemensS7Net.Write($"DB91.{str}.4", state);
siemensS7Net.Write($"DB91.{str}.5", !state);
}
}
}