dep_nodyang
wangsr 1 year ago
commit c5c60daf59

@ -1,8 +1,23 @@
namespace Mesnac.Action.ChemicalWeighing
using HslCommunication;
using Mesnac.Action.ChemicalWeighing.Pl;
namespace Mesnac.Action.ChemicalWeighing
{
public static class LjHelp
{
//开门狗
public static int WatchDog=>BasePlcHelper.Instance.WatchDog.LastValue.ToInt();
public static int WatchDog
{
get
{
OperateResult<byte[]> read = PlcConnect.Instance.Read("DB2107.2.0", 2);
var content = read.Content;
return PlcConnect.Instance.ByteTransform.TransInt16(content, 0);
}
}
//BasePlcHelper.Instance.WatchDog.LastValue.ToInt();
}
}

@ -99,7 +99,7 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
PressureSettingView view = new PressureSettingView()
{
Id = _id,
HighLimit = b,
HighLimit =b,
LowLimit = a,
};

@ -1,6 +1,8 @@
using System;
using System.Collections.Generic;
using System.Linq;
using DataBlockHelper.DBHelpers;
using DataBlockHelper.DbWrite;
using DevExpress.XtraGauges.Core.Model;
using DevExpress.XtraRichEdit.API.Layout;
@ -16,22 +18,41 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
{
if (view != null)
{
var basePlcHelper = GetPlcHelper;
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.mainPress_V1_LowLimit, view.LowLimit);
basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.mainPress_V1_HighLimit, view.HighLimit);
// var basePlcHelper = GetPlcHelper;
// basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.mainPress_V1_LowLimit, view.LowLimit);
// basePlcHelper.PlcWriteFloatByDataKey(basePlcHelper.mainPress_V1_HighLimit, view.HighLimit);
// basePlcHelper.PlcWriteByDataKey(basePlcHelper.mainPress_V1_Alarm,
// new object[] { Convert.ToBoolean(view.Alarm) });
}
PlcWriteUtil plcWriter = new PlcWriteUtil();
if (view != null)
{
// var basePlcHelper = GetPlcHelper;
var ss= plcWriter.Write(PlcDbEnum.Db2107,"16.0",PlcDbType.PlcFloat,view.LowLimit);
ss= plcWriter.Write(PlcDbEnum.Db2107,"20.0",PlcDbType.PlcFloat,view.HighLimit);
}
}
private static DB2107Helper _db2107Helper = new DB2107Helper();
private static PressureSettingView UpDbw12()
{
var basePlcHelper = GetPlcHelper;
PressureSettingView view = new PressureSettingView();
var v1 = _db2107Helper.Pressure.MainPress_V1;
view.Id = 1;
view.LowLimit = basePlcHelper.mainPress_V1_LowLimit.NowValue.ToFloat();
view.HighLimit = basePlcHelper.mainPress_V1_HighLimit.NowValue.ToFloat();
view.Alarm = basePlcHelper.mainPress_V1_LowLimit.NowValue.ToInt();
view.LowLimit = v1.LowLimit;
view.HighLimit = v1.HighLimit;
return view;
}
@ -40,6 +61,9 @@ namespace Mesnac.Action.ChemicalWeighing.LjPressure
private static void DownDbw26(PressureSettingView view)
{
// PlcWriter plcWriter=new PlcWriter();
if (view != null)
{
var basePlcHelper = GetPlcHelper;

@ -169,6 +169,9 @@
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\..\PlugInPlatform\Mesnac.PlugIn.dll</HintPath>
</Reference>
<Reference Include="Microsoft.Office.Interop.Excel">
<HintPath>..\..\Microsoft.Office.Interop.Excel.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
@ -978,6 +981,10 @@
<Project>{f022c0e6-2819-4fb1-bb86-0f389f061a44}</Project>
<Name>Mesnac.Controls.Default</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\DataBlockHelper\DataBlockHelper.csproj">
<Project>{4e36df17-e81d-4360-8687-8ad75422b470}</Project>
<Name>DataBlockHelper</Name>
</ProjectReference>
<ProjectReference Include="..\..\..\Main\Mesnac.Basic\Mesnac.Basic.csproj">
<Project>{28acacf1-9936-4e97-a866-f84366ec5286}</Project>
<Name>Mesnac.Basic</Name>

@ -1,4 +1,6 @@
using System;
using System.Text;
using HslCommunication;
using HslCommunication.Profinet.Siemens;
namespace DataBlockHelper.DbWrite
@ -16,28 +18,34 @@ namespace DataBlockHelper.DbWrite
}
public void Write(PlcDbEnum dbEnum, string address, PlcDbType dbType, object value)
public OperateResult Write(PlcDbEnum dbEnum, string address, PlcDbType dbType, object value)
{
OperateResult operateResult = new OperateResult();
string plcAddress = $"{dbEnum.ToString()}.{address}";
switch (dbType)
{
case PlcDbType.PlcInt:
_siemensS7Net.Write(plcAddress, Convert.ToInt32(value));
operateResult=_siemensS7Net.Write(plcAddress, Convert.ToInt32(value));
break;
case PlcDbType.PlcUint:
_siemensS7Net.Write(plcAddress, Convert.ToInt16(value));
operateResult=_siemensS7Net.Write(plcAddress, Convert.ToInt16(value));
break;
case PlcDbType.PlcBoolean:
_siemensS7Net.Write(plcAddress, Convert.ToBoolean(value));
operateResult= _siemensS7Net.Write(plcAddress, Convert.ToBoolean(value));
break;
case PlcDbType.PlcFloat:
_siemensS7Net.Write(plcAddress, Convert.ToSingle(value));
float number = Convert.ToSingle(value);
operateResult=_siemensS7Net.Write(plcAddress,number);
break;
}
return operateResult;
}
@ -51,6 +59,8 @@ namespace DataBlockHelper.DbWrite
public void Write(string plcAddress, PlcDbType dbType, object value)
{
OperateResult operateResult = new OperateResult();
switch (dbType)
{
case PlcDbType.PlcInt:

@ -51,6 +51,9 @@ namespace DataBlockHelper.Entity.DB2107Entity
LowLimit = PlcConnect.Instance.ByteTransform.TransSingle(content, 4);
HighLimit = PlcConnect.Instance.ByteTransform.TransSingle(content, 8);
var operateResult = PlcConnect.Instance.ReadFloat("Db2107.20.0");
byte byt = content[12];
Alarm = byt.GetBit(0);

@ -25,18 +25,14 @@ namespace DataBlockHelper
}
public static void Init(PlcConfig config)
{
Config = config ?? new PlcConfig();
}
public SiemensS7Net SiemensS7NetConnection()
{
SiemensPLCS siemensPLCS = SiemensPLCS.S1500;
SiemensS7Net s7 = new SiemensS7Net(siemensPLCS);
s7.IpAddress = Config.IpAddress;
s7.Port = Config.Port;
s7.IpAddress = "192.168.1.50";
s7.Port = 102;
s7.ConnectServer();
return s7;
}

@ -194,6 +194,10 @@
<Project>{d0c0324f-434e-47eb-8f7c-ba6cd7f233b4}</Project>
<Name>Mesnac.Controls.Feeding</Name>
</ProjectReference>
<ProjectReference Include="..\..\DataBlockHelper\DataBlockHelper.csproj">
<Project>{4e36df17-e81d-4360-8687-8ad75422b470}</Project>
<Name>DataBlockHelper</Name>
</ProjectReference>
<ProjectReference Include="..\..\Mesnac.DoUtils\Mesnac.DoUtils.csproj">
<Project>{ad132cad-5288-44dc-a38f-4b0658fc228c}</Project>
<Name>Mesnac.DoUtils</Name>

Loading…
Cancel
Save