|
|
|
|
using HslCommunication.Profinet.Siemens;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace DataBlockHelper.DBHelpers
|
|
|
|
|
{
|
|
|
|
|
public class DB191WriteHelper
|
|
|
|
|
{
|
|
|
|
|
private static readonly string DbName = "DB191";
|
|
|
|
|
private static SiemensS7Net siemensS7Net = PlcConnect.Instance;
|
|
|
|
|
|
|
|
|
|
public static void SetVesselModeA(bool state1, bool state2)
|
|
|
|
|
{
|
|
|
|
|
AddVesselMode(0, state1, state2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetSiloGroupA(bool state1, bool state2, bool state3, bool state4, bool state5)
|
|
|
|
|
{
|
|
|
|
|
AddSiloGroup(0, state1, state2, state3, state4, state5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetSiloA(bool state1, bool state2, bool state3, bool state4)
|
|
|
|
|
{
|
|
|
|
|
AddSilo(0, state1, state2, state3, state4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetClearAlarmA(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddClearAlarm(0, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetStartA(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddStart(0, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetStopA(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddStop(0, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetVesselModeB(bool state1, bool state2)
|
|
|
|
|
{
|
|
|
|
|
AddVesselMode(4, state1, state2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetSiloGroupB(bool state1, bool state2, bool state3, bool state4, bool state5)
|
|
|
|
|
{
|
|
|
|
|
AddSiloGroup(4, state1, state2, state3, state4, state5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetSiloB(bool state1, bool state2, bool state3, bool state4)
|
|
|
|
|
{
|
|
|
|
|
AddSilo(4, state1, state2, state3, state4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetClearAlarmB(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddClearAlarm(4, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetStartB(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddStart(4, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetStopB(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddStop(4, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetVesselModeC(bool state1, bool state2)
|
|
|
|
|
{
|
|
|
|
|
AddVesselMode(8, state1, state2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetSiloGroupC(bool state1, bool state2, bool state3, bool state4, bool state5)
|
|
|
|
|
{
|
|
|
|
|
AddSiloGroup(8, state1, state2, state3, state4, state5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetSiloC(bool state1, bool state2, bool state3, bool state4)
|
|
|
|
|
{
|
|
|
|
|
AddSilo(8, state1, state2, state3, state4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetClearAlarmC(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddClearAlarm(8, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetStartC(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddStart(8, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetStopC(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddStop(8, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetPanelOnOffA(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddPanelOnOff(0, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetPanelOnOffB(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddPanelOnOff(1, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void SetPanelOnOffC(bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddPanelOnOff(2, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static void AddVesselMode(int start, bool state1, bool state2)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(0 + start, 0, state1);
|
|
|
|
|
AddPanel(0 + start, 1, state2);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddSiloGroup(int start, bool state1, bool state2, bool state3, bool state4, bool state5)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(0 + start, 2, state1);
|
|
|
|
|
AddPanel(0 + start, 3, state2);
|
|
|
|
|
AddPanel(0 + start, 4, state3);
|
|
|
|
|
AddPanel(0 + start, 5, state4);
|
|
|
|
|
AddPanel(0 + start, 6, state5);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddSilo(int start, bool state1, bool state2, bool state3, bool state4)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(0 + start, 7, state1);
|
|
|
|
|
AddPanel(1 + start, 0, state2);
|
|
|
|
|
AddPanel(1 + start, 1, state3);
|
|
|
|
|
AddPanel(1 + start, 2, state4);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddClearAlarm(int start, bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(1 + start, 3, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddStart(int start, bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(1 + start, 5, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddStop(int start, bool state1)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(1 + start, 6, state1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddPanelOnOff(int bit, bool state)
|
|
|
|
|
{
|
|
|
|
|
AddPanel(30, bit, state);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void AddPanel(int start, int bit, bool state)
|
|
|
|
|
{
|
|
|
|
|
siemensS7Net.Write($"{DbName}.{start}.{bit}", state);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|