Selaa lähdekoodia

包升级

样式分支
pry 2 vuotta sitten
vanhempi
commit
5ac12cc56b
14 muutettua tiedostoa jossa 47 lisäystä ja 47 poistoa
  1. +1
    -1
      BPASmartClient.Device/BPASmartClient.Device.csproj
  2. +0
    -3
      BPASmartClient.Device/BaseDevice.cs
  3. +0
    -0
      BPASmartClient.MORKSM.BK.PLC/BPASmartClient.PLC.csproj
  4. +3
    -10
      BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs
  5. +5
    -1
      BPASmartClient.Modbus/ModbusTcp.cs
  6. +1
    -1
      BPASmartClient.Model/BPASmartClient.Model.csproj
  7. +1
    -1
      BPASmartClient.MorkS/BPASmartClient.MorkS.csproj
  8. +0
    -13
      BPASmartClient.MorkS/Control.cs
  9. +1
    -4
      BPASmartClient.MorkT/BPASmartClient.MorkT.csproj
  10. +21
    -0
      BPASmartClient/App.xaml.cs
  11. +1
    -1
      BPASmartClient/Control/LogView.xaml
  12. +1
    -1
      BPASmartClient/DeviceInfo.xml
  13. +11
    -10
      BPASmartClient/MainWindow.xaml.cs
  14. +1
    -1
      SmartClient.sln

+ 1
- 1
BPASmartClient.Device/BPASmartClient.Device.csproj Näytä tiedosto

@@ -5,7 +5,7 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.9" />
<PackageReference Include="BPA.Message" Version="1.0.11" />
</ItemGroup>

<ItemGroup>


+ 0
- 3
BPASmartClient.Device/BaseDevice.cs Näytä tiedosto

@@ -16,9 +16,6 @@ namespace BPASmartClient.Device
{
public BaseDevice()
{
var t = this.GetType();
// t.Name 是继承该类的一个实体类名
// t.Namespace 是继承该类的一个实体类的命名空间
}

/// <summary>


BPASmartClient.MORKSM.BK.PLC/BPASmartClient.MORKSM.BK.PLC.csproj → BPASmartClient.MORKSM.BK.PLC/BPASmartClient.PLC.csproj Näytä tiedosto


+ 3
- 10
BPASmartClient.MORKSM.BK.PLC/MorksMachine.cs Näytä tiedosto

@@ -7,7 +7,7 @@ using static BPASmartClient.EventBus.EventBus;
using BPASmartClient.Model;
using BPASmartClient.Model.PLC;

namespace BPASmartClient.MORKSM.BK.PLC
namespace BPASmartClient.PLC
{
public class MorksMachine : BasePeripheral
{
@@ -18,7 +18,8 @@ namespace BPASmartClient.MORKSM.BK.PLC

public override void Init()
{
modbusTcp.ModbusTcpConnect(IpAddress, Port);
modbusTcp.ModbusTcpConnect(IpAddress, Port);//PLC 设备连接

//读取数据
EventBus.EventBus.GetInstance().Subscribe<ReadModel>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
{
@@ -28,7 +29,6 @@ namespace BPASmartClient.MORKSM.BK.PLC
object readData = new object();
if (par.Address.ToUpper().Contains("M"))
{
//modbusTcp.Read(address, CommandType.Coils, par.Length);
modbusTcp.Readbool(address, par.Length, new Action<bool[]>((s) => { readData = s; }));
}
else if (par.Address.ToUpper().Contains("VW"))
@@ -36,7 +36,6 @@ namespace BPASmartClient.MORKSM.BK.PLC
readData = modbusTcp.Read(address, CommandType.HoldingRegisters, par.Length);
}
callBack?.Invoke(readData);
//callBack = new EventCallBackHandle(readData);
});

//写入数据
@@ -54,12 +53,6 @@ namespace BPASmartClient.MORKSM.BK.PLC
modbusTcp.Write(address, CommandType.HoldingRegisters, par.Value);
}
});

////批量读取数据
//EventBus.EventBus.GetInstance().Subscribe<>(DeviceId, delegate (IEvent @event, EventCallBackHandle callBack)
//{

//});
}

public override void Start()


+ 5
- 1
BPASmartClient.Modbus/ModbusTcp.cs Näytä tiedosto

@@ -49,7 +49,6 @@ namespace BPASmartClient.Modbus
MessageLog.GetInstance.Show($"设备【{ip}:{port}】连接成功");
}


private void Connect()
{
bool ErrorFlag = false;
@@ -74,6 +73,11 @@ namespace BPASmartClient.Modbus
MessageLog.GetInstance.Show("ModbusTcp 连接成功!");
}

