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

784 lines
19 KiB
C#

using System;
using System.Collections.Generic;
1 year ago
namespace DataBlockHelper.DBHelpers
{
public class DB2105WriteHelper
{
private static readonly string DbName = "DB2105";
public static void WriteStartJob1()
1 year ago
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.0",true);
}
public static void WriteStopJob1()
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.0",false);
1 year ago
}
public static void WriteStartJob2()
1 year ago
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.1",true);
1 year ago
}
public static void WriteStopJob2()
1 year ago
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.52.1",false);
1 year ago
}
public static void WriteStartJob3()
1 year ago
{
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);
1 year ago
}
public static void WriteManScrewH2()
1 year ago
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.1",true);
1 year ago
}
public static void WriteManScrewH3()
1 year ago
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.2",true);
1 year ago
}
public static void WriteManScrewH4()
1 year ago
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.53.3",true);
1 year ago
}
public static void WriteManScrewH5()
1 year ago
{
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);
1 year ago
}
/// <summary>
/// 换一个数据区 134
/// </summary>
/// <param name="setValue"></param>
12 months ago
public static void WriteSetValueL1(SetValue setValue)
{
12 months ago
WriteL(1, setValue.Value,setValue.Toterance);
}
12 months ago
public static void WriteSetValueR1(SetValue setValue)
{
12 months ago
WriteR(1, setValue.Value, setValue.Toterance);
}
12 months ago
public static void WriteSetValueL2(SetValue setValue)
{
12 months ago
WriteL(2, setValue.Value, setValue.Toterance);
}
12 months ago
public static void WriteSetValueR2(SetValue setValue)
{
12 months ago
WriteR(2, setValue.Value, setValue.Toterance);
}
public static void WriteSetValueL3(SetValue setValue)
{
WriteL(3, setValue.Value, setValue.Toterance);
}
public static void WriteSetValueR3(SetValue setValue)
{
WriteR(3, setValue.Value, setValue.Toterance);
}
public static void WriteSetValueL4(SetValue setValue)
{
WriteL(4, setValue.Value, setValue.Toterance);
}
public static void WriteSetValueR4(SetValue setValue)
{
WriteR(4, setValue.Value, setValue.Toterance);
}
12 months ago
1 year ago
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);
1 year ago
}
/// <summary>
/// 点击下粉料按钮 如果返回true 就是成功 如果返回失败 就是准备信号么有准备好
/// </summary>
/// <returns></returns>
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);
}
/// <summary>
1 year ago
/// 点击下糊化料按钮 湿混机 如果返回true 就是成功 如果返回失败 就是准备信号么有准备好
/// </summary>
/// <returns></returns>
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;
12 months ago
//var operateResult = siemensS7Net.ReadBool($"{DbName}.{start}.1");
//if (!operateResult.Content)
//{
// return false;
//}
var operate= siemensS7Net.Write($"{DbName}.{start}.0", true);
return operate.IsSuccess;
}
/// <summary>
/// 传入机台1~8 自动清零
/// </summary>
/// <param name="no"></param>
/// <returns></returns>
public static bool WriteFalseFeededDry(int no)
{
int start = 110;
int n = start+((no - 1)*2);
var siemensS7Net = PlcConnect.Instance;
var operate = siemensS7Net.Write($"{DbName}.{n}.4", false);
return operate.IsSuccess;
}
12 months ago
public static bool WriteHNo(int no,string t, bool b)
{
var siemensS7Net = PlcConnect.Instance;
int start = 134;
12 months ago
int db=start+((no - 1)*14);
int dian = 0;
if (t == "L")
{
dian = 0;
}
else
{
if(t== "R")
{
dian = 1;
}
else
{
if (t== "S")
{
dian = 2;
}
}
}
var operate = siemensS7Net.Write($"{DbName}.{db}.{dian}", b);
return operate.IsSuccess;
}
12 months ago
public static bool WriteL(int no, float value, float tolerance)
{
var siemensS7Net = PlcConnect.Instance;
int start = 134;
int db = start + ((no - 1) * 14);
var operate = siemensS7Net.Write($"{DbName}.{db + 2}.0", value);
operate = siemensS7Net.Write($"{DbName}.{db + 10}.0", tolerance);
return operate.IsSuccess;
}
public static bool WriteR(int no, float value, float tolerance)
{
var siemensS7Net = PlcConnect.Instance;
int start = 134;
12 months ago
int db = start + ((no - 1) * 14);
12 months ago
var operate = siemensS7Net.Write($"{DbName}.{db + 6}.0", value);
operate = siemensS7Net.Write($"{DbName}.{db + 10}.0", tolerance);
return operate.IsSuccess;
}
12 months ago
private static readonly int HaNo = 190;
public static readonly int HbNo = 198;
private static readonly int CaNo = 206;
private static readonly int CbNo = 214;
#region 添加方法Ha
public static void AddHaAddValue(short value)
{
AddValue(value, HaNo);
}
public static void AddHaAddRemainValue(short value)
{
AddRemainValue(value, HaNo);
}
public static void AddHaAddForceBin(short value)
{
AddForceBin(value, HaNo);
}
public static void AddHaAddForceOn(bool value)
{
AddForceOn(value, HaNo);
}
public static void AddHaAddStartIn(bool value)
{
AddStartIn(value, HaNo);
}
public static void AddHaAddStartOut(bool value)
{
AddStartOut(value, HaNo);
}
#endregion
#region Hb 添加方法
public static void AddHbAddValue(short value)
{
AddValue(value, HbNo);
}
public static void AddHbAddRemainValue(short value)
{
AddRemainValue(value, HbNo);
}
public static void AddHbAddForceBin(short value)
{
AddForceBin(value, HbNo);
}
public static void AddHbAddForceOn(bool value)
{
AddForceOn(value, HbNo);
}
public static void AddHbAddStartIn(bool value)
{
AddStartIn(value, HbNo);
}
public static void AddHbAddStartOut(bool value)
{
AddStartOut(value, HbNo);
}
#endregion
#region Ca 添加方法
public static void AddCaAddValue(short value)
{
AddValue(value, CaNo);
}
public static void AddCaAddRemainValue(short value)
{
AddRemainValue(value, CaNo);
}
public static void AddCaAddForceBin(short value)
{
AddForceBin(value, CaNo);
}
public static void AddCaAddForceOn(bool value)
{
AddForceOn(value, CaNo);
}
public static void AddCaAddStartIn(bool value)
{
AddStartIn(value, CaNo);
}
public static void AddCaAddStartOut(bool value)
{
AddStartOut(value, CaNo);
}
#endregion
#region Cb 添加方法
public static void AddCbAddValue(short value)
{
AddValue(value, CbNo);
}
public static void AddCbAddRemainValue(short value)
{
AddRemainValue(value, CbNo);
}
public static void AddCbAddForceBin(short value)
{
AddForceBin(value, CbNo);
}
public static void AddCbAddForceOn(bool value)
{
AddForceOn(value, CbNo);
}
public static void AddCbAddStartIn(bool value)
{
AddStartIn(value, CbNo);
}
public static void AddCbAddStartOut(bool value)
{
AddStartOut(value, CbNo);
}
#endregion
private static void AddValue(short value, int start)
{
//106
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{start}.0", value);
}
private static void AddRemainValue(short value, int start)
{
int nu = start + 2;
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{nu}.0", value);
}
private static void AddForceBin(short value, int start)
{
int nu = start + 4;
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{nu}.0", value);
}
private static void AddForceOn(bool value, int start)
{
int nu = start + 6;
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{nu}.0", value);
}
private static void AddStartIn(bool value, int start)
{
int nu = start + 6;
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{nu}.1", value);
}
private static void AddStartOut(bool value, int start)
{
int nu = start + 6;
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{nu}.2", value);
}
/// <summary>
/// 0 冷水A 1 热水A 2 冷水B 3 热水B
/// </summary>
/// <param name="no"></param>
public static void StopWater(int no)
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{53}.{no}",true);
}
/// <summary>
/// 0 冷水A 1 热水A 2 冷水B 3 热水B
/// </summary>
/// <param name="no"></param>
public static void StartWater(int no)
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{53}.{no}", false);
}
/// <summary>
/// true 状态是停止
/// </summary>
/// <returns></returns>
public static List<bool> GetWaterStatus()
{
var siemensS7Net = PlcConnect.Instance;
List<bool> status = new List<bool>();
for (int i = 0; i < 4; i++)
{
var b= siemensS7Net.ReadBool($"{DbName}.{53}.{i}");
status.Add(b.Content);
}
return status;
}
11 months ago
/// <summary>
/// 写入干混机 1 2 3 4
/// </summary>
/// <param name="no"></param>
/// <param name="value"></param>
/// <returns></returns>
public static void WriteStartOrStop(int no, bool value)
{
var siemensS7Net = PlcConnect.Instance;
var b = siemensS7Net.Write($"{DbName}.48.{no-1}",value);
}
11 months ago
public static void AddFeededPd(int start,bool b)
{
//94.6;
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}.{start}.6",b);
}
public static void AddFeededPdG1(bool b)
{
AddFeededPd(94, b);
}
public static void AddFeededPdG2(bool b)
{
AddFeededPd(96, b);
}
public static void AddFeededPdG3(bool b)
{
AddFeededPd(98, b);
}
public static void AddFeededPdG4(bool b)
{
AddFeededPd(100, b);
}
public static void AddFeededPdG5(bool b)
{
AddFeededPd(102, b);
}
public static void AddFeededPdG6(bool b)
{
AddFeededPd(104, b);
}
public static void AddFeededPdG7(bool b)
{
AddFeededPd(106, b);
}
public static void AddFeededPdG8(bool b)
{
AddFeededPd(108, b);
}
1 year ago
}
}