using System;
using System.Collections.Generic;
namespace DataBlockHelper.DBHelpers
{
public class DB2105WriteHelper
{
private static readonly string DbName = "DB2105";
public static void WriteStartJob1()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.0",true);
}
public static void WriteStopJob1()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.0",false);
}
public static void WriteStartJob2()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.1",true);
}
public static void WriteStopJob2()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.1",false);
}
public static void WriteStartJob3()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.2",true);
}
public static void WriteStopJob3()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.2",false);
}
public static void WriteStartJob4()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.3",true);
}
public static void WriteStopJob4()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.3",false);
}
public static void WriteStartJob5()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.4",true);
}
public static void WriteStopJob5()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.4",false);
}
public static void WriteStartJob6()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.5",true);
}
public static void WriteStopJob6()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.5",false);
}
public static void WriteStartJob7()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.6",true);
}
public static void WriteStopJob7()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.6",false);
}
public static void WriteStartJob8()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.7",true);
}
public static void WriteStopJob8()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.7",false);
}
public static void WriteManScrewH1()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.0",true);
}
public static void WriteManScrewH2()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.1",true);
}
public static void WriteManScrewH3()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.2",true);
}
public static void WriteManScrewH4()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.3",true);
}
public static void WriteManScrewH5()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.4",true);
}
public static void WriteManScrewH6()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.5",true);
}
public static void WriteManScrewH7()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.6",true);
}
public static void WriteManScrewH8()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.7",true);
}
public static void WriteSetValueH1(SetValue setValue)
{
WriteSetValue(54, setValue);
}
public static void WriteSetValueH2(SetValue setValue)
{
WriteSetValue(62, setValue);
}
public static void WriteSetValueH3(SetValue setValue)
{
WriteSetValue(70, setValue);
}
public static void WriteSetValueH4(SetValue setValue)
{
WriteSetValue(78, setValue);
}
private static void WriteSetValue(int start,SetValue setValue)
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{start}.0", setValue.Value);
siemensS7Net.Write($"{DbName}.{start+4}.0", setValue.Toterance);
}
///
/// 点击下粉料按钮 如果返回true 就是成功 如果返回失败 就是准备信号么有准备好
///
///
public static bool WriteG1Pd()
{
return WriteG(94,3);
}
public static bool WriteG1Cw()
{
return WriteG(94,4);
}
public static bool WriteG1Hw()
{
return WriteG(94,5);
}
public static bool WriteG2Pd()
{
return WriteG(96,3);
}
public static bool WriteG2Cw()
{
return WriteG(96,4);
}
public static bool WriteG2Hw()
{
return WriteG(96,5);
}
public static bool WriteG3Pd()
{
return WriteG(98,3);
}
public static bool WriteG3Cw()
{
return WriteG(98,4);
}
public static bool WriteG3Hw()
{
return WriteG(98,5);
}
public static bool WriteG4Pd()
{
return WriteG(100,3);
}
public static bool WriteG4Cw()
{
return WriteG(100,4);
}
public static bool WriteG4Hw()
{
return WriteG(100,5);
}
public static bool WriteG5Pd()
{
return WriteG(102,3);
}
public static bool WriteG5Cw()
{
return WriteG(102,4);
}
public static bool WriteG5Hw()
{
return WriteG(102,5);
}
public static bool WriteG6Pd()
{
return WriteG(104,3);
}
public static bool WriteG6Cw()
{
return WriteG(104,4);
}
public static bool WriteG6Hw()
{
return WriteG(104,5);
}
public static bool WriteG7Pd()
{
return WriteG(106,3);
}
public static bool WriteG7Cw()
{
return WriteG(106,4);
}
public static bool WriteG7Hw()
{
return WriteG(106,5);
}
public static bool WriteG8Pd()
{
return WriteG(108,3);
}
public static bool WriteG8Cw()
{
return WriteG(108,4);
}
public static bool WriteG8Hw()
{
return WriteG(108,5);
}
///
/// 点击下糊化料按钮 湿混机 如果返回true 就是成功 如果返回失败 就是准备信号么有准备好
///
///
public static bool WriteM1()
{
return WriteM(110);
}
public static bool WriteM2()
{
return WriteM(112);
}
public static bool WriteM3()
{
return WriteM(114);
}
public static bool WriteM4()
{
return WriteM(116);
}
public static bool WriteM5()
{
return WriteM(118);
}
public static bool WriteM6()
{
return WriteM(120);
}
public static bool WriteM7()
{
return WriteM(122);
}
public static bool WriteM8()
{
return WriteM(124);
}
private static bool WriteG(int start,int dian)
{
var siemensS7Net = PlcConnect.Instance;
var operateResult = siemensS7Net.ReadBool($"{DbName}.{start}.{dian}");
if (!operateResult.Content)
{
return false;
}
var operate= siemensS7Net.Write($"{DbName}.{start}.{dian-3}", true);
return operate.IsSuccess;
}
private static bool WriteM(int start)
{
var siemensS7Net = PlcConnect.Instance;
var operateResult = siemensS7Net.ReadBool($"{DbName}.{start}.1");
if (!operateResult.Content)
{
return false;
}
var operate= siemensS7Net.Write($"{DbName}.{start}.0", true);
return operate.IsSuccess;
}
}
}