change-螺旋频率设定地址变化,float直接给

dev
liuwf 3 months ago
parent ae53b6eec7
commit 138aba9860

@ -347,5 +347,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
public override bool writeFloatByAddress(string address, int value)
{
throw new NotImplementedException();
}
}
}

@ -288,5 +288,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
public override bool writeFloatByAddress(string address, int value)
{
throw new NotImplementedException();
}
}
}

@ -291,5 +291,10 @@ namespace SlnMesnac.Plc.Factory
{
throw new NotImplementedException();
}
public override bool writeFloatByAddress(string address, int value)
{
throw new NotImplementedException();
}
}
}

@ -310,5 +310,29 @@ namespace SlnMesnac.Plc.Factory
throw new InvalidOperationException($"根据地址:{address};写入double数据异常{ex.Message}");
}
}
/// <summary>
/// 通过PLC地址写入Float类型数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
/// <returns></returns>
/// <exception cref="InvalidOperationException"></exception>
public override bool writeFloatByAddress(string address, int value)
{
try
{
OperateResult operateResult = s7.Write(address, (float)value);
if (!operateResult.IsSuccess)
{
throw new InvalidOperationException($"根据地址:{address};写入double数据失败{operateResult.Message}");
}
return operateResult.IsSuccess;
}
catch (Exception ex)
{
throw new InvalidOperationException($"根据地址:{address};写入double数据异常{ex.Message}");
}
}
}
}

@ -112,5 +112,13 @@ namespace SlnMesnac.Plc
/// <param name="value"></param>
/// <returns></returns>
public abstract bool writeDoubleByAddress(string address, int value);
/// <summary>
/// 通过PLC地址写入float类型数据
/// </summary>
/// <param name="address"></param>
/// <param name="value"></param>
/// <returns></returns>
public abstract bool writeFloatByAddress(string address, int value);
}
}

@ -326,7 +326,7 @@
<TextBox x:Name="Speed1Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="10,0,0,0" Foreground="White"/>
<TextBlock Text="/" FontSize="20" VerticalAlignment="Center" Margin="5,0,5,0" Foreground="White"/>
<TextBox x:Name="Speed2Txt" Text="0.00" Width="70" Height="35" FontSize="20" VerticalAlignment="Center" Margin="0,0,10,0" Foreground="White"/>
<Button x:Name="SpiralSpeed" Content="螺旋1/2速度设定(0-50)" FontSize="20" Width="250" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="DeepSkyBlue" Click="SpiralSpeed_Click" />
<Button x:Name="SpiralSpeed" Content="螺旋1/2频率设定(0-50)" FontSize="20" Width="250" Height="40" VerticalAlignment="Center" Margin="0,0,20,0" Background="DeepSkyBlue" Click="SpiralSpeed_Click" />
<Button x:Name="StartSpiral1Button" Content="螺旋1启动" FontSize="20" Background="LimeGreen" Width="100" Height="40" Margin="30 0 10 0" Click="StartSpiral1Button_Click"/>
<Button x:Name="StartSpiral2Button" Content="螺旋2启动" FontSize="20" Background="LimeGreen" Width="100" Height="40" Margin="0 0 10 0" Click="StartSpiral2Button_Click"/>

@ -74,10 +74,18 @@ namespace SlnMesnac.WPF.Page
try
{
Thread.Sleep(2000);
RefreshMagNet();
RefreshSpiral();
RefreshHot();
RefreshUnPack();
if (plc != null)
{
RefreshMagNet();
RefreshSpiral();
RefreshHot();
RefreshUnPack();
}
else
{
_logger.LogError($"设备监听启动失败PLC连接失败!");
Thread.Sleep(1000 * 30);
}
}
catch(Exception ex)
{
@ -581,9 +589,9 @@ namespace SlnMesnac.WPF.Page
}
else
{
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值")) * 100;
int value2 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度值"));
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"), true);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), value2);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), value2);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2启动"));
}
@ -671,7 +679,7 @@ namespace SlnMesnac.WPF.Page
int value1 = int.Parse(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度值"));
plc.writeBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"), true);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), value1 * 100);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), value1);
Thread.Sleep(MachineSleep);
result = plc.readBoolByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1启动"));
@ -766,7 +774,7 @@ namespace SlnMesnac.WPF.Page
}
int value = int.Parse(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定值"));
SendPulseSignal("烘干机燃烧启动");
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), value * 100);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), value * 10);
Thread.Sleep(MachineSleep);
return true;
}
@ -963,11 +971,11 @@ namespace SlnMesnac.WPF.Page
await App.Current.Dispatcher.BeginInvoke((Action)(() =>
{
HotSignal1_1.Fill = signal1_1==2 ? Brushes.Green : Brushes.Red;
HotSignal1_1.Fill = signal1_1==1 ? Brushes.Green : Brushes.Red;
HotSignal1_1_Value.Text = ChangeHotStatus(signal1_1);
HotSignal2_1.Fill = signal2_1 == 2 ? Brushes.Green : Brushes.Red;
HotSignal2_1.Fill = signal2_1 == 1 ? Brushes.Green : Brushes.Red;
HotSignal2_1_Value.Text = ChangeHotStatus(signal2_1);
HotSignal3_1.Fill = signal3_1 == 2 ? Brushes.Green : Brushes.Red;
HotSignal3_1.Fill = signal3_1 == 1 ? Brushes.Green : Brushes.Red;
HotSignal3_1_Value.Text = ChangeHotStatus(signal3_1);
HotSignal1_2.Fill = signal1_2 ? Brushes.Green : Brushes.Red;
@ -1001,10 +1009,11 @@ namespace SlnMesnac.WPF.Page
{
switch (status)
{
case 1: return "未知"; break;
case 2: return "运行"; break;
case 4: return "停止"; break;
default: return "未知"; break;
case 0: return "未知";
case 1: return "运行";
case 2: return "停止";
case 3: return "故障";
default: return "未知";
}
}
private string ChangeHotWarn(int status)
@ -1072,8 +1081,8 @@ namespace SlnMesnac.WPF.Page
BaseConfigInfo configInfo1 = configInfos.Where(x => x.ConfigKey == "螺旋1速度值").FirstOrDefault();
BaseConfigInfo configInfo2 = configInfos.Where(x => x.ConfigKey == "螺旋2速度值").FirstOrDefault();
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1 * 100);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2 * 100);
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋1速度设置"), speed1 );
plc.writeFloatByAddress(baseBusiness.GetPlcAddressByConfigKey("螺旋2速度设置"), speed2 );
configInfo1.ConfigValue = Speed1Txt.Text;
configInfo2.ConfigValue = Speed2Txt.Text;
@ -1154,7 +1163,7 @@ namespace SlnMesnac.WPF.Page
List<BaseConfigInfo> configInfos = _configInfoBusiness.GetConfigInfos();
BaseConfigInfo configInfo = configInfos.Where(x => x.ConfigKey == "烘干机螺旋频率设定值").FirstOrDefault();
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), temp/100);
plc.writeInt16ByAddress(baseBusiness.GetPlcAddressByConfigKey("烘干机温度设定"), temp*10);
configInfo.ConfigValue = HotTempTxt.Text;

@ -38,9 +38,9 @@
{
"configId": 1,
"plcType": "SiemensPlc",
// "plcIp": "192.168.2.220",
"plcIp": "127.0.0.1",
"plcPort": 103,
"plcIp": "192.168.2.220",
// "plcIp": "127.0.0.1",
"plcPort": 102,
"plcKey": "plc",
"isFlage": true
},

Loading…
Cancel
Save