Merge branch 'master' of http://www.scserverddns.top:13000/sc/DyeingComputer
This commit is contained in:
commit
9ddcbb99fa
5 files changed
+101
-26
No files matched your search
+45
-6
@@ -4,8 +4,10 @@ using System.Collections.Generic;
|
||||
using System.ComponentModel;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
@@ -18,6 +20,43 @@ namespace DyeingComputer
|
||||
/// </summary>
|
||||
public partial class App : Application
|
||||
{
|
||||
private static Assembly OnResolveAssembly(object sender, ResolveEventArgs args)
|
||||
{
|
||||
Assembly executingAssembly = Assembly.GetExecutingAssembly();
|
||||
var executingAssemblyName = executingAssembly.GetName();
|
||||
var resName = executingAssemblyName.Name + ".resources";
|
||||
|
||||
AssemblyName assemblyName = new AssemblyName(args.Name); string path = "";
|
||||
if (resName == assemblyName.Name)
|
||||
{
|
||||
path = executingAssemblyName.Name + ".g.resources"; ;
|
||||
}
|
||||
else
|
||||
{
|
||||
path = assemblyName.Name + ".dll";
|
||||
if (assemblyName.CultureInfo.Equals(CultureInfo.InvariantCulture) == false)
|
||||
{
|
||||
path = String.Format(@"{0}\{1}", assemblyName.CultureInfo, path);
|
||||
}
|
||||
}
|
||||
|
||||
using (Stream stream = executingAssembly.GetManifestResourceStream(path))
|
||||
{
|
||||
if (stream == null)
|
||||
return null;
|
||||
|
||||
byte[] assemblyRawBytes = new byte[stream.Length];
|
||||
stream.Read(assemblyRawBytes, 0, assemblyRawBytes.Length);
|
||||
return Assembly.Load(assemblyRawBytes);
|
||||
}
|
||||
}
|
||||
protected override void OnStartup(StartupEventArgs e)
|
||||
{
|
||||
base.OnStartup(e);
|
||||
AppDomain.CurrentDomain.AssemblyResolve += OnResolveAssembly;
|
||||
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
}
|
||||
|
||||
private UserClass.IniFile.IniFiles Configini = new UserClass.IniFile.IniFiles(Convert.ToString(System.AppDomain.CurrentDomain.BaseDirectory) + "DyeingComputer.ini");
|
||||
|
||||
public App()
|
||||
@@ -46,12 +85,12 @@ namespace DyeingComputer
|
||||
//return Container.Resolve<MainWindow>();
|
||||
}
|
||||
|
||||
protected override void OnStartup(StartupEventArgs e) //跟踪报错信息
|
||||
{
|
||||
base.OnStartup(e);
|
||||
//UI线程的异常捕捉
|
||||
this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
}
|
||||
// protected override void OnStartup(StartupEventArgs e) //跟踪报错信息
|
||||
// {
|
||||
// base.OnStartup(e);
|
||||
// //UI线程的异常捕捉
|
||||
// this.DispatcherUnhandledException += App_DispatcherUnhandledException;
|
||||
// }
|
||||
|
||||
private void App_DispatcherUnhandledException(object sender, System.Windows.Threading.DispatcherUnhandledExceptionEventArgs e)
|
||||
{
|
||||
|
||||
@@ -61,6 +61,25 @@
|
||||
<PropertyGroup>
|
||||
<ApplicationIcon>LOGO\sunlight_logo.ico</ApplicationIcon>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x64'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x64\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x64'">
|
||||
<OutputPath>bin\x64\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.ComponentModel.DataAnnotations" />
|
||||
@@ -387,4 +406,11 @@
|
||||
</BootstrapperPackage>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
<Target Name="AfterResolveReferences">
|
||||
<ItemGroup>
|
||||
<EmbeddedResource Include="@(ReferenceCopyLocalPaths)" Condition="'%(ReferenceCopyLocalPaths.Extension)' == '.dll'">
|
||||
<LogicalName>%(ReferenceCopyLocalPaths.DestinationSubDirectory)%(ReferenceCopyLocalPaths.Filename)%(ReferenceCopyLocalPaths.Extension)</LogicalName>
|
||||
</EmbeddedResource>
|
||||
</ItemGroup>
|
||||
</Target>
|
||||
</Project>
|
||||
@@ -6,5 +6,7 @@
|
||||
xmlns:local="clr-namespace:DyeingComputer.View"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
||||
<Grid/>
|
||||
<Grid>
|
||||
<DataGrid HorizontalAlignment="Left" Height="152" Margin="69,315,0,0" VerticalAlignment="Top" Width="282" d:ItemsSource="{d:SampleData ItemCount=5}"/>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -6,5 +6,8 @@
|
||||
xmlns:local="clr-namespace:DyeingComputer.View"
|
||||
mc:Ignorable="d"
|
||||
d:DesignHeight="630" d:DesignWidth="1280" VerticalAlignment="Top">
|
||||
<Grid/>
|
||||
<Grid>
|
||||
<DataGrid HorizontalAlignment="Left" Height="264" Margin="783,195,0,0" VerticalAlignment="Top" Width="394" d:ItemsSource="{d:SampleData ItemCount=5}"/>
|
||||
|
||||
</Grid>
|
||||
</UserControl>
|
||||
@@ -233,8 +233,7 @@ namespace DyeingComputer.ViewModel
|
||||
if (!string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Name_err.ToString();
|
||||
}
|
||||
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
||||
{
|
||||
Name_err = "";
|
||||
{
|
||||
if (!LINK_OK) Modbus_link();
|
||||
|
||||
if (string.IsNullOrEmpty(Name_err.ToString()) && ((Selet_dtm("1010") < 10) || (Selet_dtm("1010") > 160)))
|
||||
@@ -988,6 +987,7 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
LogGing.LogGingDATA("800_SerialPort_Not");
|
||||
LogGing.LogGingDATA(e.Message);
|
||||
Name_err = "800_SerialPort_Not";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1007,24 +1007,29 @@ namespace DyeingComputer.ViewModel
|
||||
readonly byte slaveId = 1;
|
||||
private async void Modbus_link()
|
||||
{
|
||||
await Task.Run(() =>
|
||||
if (Name_err.ToString() != "800_SerialPort_Not")
|
||||
{
|
||||
LINK_RUN++;
|
||||
try
|
||||
await Task.Run(() =>
|
||||
{
|
||||
master.WriteMultipleCoils(slaveId, 00000, DQ); //写入线圈
|
||||
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
||||
DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈
|
||||
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
||||
LINK_OK = true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LINK_OK = false;
|
||||
LINK_ERR++;
|
||||
Name_err = "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")";
|
||||
}
|
||||
});
|
||||
LINK_RUN++;
|
||||
try
|
||||
{
|
||||
master.WriteMultipleCoils(slaveId, 00000, DQ); //写入线圈
|
||||
master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器
|
||||
DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈
|
||||
RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器
|
||||
LINK_OK = true;
|
||||
Name_err = "";
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LINK_OK = false;
|
||||
LINK_ERR++;
|
||||
Name_err = "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")";
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
void LOG_view()//细节页面
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user