增加点位

dep_nodyang
nodyang 1 year ago
parent 5b648d2ff8
commit 16840c81fc

@ -13,7 +13,7 @@ namespace DataBlockHelper.DBHelpers
public DB2104Helper() public DB2104Helper()
{ {
this.bytes = PlcConnect.Instance.Read("DB2104.0.0", 3578).Content; this.bytes = PlcConnect.Instance.Read("DB2104.0.0", 3618).Content;
} }
public RecipeCommEntity RecipeComm => RecipeCom(bytes); public RecipeCommEntity RecipeComm => RecipeCom(bytes);
@ -53,5 +53,45 @@ namespace DataBlockHelper.DBHelpers
public WeterEntity Weter_M8 => new WeterEntity(3378, bytes); public WeterEntity Weter_M8 => new WeterEntity(3378, bytes);
/// <summary>
/// 热水秤A
/// </summary>
public WaterEntity GetAHotWater => GetWater(3578);
/// <summary>
/// 热水秤B
/// </summary>
public WaterEntity GetBHotWater => GetWater(3588);
/// <summary>
/// 冷水秤A
/// </summary>
public WaterEntity GetAColWater => GetWater(3598);
/// <summary>
/// 冷水秤B
/// </summary>
public WaterEntity GetBColWater => GetWater(3608);
private WaterEntity GetWater(int start)
{
var instanceByteTransform = PlcConnect.Instance.ByteTransform;
var ls = bytes.Skip(start).Take(10).ToArray();
WaterEntity entity = new WaterEntity
{
Bin = instanceByteTransform.TransInt16(ls, 0),
Set = instanceByteTransform.TransSingle(ls, 2),
TolErance = instanceByteTransform.TransSingle(ls, 6)
};
return entity;
}
} }
} }

@ -0,0 +1,68 @@
using System.Collections.Generic;
using DataBlockHelper.Entity.DB2104Entity;
namespace DataBlockHelper.DBHelpers
{
public class Db2104WriteHelper
{
private static readonly string DbName = "DB2104";
/// <summary>
/// 写入水 写入集合顺序 A 热水 B热水 冷水A 冷水B
/// </summary>
/// <param name="ls"></param>
public static bool Write(List<WaterEntity> ls)
{
int start = 3578;
for (int i = 0; i < ls.Count; i++)
{
int no = start + (i * 10);
Write(no, ls[i]);
}
return true;
}
/// <summary>
/// A 热水
/// </summary>
/// <param name="entity"></param>
public static void WriteAHostWater(WaterEntity entity)
{
Write(3578, entity);
}
/// <summary>
/// B热水
/// </summary>
/// <param name="entity"></param>
public static void WriteBHostWater(WaterEntity entity)
{
Write(3588, entity);
}
/// <summary>
/// 冷水A
/// </summary>
/// <param name="entity"></param>
public static void WriteAColWater(WaterEntity entity)
{
Write(3598, entity);
}
/// <summary>
/// 冷水B
/// </summary>
/// <param name="entity"></param>
public static void WriteBColWater(WaterEntity entity)
{
Write(3608, entity);
}
private static void Write(int start, WaterEntity entity)
{
var siemensS7Net = PlcConnect.Instance;
siemensS7Net.Write($"{DbName}:{start}.0", entity.Bin);
siemensS7Net.Write($"{DbName}:{start+2}.0", entity.Set);
siemensS7Net.Write($"{DbName}:{start+6}.0", entity.TolErance);
}
}
}

