|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|