/// <summary>
/// 获取 M 区 和 VW 区的Modbus的地址
/// </summary>
/// <param name="address"></param>
/// <returns></returns>
public int GetAddress(string address)
{
if (address == null) return -1;


+ 1
- 1
BPASmartClient.Model/BPASmartClient.Model.csproj Näytä tiedosto

@@ -15,7 +15,7 @@
</ItemGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.9" />
<PackageReference Include="BPA.Message" Version="1.0.11" />
</ItemGroup>

</Project>

+ 1
- 1
BPASmartClient.MorkS/BPASmartClient.MorkS.csproj Näytä tiedosto

@@ -8,7 +8,7 @@
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.EventBus\BPASmartClient.EventBus.csproj" />
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" />
<ProjectReference Include="..\BPASmartClient.MORKSM.BK.PLC\BPASmartClient.MORKSM.BK.PLC.csproj" />
<ProjectReference Include="..\BPASmartClient.MORKSM.BK.PLC\BPASmartClient.PLC.csproj" />
</ItemGroup>

</Project>

+ 0
- 13
BPASmartClient.MorkS/Control.cs Näytä tiedosto

@@ -32,8 +32,6 @@ namespace BPASmartClient.MorkS
int OrderCount;
bool Initing;



public override void StartMain()
{
ServerInit();
@@ -137,8 +135,6 @@ namespace BPASmartClient.MorkS
}));

ReadData("M235.0", 1, new Action<bool[]>((bools) => { mORKS.Error = bools[0]; }));
//var errorStatus = ModbusTcpHelper.GetInstance.Read((ushort)ModbusTcpHelper.GetInstance.GetBoolAddress("M235.0"), ReadType.Coils, 1);
//if (errorStatus != null && errorStatus is bool error) mORKS.Error = error;

ReadData("M102.0", 7, new Action<bool[]>((bools) =>
{
@@ -184,15 +180,6 @@ namespace BPASmartClient.MorkS
}
});

//var ResLoc = ModbusTcpHelper.GetInstance.Read(286, ReadType.HoldingRegisters);
//if (ResLoc != null)
//{
// if (ResLoc is ushort loc)
// {
// mORKS.TurntableFeedbackloc = loc;
// }
//}

Thread.Sleep(500);
}), "ReadPLCData", true);
}


+ 1
- 4
BPASmartClient.MorkT/BPASmartClient.MorkT.csproj Näytä tiedosto

@@ -4,12 +4,9 @@
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="BPA.Message" Version="1.0.9" />
</ItemGroup>

<ItemGroup>
<ProjectReference Include="..\BPASmartClient.Device\BPASmartClient.Device.csproj" />
<ProjectReference Include="..\BPASmartClient.Model\BPASmartClient.Model.csproj" />
</ItemGroup>

</Project>

+ 21
- 0
BPASmartClient/App.xaml.cs Näytä tiedosto

@@ -23,6 +23,7 @@ namespace BPASmartClient
base.OnStartup(e);
SystemHelper.GetInstance.CreateDesktopShortcut();
AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
DataRead();
MainWindow mainView = new MainWindow();
mainView.Show();
SplitScreenDisplay();
@@ -78,6 +79,7 @@ namespace BPASmartClient
var ErroLog = e.ExceptionObject.ToString();
MessageLog.GetInstance.Show(ErroLog);
TextHelper.GetInstance.WriteTextInfo(ErroLog, "ErroLog");
DataSave();
//SqlHelper.GetInstance.Save();
//MainConsole.Main.GetInstance.DataSave();
//IotReport.GetInstance.HttpAddLog(new BPA.Message.API请求.LogTable
@@ -94,6 +96,7 @@ namespace BPASmartClient
protected override void OnExit(ExitEventArgs e)
{
base.OnExit(e);
DataSave();
//IotReport.Close();
//SqlHelper.GetInstance.Save();
//MainConsole.Main.GetInstance.DataSave();
@@ -101,5 +104,23 @@ namespace BPASmartClient
System.Environment.Exit(0);

}

/// <summary>
/// 输入保存
/// </summary>
private void DataSave()
{
Json<KeepDataBase>.Save();
}

/// <summary>
/// 输入读取
/// </summary>
private void DataRead()
{
Json<KeepDataBase>.Read();
}


}
}

+ 1
- 1
BPASmartClient/Control/LogView.xaml Näytä tiedosto