@ -18,5 +18,111 @@ namespace DataBlockHelper.DBHelpers
public bool[] Status => new FourBoolArrayManager(48, bytes).GetList(); public bool[] Status => new FourBoolArrayManager(48, bytes).GetList();
public bool[] End => new FourBoolArrayManager(50, bytes).GetList(); public bool[] End => new FourBoolArrayManager(50, bytes).GetList();
/// <summary>
/// 设置启动运行
/// </summary>
public List<NoVal> GetStartJob
{
get
{
List<NoVal> ls = new List<NoVal>();
var b = bytes.Skip(52).Take(1).First();
for (int i = 0; i <8; i++)
{
int no = i + 1;
ls.Add(new NoVal()
{
No = no,
Val = b.GetBit(i)
});
}
return ls;
}
}
/// <summary>
/// 获取手动加粉料数据
/// </summary>
public List<NoVal> GetManScrew
{
get
{
List<NoVal> ls = new List<NoVal>();
var b = bytes.Skip(53).Take(1).First();
for (int i = 0; i <4; i++)
{
int no = i + 1;
ls.Add(new NoVal()
{
No = no,
Val = b.GetBit(i)
});
}
return ls;
}
}
/// <summary>
/// 获取设定值
/// </summary>
public List<SetValue> GetSetValue
{
get
{
// 54 58
// 62 66
// 70 74
// 78 82
// 86 90
// 94 98
// 102 106
// 110 114
int start = 54;
List<SetValue> ls = new List<SetValue>();
for (int i = 0; i < 8; i++)
{
int no = i + 1;
var b = bytes.Skip(start).Take(8).ToArray();
ls.Add(new SetValue()
{
No = no,
Value = PlcConnect.Instance.ByteTransform.TransSingle(b,0),
Toterance = PlcConnect.Instance.ByteTransform.TransSingle(b,4),
});
start += 8;
}
return ls;
}
}
}
public class NoVal
{
public int No { get; set; }
public bool Val { get; set; }
}
public class SetValue
{
public int No { get; set; }
public float Value { get; set; }
public float Toterance { get; set; }
} }
} }

@ -0,0 +1,61 @@
using System.Collections.Generic;
namespace DataBlockHelper.DBHelpers
{
public class DB2105WriteHelper
{
private static readonly string DbName = "DB2105";
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);
}
public static void WriteSetValueH5(SetValue setValue)
{
WriteSetValue(86, setValue);
}
public static void WriteSetValueH6(SetValue setValue)
{
WriteSetValue(86, setValue);
}
public static void WriteSetValueH7(SetValue setValue)
{
WriteSetValue(94, setValue);
}
public static void WriteSetValueH8(SetValue setValue)
{
WriteSetValue(102, 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);
}
}
}

@ -52,7 +52,9 @@
<Compile Include="DBHelpers\DB2102Helper.cs" /> <Compile Include="DBHelpers\DB2102Helper.cs" />
<Compile Include="DBHelpers\DB2103Helper.cs" /> <Compile Include="DBHelpers\DB2103Helper.cs" />
<Compile Include="DBHelpers\DB2104Helper.cs" /> <Compile Include="DBHelpers\DB2104Helper.cs" />
<Compile Include="DBHelpers\DB2104WriteHelper.cs" />
<Compile Include="DBHelpers\DB2105Helper.cs" /> <Compile Include="DBHelpers\DB2105Helper.cs" />
<Compile Include="DBHelpers\DB2105WriteHelper.cs" />
<Compile Include="DBHelpers\DB2106Helper.cs" /> <Compile Include="DBHelpers\DB2106Helper.cs" />
<Compile Include="DBHelpers\DB2119Helper.cs" /> <Compile Include="DBHelpers\DB2119Helper.cs" />
<Compile Include="DBHelpers\Db3000Helper.cs" /> <Compile Include="DBHelpers\Db3000Helper.cs" />
@ -72,6 +74,7 @@
<Compile Include="Entity\DB2104Entity\EnableStatusEntity.cs" /> <Compile Include="Entity\DB2104Entity\EnableStatusEntity.cs" />
<Compile Include="Entity\DB2104Entity\GelatEntity.cs" /> <Compile Include="Entity\DB2104Entity\GelatEntity.cs" />
<Compile Include="Entity\DB2104Entity\RecipeCommEntity.cs" /> <Compile Include="Entity\DB2104Entity\RecipeCommEntity.cs" />
<Compile Include="Entity\DB2104Entity\WaterView.cs" />
<Compile Include="Entity\DB2104Entity\WeterEntity.cs" /> <Compile Include="Entity\DB2104Entity\WeterEntity.cs" />
<Compile Include="Entity\DB2105Entity\FourBoolArrayEntity.cs" /> <Compile Include="Entity\DB2105Entity\FourBoolArrayEntity.cs" />
<Compile Include="Entity\DB2105Entity\PlanEntity.cs" /> <Compile Include="Entity\DB2105Entity\PlanEntity.cs" />

@ -0,0 +1,9 @@
namespace DataBlockHelper.Entity.DB2104Entity
{
public class WaterEntity
{
public short Bin { get; set; }
public float Set { get; set; }
public float TolErance { get; set; }
}
}
Loading…
Cancel
Save