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

89 lines
2.3 KiB
C#

12 months ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DataBlockHelper.DBHelpers
{
public class DB112WriterHelper
{
private static readonly string DbName = "DB112";
// var siemensS7Net = PlcConnect.Instance;
12 months ago
public static void AddConveyorA(Conveyor conveyor)
{
int start = 2;
AddConveyor(start, conveyor);
}
public static void AddConveyorB(Conveyor conveyor)
{
int start = 34;
AddConveyor(start, conveyor);
}
public static void AddConveyorC(Conveyor conveyor)
{
int start = 66;
AddConveyor(start, conveyor);
12 months ago
}
public static void AddConveyorTimerA(ConveyorTimer conveyor)
{
int start = 98;
AddConveyorTimer(start, conveyor);
}
public static void AddConveyorTimerB(ConveyorTimer conveyor)
{
int start = 102;
AddConveyorTimer(start, conveyor);
}
public static void AddConveyorTimerC(ConveyorTimer conveyor)
{
int start = 106;
AddConveyorTimer(start, conveyor);
}
private static void AddConveyor(int start, Conveyor conveyor)
{
12 months ago
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{start}.0", conveyor.SetValue1);
siemensS7Net.Write($"{DbName}.{start + 4}.0", conveyor.SetValue2);
siemensS7Net.Write($"{DbName}.{start + 8}.0", conveyor.SetValue3);
siemensS7Net.Write($"{DbName}.{start + 12}.0", conveyor.SetValue4);
siemensS7Net.Write($"{DbName}.{start + 16}.0", conveyor.SetValue5);
siemensS7Net.Write($"{DbName}.{start + 20}.0", conveyor.SetValue6);
siemensS7Net.Write($"{DbName}.{start + 24}.0", conveyor.SetValue7);
siemensS7Net.Write($"{DbName}.{start + 28}.0", conveyor.SetValue7);
}
private static void AddConveyorTimer(int start, ConveyorTimer conveyor)
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{start}.0", conveyor.SetValue1);
siemensS7Net.Write($"{DbName}.{start + 2}.0", conveyor.SetValue2);
12 months ago
}
//
}
}