@@ -52,7 +52,7 @@
<DataGridTemplateColumn Header="日志内容" Width="*">
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center" Text="{Binding message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
<TextBlock HorizontalAlignment="Left" Text="{Binding message, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" FontSize="14" Foreground="{Binding foreground, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>


+ 1
- 1
BPASmartClient/DeviceInfo.xml Näytä tiedosto

@@ -21,7 +21,7 @@

<Device Name="MorkS" Module="BPASmartClient.MorkS.Control" DeviceId="2">
<Peripherals>
<Peripheral Module="BPASmartClient.MORKSM.BK.PLC.MorksMachine">
<Peripheral Module="BPASmartClient.PLC.MorksMachine">
<Parameters>
<IpAddress>127.0.0.1</IpAddress>
<Port>502</Port>


+ 11
- 10
BPASmartClient/MainWindow.xaml.cs Näytä tiedosto

@@ -2,6 +2,7 @@
using BPASmartClient.Business;
using BPASmartClient.CustomResource.UserControls;
using BPASmartClient.CustomResource.UserControls.MessageShow;
using BPASmartClient.Device;
using BPASmartClient.EventBus;
using BPASmartClient.Helper;
using BPASmartClient.Message;
@@ -55,12 +56,12 @@ namespace BPASmartClient
}
this.DragMove();
};
MenuItem_Click(new MenuItem() { Tag = "LogView",Header = "日志监视" },null);
MenuItem_Click(new MenuItem() { Tag = "LogView", Header = "日志监视" }, null);

ThreadManage.GetInstance().Start(new Action(() =>
{
new MainConsole().Start();
}),"启动主控制台");
}), "启动主控制台");
}
#endregion

@@ -75,7 +76,7 @@ namespace BPASmartClient
if (sender is MenuItem)
{
Type type = Type.GetType($"BPASmartClient.Control.{(sender as MenuItem).Tag?.ToString()}");
if (type == null){MenuClick((sender as MenuItem).Tag?.ToString());return; }
if (type == null) { MenuClick((sender as MenuItem).Tag?.ToString()); return; }
ConstructorInfo cti = type.GetConstructor(System.Type.EmptyTypes);
contentRegion.Content = (FrameworkElement)cti.Invoke(null);
Title.Text = (sender as MenuItem).Header?.ToString() + "界面";
@@ -116,23 +117,23 @@ namespace BPASmartClient


#region 临时测试代码
private void Button_Click(object sender,RoutedEventArgs e)
private void Button_Click(object sender, RoutedEventArgs e)
{
//new Demo_MakeCoffeeEvent() { Id = 1 }.Publish();
//new DRCoffee_MakeCoffeeEvent() { Id = 1, DrinkCode= DrCoffeeDrinksCode.两杯意式浓缩 }.Publish();
//new DRCoffee_CoffeeCommCmdEvent() { Id = 1,CommCmd = DrCoffeeCommCmd.冲煮系统快速冲洗指令}.Publish();

MorkOrderPush morkOrderPush = new MorkOrderPush() { DeviceId = 2 };
var temp = BPAPackage.Make(morkOrderPush,12,BPA.Message.Enum.DeviceClientType.MORKS);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish("DOWN/MORKS/ORDER/12",temp.Serialize());
var temp = BPAPackage.Make(morkOrderPush, 12, BPA.Message.Enum.DeviceClientType.MORKS);
Plugin.GetInstance().GetPlugin<MQTTMgr>().Publish("DOWN/MORKS/ORDER/12", temp.Serialize());
}

private void Button_Click_1(object sender, RoutedEventArgs e)
{
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success,this,"我是标题","我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, this, "我是标题", "我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Error, this, "我是标题", "我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, this, "我是标题", "我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
NoticeDemoViewModel.OpenMsg(EnumPromptType.Success, this, "我是标题", "我是消息内容!我是消息内容!我是消息内容!我是消息内容!");
}
#endregion



+ 1
- 1
SmartClient.sln Näytä tiedosto

@@ -72,7 +72,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.CustomResour
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Lebai.SDK", "Lebai.SDK\Lebai.SDK.csproj", "{3A55F68A-D526-4CFC-A5A6-B69FB76716C2}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.MORKSM.BK.PLC", "BPASmartClient.MORKSM.BK.PLC\BPASmartClient.MORKSM.BK.PLC.csproj", "{7F04A788-38B5-42CB-B601-70C657C953B8}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BPASmartClient.PLC", "BPASmartClient.MORKSM.BK.PLC\BPASmartClient.PLC.csproj", "{7F04A788-38B5-42CB-B601-70C657C953B8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution


Ladataan…
Peruuta
Tallenna