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/DB191WriteHelper.cs

150 lines
4.0 KiB
C#

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";
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);
}
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 AddPanel(int start, int bit, bool state)
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{start}.{bit}", state);
}
}
}