Commit 06c79fd5 authored by liu's avatar liu

主要将libmodbus slave改用nmodbus4 slave 用以解决modbus slave组分输出时间过程卡住的问题,其次修改了自定义控件实施谱图上单位显示问题和增加了多网口时可选择

parent edc81683
......@@ -5,12 +5,12 @@ VisualStudioVersion = 15.0.27428.2002
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GcDevicePc", "GcDevicePc\GcDevicePc.csproj", "{BBCD58CB-247D-4108-A135-F36F8ABA3289}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "VocAnalyzer", "VocAnalyzer\VocAnalyzer.vdproj", "{8260B9BB-618D-42C5-9F82-9881AD0B65FA}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharedSpace", "SharedSpace\SharedSpace.csproj", "{5498F944-5721-461B-B07F-3105EF0BF643}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VocsMonitor", "VocsMonitor\VocsMonitor\VocsMonitor.csproj", "{25AB743D-235C-4F11-96C3-2356AC90BF81}"
EndProject
Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "VocAnalyzer", "VocAnalyzer\VocAnalyzer.vdproj", "{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
......@@ -33,12 +33,6 @@ Global
{BBCD58CB-247D-4108-A135-F36F8ABA3289}.Release|Mixed Platforms.Build.0 = Release|x86
{BBCD58CB-247D-4108-A135-F36F8ABA3289}.Release|x86.ActiveCfg = Release|x86
{BBCD58CB-247D-4108-A135-F36F8ABA3289}.Release|x86.Build.0 = Release|x86
{8260B9BB-618D-42C5-9F82-9881AD0B65FA}.Debug|Any CPU.ActiveCfg = Debug
{8260B9BB-618D-42C5-9F82-9881AD0B65FA}.Debug|Mixed Platforms.ActiveCfg = Debug
{8260B9BB-618D-42C5-9F82-9881AD0B65FA}.Debug|x86.ActiveCfg = Debug
{8260B9BB-618D-42C5-9F82-9881AD0B65FA}.Release|Any CPU.ActiveCfg = Release
{8260B9BB-618D-42C5-9F82-9881AD0B65FA}.Release|Mixed Platforms.ActiveCfg = Release
{8260B9BB-618D-42C5-9F82-9881AD0B65FA}.Release|x86.ActiveCfg = Release
{5498F944-5721-461B-B07F-3105EF0BF643}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{5498F944-5721-461B-B07F-3105EF0BF643}.Debug|Any CPU.Build.0 = Debug|Any CPU
{5498F944-5721-461B-B07F-3105EF0BF643}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
......@@ -61,6 +55,18 @@ Global
{25AB743D-235C-4F11-96C3-2356AC90BF81}.Release|Mixed Platforms.Build.0 = Release|Any CPU
{25AB743D-235C-4F11-96C3-2356AC90BF81}.Release|x86.ActiveCfg = Release|Any CPU
{25AB743D-235C-4F11-96C3-2356AC90BF81}.Release|x86.Build.0 = Release|Any CPU
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Debug|Any CPU.ActiveCfg = Debug
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Debug|Any CPU.Build.0 = Debug
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Debug|Mixed Platforms.ActiveCfg = Debug
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Debug|Mixed Platforms.Build.0 = Debug
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Debug|x86.ActiveCfg = Debug
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Debug|x86.Build.0 = Debug
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Release|Any CPU.ActiveCfg = Release
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Release|Any CPU.Build.0 = Release
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Release|Mixed Platforms.ActiveCfg = Release
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Release|Mixed Platforms.Build.0 = Release
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Release|x86.ActiveCfg = Release
{9A8B92E2-7CFA-43AE-8EC6-561827F41EF4}.Release|x86.Build.0 = Release
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
......
......@@ -42,7 +42,7 @@ namespace GcDevicePc
this.fid1ver.Text = this.FID1version;
this.fid2ver.Text = this.FID2version;
this.tcdver.Text = this.TCD1version;
this.PCver.Text = this.Hmiversion + "/1.4.8";
this.PCver.Text = this.Hmiversion + "/1.4.9";
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
</configSections>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<runtime>
<legacyUnhandledExceptionPolicy enabled="true"/>
<legacyUnhandledExceptionPolicy enabled="true" />
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Data.SQLite" publicKeyToken="db937bc2d44ff139" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.0.104.0" newVersion="1.0.104.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
<log4net>
......
......@@ -316,7 +316,7 @@
// if (hmicount >= 1)
// {
// ip = (((globaldata.DeviceInfo) (mysearch.myHMIList[0])).IpAddr);
// globaldata.connection_ip = ip;
//globaldata.connection_ip = ip;
// mysearch.ThStop();
// break;
// }
......@@ -416,7 +416,7 @@ namespace GcDevicePc
/// </summary>
public void InitDeviceInfo()
{
int checkflag = 0;
//int checkflag = 0;
int ret = 0;
int initret = 0;
......@@ -650,7 +650,7 @@ namespace GcDevicePc
"RunMethod.ini"
};
int checkflag = 0;
//int checkflag = 0;
int ret = 0;
int initret = 0;
......@@ -782,10 +782,20 @@ namespace GcDevicePc
{
try
{
string file = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.StartupPath), "GC_Config\\GC_Set\\启动参数\\startup.ini");
INIOperation test = new INIOperation(file);
string Meshport = test.INIGetStringValue("NetWorkConfig", "网口", null);
if (string.IsNullOrEmpty(Meshport))
{
Meshport = "本地连接";
}
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
if (adapter.Name == "本地连接")
if (adapter.Name == Meshport)
{
bool pd1 = (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet || adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211);
if (pd1)
......@@ -795,7 +805,11 @@ namespace GcDevicePc
foreach (UnicastIPAddressInformation ipadd in ipCollection)
{
if (ipadd.Address.AddressFamily == AddressFamily.InterNetwork)
{
localip = ipadd.Address.ToString();
globaldata.myIpaddr = ipadd.Address;
}
}
if (!String.IsNullOrEmpty(localip))
......
......@@ -39,7 +39,7 @@
this.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.None;
this.Name = "CurveDisPlay";
this.Text = "实时图谱";
this.Text = "实时谱图";
this.ResumeLayout(false);
}
......
......@@ -275,7 +275,9 @@ namespace GcDevicePc.CK_UI
}
else
{//此处计算成mg/m3 nmhc
textBox1.Text = Math.Round(listNmoc[listNmoc.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox1.Text = Math.Round(listNmoc[listNmoc.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox1.Text = Math.Round(listNmoc[listNmoc.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listNmoc[listNmoc.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -294,7 +296,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox2.Text = Math.Round(listTHC[listTHC.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox2.Text = Math.Round(listTHC[listTHC.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox2.Text = Math.Round(listTHC[listTHC.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listTHC[listTHC.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -315,7 +319,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox3.Text = Math.Round(listCH4[listCH4.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox3.Text = Math.Round(listCH4[listCH4.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox3.Text = Math.Round(listCH4[listCH4.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listCH4[listCH4.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -404,7 +410,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox1.Text = Math.Round(listNmoc[listNmoc.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox1.Text = Math.Round(listNmoc[listNmoc.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox1.Text = Math.Round(listNmoc[listNmoc.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listNmoc[listNmoc.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -423,7 +431,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox2.Text = Math.Round(listTHC[listTHC.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox2.Text = Math.Round(listTHC[listTHC.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox2.Text = Math.Round(listTHC[listTHC.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listTHC[listTHC.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -442,7 +452,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox3.Text = Math.Round(listCH4[listCH4.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox3.Text = Math.Round(listCH4[listCH4.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox3.Text = Math.Round(listCH4[listCH4.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listCH4[listCH4.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -462,7 +474,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox4.Text = Math.Round(listben[listben.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox4.Text = Math.Round(listben[listben.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox4.Text = Math.Round(listben[listben.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listben[listben.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -481,7 +495,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox5.Text = Math.Round(listjiaben[listjiaben.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox5.Text = Math.Round(listjiaben[listjiaben.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox5.Text = Math.Round(listjiaben[listjiaben.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listjiaben[listjiaben.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......@@ -500,7 +516,9 @@ namespace GcDevicePc.CK_UI
}
else
{
textBox6.Text = Math.Round(listerjiaben[listerjiaben.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
textBox6.Text = Math.Round(listerjiaben[listerjiaben.Count - 1].Y, 2).ToString() + "mg/m³";
//textBox6.Text = Math.Round(listerjiaben[listerjiaben.Count - 1].Y / (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 12) * (CKVocAnalyzer.GlobalCKV.vocparamlist[i].MWeight / 22.4), 2).ToString() + "mg/m³";
}
if (listerjiaben[listerjiaben.Count - 1].Y >= CKVocAnalyzer.GlobalCKV.vocparamlist[i].WaringValue)
......
......@@ -4,6 +4,12 @@ using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
using GcDevicePc.IniParam;
using Modbus.Device;
using System.Net;
using System.Data;
using System.Net.Sockets;
using Modbus.Data;
using System.Threading;
namespace GcDevicePc.Common
{
......@@ -51,7 +57,10 @@ namespace GcDevicePc.Common
try
{
fnLibModbusSlaveClose(hModbusHandle);
}catch
//slave.Dispose();
}
catch
{
}
......@@ -63,6 +72,9 @@ namespace GcDevicePc.Common
try
{
ret = fnLibModbusSlaveClose(hModbusHandle);
//slave.Dispose();
}
catch
{
......@@ -73,10 +85,13 @@ namespace GcDevicePc.Common
}
public void CModbusSlaveInit(ushort hstartaddr, ushort hnreg, ushort cstartaddr, ushort cnreg)
{
setHoldingRegisterFunc(hstartaddr, hnreg);
//setHoldingRegisterFunc(hstartaddr, hnreg);
setCoilsRegisterFunc(cstartaddr, cnreg);
}
SlaveReadHoldingRegister MySlaveReadHoldingRegister;
......@@ -123,7 +138,8 @@ namespace GcDevicePc.Common
f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString());
Buffer.BlockCopy(f, 2, s, 0, 2);
Buffer.BlockCopy(f, 0, s, 2, 2);
value = s[(address - baseaddress) % 2];
//value = s[(address - baseaddress) % 2];
value = address;
}
else
{
......@@ -687,10 +703,5 @@ namespace GcDevicePc.Common
{
//Console.WriteLine("MoudbusSlave Wirte adder:" + address.ToString() + " value:" + value.ToString());
}
}
}
......@@ -68,7 +68,6 @@ namespace GcDevicePc.Common
return ret;
}
public void CModbusSlave485Init(ushort hstartaddr, ushort hnreg, ushort cstartaddr, ushort cnreg)
{
setHoldingRegisterFunc(hstartaddr, hnreg);
......
using GcDevicePc.IniParam;
using Modbus.Data;
using Modbus.Device;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
namespace GcDevicePc.Common
{
class NModbusSlave
{
private ModbusSlave slave;
public NModbusSlave()
{
listener = new TcpListener(IPAddress.Any, 502);// 端口根据需要确定
listener.Start();
slave = ModbusTcpSlave.CreateTcp(1, listener);
slave.DataStore = DataStoreFactory.CreateDefaultDataStore();
slave.DataStore.DataStoreWrittenTo += new EventHandler<DataStoreEventArgs>(Modbus_DataStoreWriteTo);
slave.ModbusSlaveRequestReceived += new EventHandler<ModbusSlaveRequestEventArgs>(Modbus_Request_Event);
slave.DataStore.DataStoreReadFrom += new EventHandler<DataStoreEventArgs>(DataStore_DataStoreReadFrom);
slave.DataStore.DataStoreWrittenTo += new EventHandler<DataStoreEventArgs>(DataStore_DataStoreWrittenTo);
slave.Listen();
//// 后台线程1:用于接收tcp连接请求,并将网络流加入列表。随主线程的退出而退出。
//new Thread(() =>
//{
// while (true)
// {
// Thread.Sleep(100);// 可以根据需要设置时间
// if (!listener.Pending())
// {
// continue;
// }
// var client = listener.AcceptTcpClient();
// // 下面属性根据需要进行设置
// // client.ReceiveBufferSize
// // client.ReceiveTimeout
// // client.SendBufferSize
// // client.SendTimeout
// if (!client.Connected)
// {
// continue;
// }
// streams.Add(client.GetStream());
// }
//})
//{ IsBackground = true }.Start();
//// 后台线程2:用于接收请求,并作出响应。随主线程的退出而退出。
//new Thread(() =>
//{
// while (true)
// {
// Thread.Sleep(100);// 可以根据需要设置时间
// if (streams == null || streams.Count == 0)
// {
// continue;
// }
// streams = streams.Where(s => s.CanRead && s.CanWrite).ToList();
// foreach (var stream in streams.Where(stream => stream.CanRead && stream.CanWrite))
// {
// AsyncReceiveBytes(stream,
// s =>
// {
// // todo:对result进行解码
// // todo:对收到指令进行逻辑判断,得出待响应的C#对象
// AsyncSendBytes(s, new byte[0]); // todo:将待响应的C#对象转换成字节数组,替换new byte[0]。
// });
// }
// }
//})
//{ IsBackground = true }.Start();
}
public void NModbusSlaveClose()
{
//listener.Stop();
//slave.Dispose();
}
~NModbusSlave()
{
listener.Stop();
slave.Dispose();
}
// 发送事件和目标的入口
//public void SendEventAndTarget()
//{
// if (streams == null || streams.Count == 0)
// {
// return;
// }
// streams = streams.Where(s => s.CanRead && s.CanWrite).ToList();
// foreach (var stream in streams.TakeWhile(stream => stream.CanWrite))
// {
// AsyncSendBytes(stream, new byte[0]);// todo:这里将待发送的C#对象转换的字节数组替换new byte[0]。
// }
//}
//private static void AsyncReceiveBytes(NetworkStream stream,
// Action<NetworkStream> callback)
//{
// // 短时后台线程:用于处理网络流的读操作,处理完成后即归还线程池。
// // 每个网络流都会分配一个线程。
// //ThreadPool.SetMaxThreads();根据需要设置。
// ThreadPool.QueueUserWorkItem(delegate
// {
// var buffer = new byte[1024];// 1024:根据需要进行设置。
// var result = new byte[0];
// do
// {
// var a = stream.Read(buffer, 0, buffer.Length);
// result = result.Concat(buffer.Take(a)).ToArray();
// } while (stream.DataAvailable);
// callback(stream);
// });
//}
//private static void AsyncSendBytes(NetworkStream stream, byte[] bytes)
//{
// // 短时后台线程:用于处理网络流的写操作,处理完成后即归还线程池。
// // 每个网络流都会分配一个线程。
// //ThreadPool.SetMaxThreads();根据需要设置。
// ThreadPool.QueueUserWorkItem(delegate
// {
// try
// {
// stream.Write(bytes, 0, bytes.Count());
// }
// catch (Exception)
// {
// Console.WriteLine("远程主机主动断开此连接!");// 也可以做其它处理。
// }
// });
//}
private readonly TcpListener listener;
// 网络流列表
//private List<NetworkStream> streams = new List<NetworkStream>();
private void DataStore_DataStoreWrittenTo(object sender, DataStoreEventArgs e)
{
}
private void DataStore_DataStoreReadFrom(object sender, DataStoreEventArgs e)
{
//int iAddress = e.StartAddress;
try
{
//if (e.ModbusDataType == ModbusDataType.HoldingRegister)
//{
// //for (int i = 0; i < e.Data.B.Count; i++)
// {
// //Set AO
// //e.Data.B[i] already write to
// //slave.DataStore.HoldingRegisters[e.StartAddress + i + 1] = slavereadhreg(Convert.ToUInt16(e.StartAddress + i + 1));
// //e.StartAddress starts from 0
// //You can set AO value to hardware here
// }
// slave.DataStore.HoldingRegisters[e.StartAddress + 1] = slavereadhreg(Convert.ToUInt16(e.StartAddress + 1));
//}
switch (e.ModbusDataType)
{
case ModbusDataType.HoldingRegister:
for (int i = 0; i < e.Data.B.Count; i++)
{
//Set AO
//e.Data.B[i] already write to
//slave.DataStore.HoldingRegisters[e.StartAddress + i + 1] = 1;
slave.DataStore.HoldingRegisters[e.StartAddress + i + 1] = slavereadhreg(Convert.ToUInt16(e.StartAddress + i + 1));
//e.StartAddress starts from 0
//You can set AO value to hardware here
}
break;
case ModbusDataType.Coil:
for (int i = 0; i < e.Data.A.Count; i++)
{
//set DO
//e.Data.A[i] already write to
slave.DataStore.CoilDiscretes[e.StartAddress + i + 1] = slavereadcreg(Convert.ToUInt16(e.StartAddress + i + 1)) == 0 ? false : true;
//e.StartAddress starts from 0
//You can set DO value to hardware here
}
break;
}
}
catch
{
}
}
private void Modbus_DataStoreWriteTo(object sender, DataStoreEventArgs e)
{
try
{
//if (e.ModbusDataType == ModbusDataType.HoldingRegister)
//{
// //for (int i = 0; i < e.Data.B.Count; i++)
// //{
// // Console.WriteLine("[" + i + "] " + e.Data.B[i]);
// //}
// slavewirtehreg(e.StartAddress, e.Data.B[e.StartAddress]);
//}
switch (e.ModbusDataType)
{
case ModbusDataType.HoldingRegister:
slavewirtehreg(e.StartAddress, e.Data.B[e.StartAddress]);
break;
case ModbusDataType.Coil:
break;
}
}
catch
{
}
}
//trigger Modbus_Request_Event
private void Modbus_Request_Event(object sender, ModbusSlaveRequestEventArgs e)
{
//disassemble packet from master
//byte fc = e.Message.FunctionCode;
//byte[] data = e.Message.MessageFrame;
//byte[] byteStartAddress = new byte[] { data[3], data[2] };
//byte[] byteNum = new byte[] { data[5], data[4] };
//Int16 StartAddress = BitConverter.ToInt16(byteStartAddress, 0);
//Int16 NumOfPoint = BitConverter.ToInt16(byteNum, 0);
//Console.WriteLine(fc.ToString() + "," + StartAddress.ToString() + "," +
//NumOfPoint.ToString());
//Console.WriteLine("asdadas");
}
static ushort slavereadhreg(ushort address)
{
try
{
ushort value = 0;
ushort signalddress = 17;
ushort baseaddress = 23;
address = (ushort)(address - 1);
int listnum = SharedSpace.Data.listValue.Count;
if (address >= 17)
{
ushort[] s = new ushort[2];
float[] f = new float[2];
if (address >= 17 && address <= 22) //信号输出
{
if (address == 17 || address == 18)
f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.fDetValue.ToString("0.000"));
if (address == 19 || address == 20)
f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.iDetValue.ToString("0.000"));
if (address == 21 || address == 22)
f[0] = float.Parse(globaldata.m_dpbuffer.ShowList.showDet.bDetValue.ToString("0.000"));
Buffer.BlockCopy(f, 2, s, 0, 2);
Buffer.BlockCopy(f, 0, s, 2, 2);
value = s[(address - signalddress) % 2];
}
else if (address >= 23 && listnum > 0) //组分输出
{
int readnum = (address - baseaddress) / 2;
if (readnum <= listnum - 1)
{
f[0] = float.Parse(SharedSpace.Data.listValue[readnum].vale.ToString());
Buffer.BlockCopy(f, 2, s, 0, 2);
Buffer.BlockCopy(f, 0, s, 2, 2);
value = s[(address - baseaddress) % 2];
//value = address;
}
else
{
value = 0;
}
}
else
{
value = 0;
}
}
//分析仪状态
if (address >= 1 && address < 20)
{
switch (address)
{
case 1: //进度
{
if ((ushort)SharedSpace.Data.typesint == 1 || (ushort)SharedSpace.Data.typesint == 2)
{
if (SharedSpace.MControl.dateend != 0 && SharedSpace.MControl.zhouqi != 0)
{
value = (ushort)((globaldata.m_hmibuffer.gcinfo.batruncount * 1.0f) /
(ushort)(SharedSpace.MControl.dateend * 1.0f /
SharedSpace.MControl.zhouqi) * 1000);
}
else
{
value = 0;
}
}
else
{
value = 0;
}
}
break;
case 2: // 0-正在采样(默认) 1-手动 2-定时 3-校准成功 4-校准失败 5-校准成功(正在采样) 6-校准失败(正在采样)
{
if (!SharedSpace.MControl.SetOut && !SharedSpace.MControl.SetRun)
{
if ((ushort)SharedSpace.Data.typesint == 3)
value = 5;
else if ((ushort)SharedSpace.Data.typesint == 4)
value = 6;
else
value = (ushort)SharedSpace.Data.typesint;
}
else
{
value = (ushort)SharedSpace.Data.typesint;
}
}
break;
case 3:
{
value = SharedSpace.Data.change == true ? (ushort)1 : (ushort)0;
}
break;
case 4:
{
value = globaldata.m_hmibuffer.gcinfo.HMIMac[0];
}
break;
case 5:
{
value = globaldata.m_hmibuffer.gcinfo.HMIMac[1];
}
break;
case 6:
{
value = globaldata.m_hmibuffer.gcinfo.HMIMac[2];
}
break;
case 7: //设备联机状态
{
value = (ushort)(globaldata.m_hmibuffer.gcinfo.hmioffline ? 1 : 0);
}
break;
case 8: //HMI状态
{
value = globaldata.m_hmibuffer.gcinfo.methodstatus;
}
break;
case 9: //前进样口
{
if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.FPActualTemp * 10);
}
else
{
value = 0;
}
}
break;
case 10: //后进样口
{
if (CProfileDevice.m_DevParam.syspara.u16InjPortBehind == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.BPActualTemp * 10);
}
else
{
value = 0;
}
}
break;
case 11: // 柱箱
{
if (CProfileDevice.m_DevParam.syspara.u16Col == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.ColActualTemp * 10);
}
else
{
value = 0;
}
}
break;
case 12: //前检测器
{
if (CProfileDevice.m_DevParam.syspara.u16InjPortFront == 1)
{
if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 0)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
}
else if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.fDetActualTemp * 10);
}
else
{
value = 0;
}
}
else
{
value = 0;
}
}
break;
case 13: //中检测器
{
if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
{
if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 0)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
}
else if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.iDetActualTemp * 10);
}
else
{
value = 0;
}
}
else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater1 == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp1 * 10);
}
else
{
value = 0;
}
}
break;
case 14: //后检测器
{
if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
{
if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 0)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
}
else if (CProfileDevice.m_DevParam.syspara.u16DetBehindType == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.bDetActualTemp * 10);
}
else if (CProfileDevice.m_DevParam.syspara.u16AuxHeater2 == 1)
{
value = (ushort)(globaldata.m_dpbuffer.ShowList.showtemp.AuxActualTemp2 * 10);
}
else
{
value = 0;
}
}
else
{
value = 0;
}
}
break;
case 15: //前点火信号
{
if (CProfileDevice.m_DevParam.syspara.u16DetFrontType == 1)
{
value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
}
else
{
value = 0;
}
}
break;
case 16: //后点火信号
{
if (CProfileDevice.m_DevParam.syspara.u16DetInterType == 1)
{
value = globaldata.m_dpbuffer.ShowList.showDet.fDetStatue;
}
else
{
value = 0;
}
}
break;
}
}
return value;
}
catch (Exception e)
{
Console.WriteLine("异常" + e.Message);
return 0;
}
}
static void slavewirtehreg(ushort address, ushort value)
{
if (address == 100 || address == 99 || address == 101)
{
if (value == 1)
{
CurveDisPlay.curdisp.SetAutoAdjust();
}
else if (value == 0)
{
CurveDisPlay.curdisp.StopAutoAdjust();
}
}
Log.Info("MoudbusSlave Wirte adder:" + address.ToString() + " value:" + value.ToString());
}
public static ushort slavereadcreg(ushort address)
{
ushort value = 0;
switch (address)
{
case 16:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[0];
break;
case 17:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[1];
break;
case 18:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[2];
break;
case 19:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[3];
break;
case 20:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[4];
break;
case 21:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[5];
break;
case 22:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[6];
break;
case 23:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[7];
break;
case 24:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[8];
break;
case 25:
value = globaldata.m_hmibuffer.gcinfo.TenRelay[9];
break;
default:
value = 0;
break;
}
// Console.WriteLine("MoudbusSlave Read Holding adder is " + CKVocAnalyzer.GlobalCKV.valueparamlist.ToString());
return value;
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace GcDevicePc.Common
{
class TWFile
{
private string filename = "default.hw";
private FileStream twfsopen;
public BinaryWriter bw;
private String head = "HW Data Fi03\n";
private byte[] headdata;
private byte[] enddata = new byte[]
{
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x1E,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x40,0x0D,0x03,0x00,0x01,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x05,0x00,0x00,0x00,0x62,0xC5,0xF2,0x59,
0x05,0x00,0x00,0x00,0x64,0x00,0x00,0x00,0x21,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x1A,0x4F,0x00,0x01,0x00,0x00,0x00,0x00,0x00,0x80,0x3F,0x00,0x00,0x80,0x3F,
0x00,0x00,0x80,0x3F,0x00,0x00,0x80,0x3F,0x00,0x00,0xE0,0x74,0xFE,0x02,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x86,0x32,0x31,0x33,0x3A,0x33,0x36,0x36,0x36,0x3A,
0x40,0x2A,0x3C,0x3F,0x47,0x41,0x43,0x4A,0x43,0x48,0x1C,0x87,0x89,0x77,0x89,0x8C,
0x7E,0x7E,0x3B,0x7D,0x80,0x8F,0x94,0x89,0x94,0x8B,0x97,0x8D,0x94,0x94,0x47,0x9F,
0x92,0x9E,0x93,0x4C,0xA0,0x93,0xA1,0x99,0x92,0x9E,0x53,0xA2,0xAA,0xA3,0x99,0x9D,
0xAB,0x5A,0x6B,0x6C,0x6D,0x6E,0x6F,0x71,0x4B,0x74,0x73,0x75,0x7C,0x75,0x78,0x78,
0x78,0x7C,0x82,0x6C,0x7E,0x81,0x89,0x83,0x85,0x8C,0x85,0x8A,0x5E,0xC8,0xBC,0xC1,
0xC0,0xC3,0xCE,0xC5,0xD1,0xC3,0xC3,0x80,0xC3,0xDB,0x83,0xD8,0xCA,0xD3,0xD7,0xD7,
0xDB,0xCB,0xDD,0xE5,0x95,0x97,0x9B,0x90,0xE4,0xEB,0xE6,0xE8,0xDA,0xE3,0x97,0xD9,
0xDD,0xE7,0xE4,0xEA,0xE6,0xF1,0xF3,0xF2,0xE2,0xF6,0xF2,0xF6,0x8F,0x00,0x00,0x00,
0x00
};
public TWFile(string file)
{
this.filename = file;
if (File.Exists(filename))
{
File.Delete(filename);
}
FileStream twfs = new FileStream(filename, FileMode.Create);
twfs.Close();
headdata = System.Text.Encoding.ASCII.GetBytes(head);
}
public void TW_Open()
{
twfsopen = new FileStream(filename, FileMode.OpenOrCreate);
bw = new BinaryWriter(twfsopen);
bw.Write(headdata);
bw.Write(0);
}
public void TW_Close(int datanum)
{
int i;
for (i = 0; i < enddata.Length; i++ )
{
bw.Write(enddata[i]);
}
bw.Seek(headdata.Length, SeekOrigin.Begin);
bw.Write(datanum);
bw.Close();
twfsopen.Close();
}
}
}
......@@ -473,7 +473,6 @@ namespace GcDevicePc.ConfigMethod
if (pagenum > 0)
{
foreach (TabPage tabPage in tabControlDet.TabPages)
{
this.tabControlDet.TabPages.Remove(tabPage);
......@@ -493,7 +492,6 @@ namespace GcDevicePc.ConfigMethod
Page.UseVisualStyleBackColor = true;
tabControlDet.Controls.Add(Page);
}
if (hwconfig.hwconfiginfo.u16DetFront == 1)
......
......@@ -236,12 +236,17 @@ namespace GcDevicePc.ConfigMethod
}
if (float.Parse(OSetTemp.Text) > 400.0f)
if (float.Parse(OSetTemp.Text) > float.Parse(OMAXTemp.Text))
{
MessageBox.Show("设置温度需要小于4000");
MessageBox.Show("设置温度不能大于最高温度");
OSetTemp.Text = "0";
}else if (float.Parse(OSetTemp.Text) > 400.0f)
{
MessageBox.Show("设置温度需要小于400");
OSetTemp.Text = "0";
}
// int line = ProUpTab.Rows.Count;
//if (line == 1)
......
......@@ -203,7 +203,7 @@ namespace GcDevicePc.ConfigMethod
{
ushort pagenum = (ushort)hwconfig.hwconfiginfo.u16InjPortNum;
int i;
//int i;
foreach (TabPage tabPage in tabControlDet.TabPages)
{
this.tabControlDet.TabPages.Remove(tabPage);
......
......@@ -45,6 +45,9 @@
this.label21 = new System.Windows.Forms.Label();
this.combSampleCarrierGas = new System.Windows.Forms.ComboBox();
this.label4 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.textBox1 = new System.Windows.Forms.TextBox();
this.label5 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
......@@ -221,17 +224,47 @@
this.label4.TabIndex = 14;
this.label4.Text = "流量3:";
//
// label3
//
this.label3.AutoSize = true;
this.label3.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label3.Location = new System.Drawing.Point(293, 64);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(67, 15);
this.label3.TabIndex = 30;
this.label3.Text = "保护温度";
//
// textBox1
//
this.textBox1.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.textBox1.Location = new System.Drawing.Point(367, 58);
this.textBox1.Name = "textBox1";
this.textBox1.Size = new System.Drawing.Size(100, 24);
this.textBox1.TabIndex = 4;
//
// label5
//
this.label5.AutoSize = true;
this.label5.Font = new System.Drawing.Font("宋体", 11F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
this.label5.Location = new System.Drawing.Point(473, 64);
this.label5.Name = "label5";
this.label5.Size = new System.Drawing.Size(22, 15);
this.label5.TabIndex = 16;
this.label5.Text = "℃";
//
// IPPIP
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.BackColor = System.Drawing.Color.White;
this.ClientSize = new System.Drawing.Size(592, 332);
this.Controls.Add(this.label3);
this.Controls.Add(this.combSampleCarrierGas);
this.Controls.Add(this.label21);
this.Controls.Add(this.label12);
this.Controls.Add(this.label11);
this.Controls.Add(this.label10);
this.Controls.Add(this.label5);
this.Controls.Add(this.label9);
this.Controls.Add(this.label4);
this.Controls.Add(this.label8);
......@@ -240,6 +273,7 @@
this.Controls.Add(this.txtPressure);
this.Controls.Add(this.txtFlow);
this.Controls.Add(this.lblSamplePortType);
this.Controls.Add(this.textBox1);
this.Controls.Add(this.txtHeater);
this.Controls.Add(this.cbHeater);
this.Controls.Add(this.label2);
......@@ -271,5 +305,8 @@
private System.Windows.Forms.Label label21;
private System.Windows.Forms.ComboBox combSampleCarrierGas;
private System.Windows.Forms.Label label4;
private System.Windows.Forms.Label label3;
private System.Windows.Forms.TextBox textBox1;
private System.Windows.Forms.Label label5;
}
}
\ No newline at end of file
......@@ -53,8 +53,15 @@ namespace GcDevicePc.ConfigMethod.injectionport
//txtSampleProtecttemp.Text = this.methodconfig.port[index].Protecttemp.ToString();
//combControlMode.SelectedIndex = this.methodconfig.port[index].ControlMode;
try
{
combSampleCarrierGas.SelectedIndex = this.methodconfig.port[index].CarrierGasType;
}
catch
{
}
if (this.methodconfig.port[index].Heater == 1)
cbHeater.CheckState = CheckState.Checked;
else
......@@ -229,6 +236,8 @@ namespace GcDevicePc.ConfigMethod.injectionport
this.methodconfig.auxs[index].SamplePortType = lblSamplePortType.Text;
this.methodconfig.auxs[index].CarrierGasType = (ushort)combSampleCarrierGas.SelectedIndex;
//this.methodconfig.auxs[index].Protecttemp =
if (cbHeater.CheckState == CheckState.Checked)
this.methodconfig.auxs[index].Heater = 1;
else
......@@ -240,6 +249,14 @@ namespace GcDevicePc.ConfigMethod.injectionport
// this.methodconfig.auxs[index].pipSeptumBlowFlow = 0;
this.methodconfig.auxs[index].pipSeptumBlowFlow = 1;
this.methodconfig.epc[1].fristFlow = string2float(txtFlow.Text);
this.methodconfig.epc[1].gasType1 = (ushort)0;
this.methodconfig.epc[1].SecondFlow = string2float(txtPressure.Text);
this.methodconfig.epc[1].gasType2 = (ushort)0;
this.methodconfig.epc[1].ThirdFlow = string2float(txtSeptumBlowingflow.Text);
this.methodconfig.epc[1].gasType3 = (ushort)0;
}
float string2float(string s)
......
......@@ -47,7 +47,7 @@ namespace GcDevicePc.Controls
{
switch (pmoptbtnstatus)
{
case 0:
case 0://全暗
((PictureBox)PMPanel.Controls[0]).Image = pmoptimage.Images[6];
((PictureBox)PMPanel.Controls[0]).Enabled = false;
((PictureBox)PMPanel.Controls[1]).Image = pmoptimage.Images[7];
......@@ -55,7 +55,7 @@ namespace GcDevicePc.Controls
((PictureBox)PMPanel.Controls[2]).Image = pmoptimage.Images[8];
((PictureBox)PMPanel.Controls[2]).Enabled = false;
break;
case 3:
case 3://停止亮
((PictureBox)PMPanel.Controls[0]).Image = pmoptimage.Images[6];
((PictureBox)PMPanel.Controls[0]).Enabled = false;
((PictureBox)PMPanel.Controls[1]).Image = pmoptimage.Images[1];
......@@ -63,7 +63,7 @@ namespace GcDevicePc.Controls
((PictureBox)PMPanel.Controls[2]).Image = pmoptimage.Images[2];
((PictureBox)PMPanel.Controls[2]).Enabled = true;
break;
case 4:
case 4://开始亮
((PictureBox)PMPanel.Controls[0]).Image = pmoptimage.Images[0];
((PictureBox)PMPanel.Controls[0]).Enabled = true;
((PictureBox)PMPanel.Controls[1]).Image = pmoptimage.Images[7];
......
......@@ -1023,8 +1023,8 @@ namespace GcDevicePc
double iDetvalue = 0;
double bDetvalue = 0;
string errinfo;
string gasno = "";
//string errinfo;
//string gasno = "";
int topItemIndex = 0;
try
......@@ -1111,7 +1111,7 @@ namespace GcDevicePc
#endregion
errinfo = null;
//errinfo = null;
tempshow = new ListViewItem();
this.datalist.Items.Add(tempshow);
......
......@@ -154,6 +154,16 @@ namespace GcDevicePc.DeviceConfigUI
this.hWConfig.hwconfiginfo.u16ValveSix = this.ValveSix.Checked ? 1: 0;
//进样口
int num = 0;
if (InjPortFront.Checked)
{
num++;
}
if (InjPortBehind.Checked)
{
num++;
}
this.hWConfig.hwconfiginfo.u16InjPortNum = num;
this.hWConfig.hwconfiginfo.u16InjPortFront = this.InjPortFront.Checked? 1: 0;
this.hWConfig.hwconfiginfo.u16InjPortFPTemp = int.Parse(this.InjPortFPTemp.Text);
this.hWConfig.hwconfiginfo.u16InjPortType_Front = this.InjPortType_Front.SelectedIndex;
......
......@@ -65,6 +65,7 @@
this.Controls.Add(this.button1);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.SizableToolWindow;
this.Name = "EPCTips";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "EPCTips";
this.ResumeLayout(false);
this.PerformLayout();
......
......@@ -178,7 +178,7 @@ namespace GcDevicePc
#region 内部操作接口
void ClientInit()
{
int bret = 0;
//int bret = 0;
try
{
this.hFileServerHandle = fnWtClientInit(fIP, wport);
......@@ -192,7 +192,7 @@ namespace GcDevicePc
void ClientClose()
{
int bret = 0;
//int bret = 0;
try
{
fnWtClientClose(this.hFileServerHandle);
......
namespace GcDevicePc
{
partial class Form1
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.label1 = new System.Windows.Forms.Label();
this.SuspendLayout();
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(208, 181);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(41, 12);
this.label1.TabIndex = 0;
this.label1.Text = "label1";
//
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 450);
this.Controls.Add(this.label1);
this.Name = "Form1";
this.Text = "Form1";
this.ResumeLayout(false);
this.PerformLayout();
}
#endregion
private System.Windows.Forms.Label label1;
}
}
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace GcDevicePc
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public Form1(string i)
{
InitializeComponent();
label1.Text = i;
}
public Form1(int i)
{
InitializeComponent();
label1.Text = i.ToString();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
......@@ -9,13 +9,17 @@ using System.Windows.Forms;
using WeifenLuo.WinFormsUI.Docking;
using GcDevicePc.CK_UI;
using GcDevicePc.Common;
using GcDevicePc.IniParam;
namespace GcDevicePc
{
public partial class Formdebug : Form
{
CurveDisPlay cuidisp = new CurveDisPlay();//显示波形
//CurveDisPlay cuidisp = new CurveDisPlay();//显示波形
CurveDisPlay curdisplay = new CurveDisPlay();
//CurveDisPlay2 curdisplay2 = new CurveDisPlay2();
//CurveDisPlay3 curdisplay3 = new CurveDisPlay3();
DataState dataleft = new DataState();//状态显示
public Formdebug()
......@@ -29,15 +33,101 @@ namespace GcDevicePc
}
private void loadPanel() //加载界面
{
this.dockPanel1.Contains(cuidisp);
cuidisp.Show(this.dockPanel1);
cuidisp.CloseButtonVisible = false;
this.dockPanel1.Contains(curdisplay);
curdisplay.Show(this.dockPanel1);
curdisplay.CloseButtonVisible = false;
//Load_Win();
dataleft.Show(this.dockPanel1,DockState.DockRight);
dataleft.CloseButtonVisible = false;
//dataleft.Close_Threading();
//dataleft.Close();
}
//private void Load_Win()
//{
// if (!String.IsNullOrEmpty(globaldata.connection_ip))
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
// {
// curdisplay.Text = "前检测器";
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// curdisplay2.Text = "中检测器";
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// curdisplay3.Text = "后检测器";
// }
// }
// else
// {
// if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
// {
// curdisplay.Text = "前检测器";
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// curdisplay2.Text = "中检测器";
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// curdisplay3.Text = "后检测器";
// }
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetFront == 1)
// {
// this.dockPanel1.Contains(curdisplay);
// curdisplay.Show(this.dockPanel1);
// curdisplay.CloseButtonVisible = false;
// }
// else
// {
// curdisplay.Dispose();
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetInter == 1)
// {
// this.dockPanel1.Contains(curdisplay2);
// curdisplay2.Show(this.dockPanel1);
// curdisplay2.CloseButtonVisible = false;
// }
// else
// {
// curdisplay2.Dispose();
// }
// if (CProfileDevice.m_DevParam.syspara.u16DetBehind == 1)
// {
// this.dockPanel1.Contains(curdisplay3);
// curdisplay3.Show(this.dockPanel1);
// curdisplay3.CloseButtonVisible = false;
// }
// else
// {
// curdisplay3.Dispose();
// }
// //Start_Thread();
// //dockPanelSideLeft.Show(this.dockPanel1, WeifenLuo.WinFormsUI.Docking.DockState.DockRight);
// //dockPanelSideLeft.CloseButtonVisible = false;
//}
public void CloseThread()
{
try
......
......@@ -1131,13 +1131,13 @@ namespace GcDevicePc.GCBuffer
//strKey = "EPC2";
//savemethodconfig.WriteProfileFloat(strKey, "第一路流量设定值", epc[cBehind].fristFlow);
//savemethodconfig.WriteProfileInt(strKey, "第一路载气类型", epc[cBehind].gasType1);
//savemethodconfig.WriteProfileFloat(strKey, "第二路流量设定值", epc[cBehind].SecondFlow);
//savemethodconfig.WriteProfileInt(strKey, "第二路载气类型", epc[cBehind].gasType2);
//savemethodconfig.WriteProfileFloat(strKey, "第三路流量设定值", epc[cBehind].ThirdFlow);
//savemethodconfig.WriteProfileFloat(strKey, "第三路载气类型", epc[cBehind].gasType3);
strKey = "EPC2";
savemethodconfig.WriteProfileFloat(strKey, "第一路流量设定值", epc[cBehind].fristFlow);
savemethodconfig.WriteProfileInt(strKey, "第一路载气类型", epc[cBehind].gasType1);
savemethodconfig.WriteProfileFloat(strKey, "第二路流量设定值", epc[cBehind].SecondFlow);
savemethodconfig.WriteProfileInt(strKey, "第二路载气类型", epc[cBehind].gasType2);
savemethodconfig.WriteProfileFloat(strKey, "第三路流量设定值", epc[cBehind].ThirdFlow);
savemethodconfig.WriteProfileFloat(strKey, "第三路载气类型", epc[cBehind].gasType3);
}
......@@ -1593,12 +1593,12 @@ namespace GcDevicePc.GCBuffer
fid[cFront].u16Sensitive = methodconfigini.GetProfileInt(sAppName, "灵敏度", iDefault);
fid[cFront].u16KeyHeater = methodconfigini.GetProfileInt(sAppName, "加热器开关", iDefault);
fid[cFront].fHeaterTempSet = methodconfigini.GetProfileFloat(sAppName, "加热器设定温度", fDefault);
fid[cFront].u16KeyH2Flow = methodconfigini.GetProfileInt(sAppName, "氢气流量开关", iDefault);
fid[cFront].fSetH2Flow = methodconfigini.GetProfileFloat(sAppName, "氢气流量值", fDefault);
fid[cFront].u16KeyH2Flow = methodconfigini.GetProfileInt(sAppName, "氢气燃气流量开关", iDefault);
fid[cFront].fSetH2Flow = methodconfigini.GetProfileFloat(sAppName, "氢气燃气流量设定值", fDefault);
fid[cFront].u16KeyAirFlow = methodconfigini.GetProfileInt(sAppName, "空气流量开关", iDefault);
fid[cFront].fAirFlowSet = methodconfigini.GetProfileFloat(sAppName, "空气流量值", fDefault);
fid[cFront].fAirFlowSet = methodconfigini.GetProfileFloat(sAppName, "空气流量设定值", fDefault);
fid[cFront].u16KeyTailGas = methodconfigini.GetProfileInt(sAppName, "尾吹气流量开关", iDefault);
fid[cFront].fSetTailGas = methodconfigini.GetProfileFloat(sAppName, "尾吹气流量值", fDefault);
fid[cFront].fSetTailGas = methodconfigini.GetProfileFloat(sAppName, "尾吹气流量设定值", fDefault);
fid[cFront].u16SigDeduct = methodconfigini.GetProfileInt(sAppName, "补偿", iDefault);
}
else if (flag == 1)
......
......@@ -60,7 +60,7 @@
<ManifestKeyFile>GcDevicePc_TemporaryKey.pfx</ManifestKeyFile>
</PropertyGroup>
<PropertyGroup>
<GenerateManifests>true</GenerateManifests>
<GenerateManifests>false</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>false</SignManifests>
......@@ -92,6 +92,12 @@
<ApplicationIcon>logo.ico</ApplicationIcon>
</PropertyGroup>
<PropertyGroup />
<PropertyGroup>
<TargetZone>LocalIntranet</TargetZone>
</PropertyGroup>
<PropertyGroup>
<ApplicationManifest>Properties\app.manifest</ApplicationManifest>
</PropertyGroup>
<ItemGroup>
<Reference Include="CKVocAlgorithm">
<HintPath>..\dll\CKVocAlgorithm.dll</HintPath>
......@@ -112,6 +118,9 @@
<Reference Include="ModbusLib">
<HintPath>..\dll\ModbusLib.dll</HintPath>
</Reference>
<Reference Include="NModbus4, Version=2.1.0.0, Culture=neutral, processorArchitecture=MSIL">
<HintPath>..\packages\NModbus4.2.1.0\lib\net40\NModbus4.dll</HintPath>
</Reference>
<Reference Include="SpaceM">
<HintPath>..\dll\SpaceM.dll</HintPath>
</Reference>
......@@ -173,6 +182,18 @@
<Compile Include="CK_UI\AdjustFrom.Designer.cs">
<DependentUpon>AdjustFrom.cs</DependentUpon>
</Compile>
<Compile Include="CK_UI\CurveDisPlay2.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CK_UI\CurveDisPlay2.Designer.cs">
<DependentUpon>CurveDisPlay2.cs</DependentUpon>
</Compile>
<Compile Include="CK_UI\CurveDisPlay3.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="CK_UI\CurveDisPlay3.Designer.cs">
<DependentUpon>CurveDisPlay3.cs</DependentUpon>
</Compile>
<Compile Include="CK_UI\HistChartForm.cs">
<SubType>Form</SubType>
</Compile>
......@@ -212,8 +233,10 @@
<Compile Include="Common\GCModbusSlave485.cs" />
<Compile Include="Common\Log.cs" />
<Compile Include="Common\MoudbusOperation.cs" />
<Compile Include="Common\NModbusSlave.cs" />
<Compile Include="Common\RunTableHelper.cs" />
<Compile Include="Common\SendDataToHW.cs" />
<Compile Include="Common\TWFile.cs" />
<Compile Include="ConfigDlg\ChromeDlg.cs">
<SubType>Form</SubType>
</Compile>
......@@ -510,6 +533,12 @@
<DependentUpon>EPCTips.cs</DependentUpon>
</Compile>
<Compile Include="FileServerClient.cs" />
<Compile Include="Form1.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon>
</Compile>
<Compile Include="Formdebug.cs">
<SubType>Form</SubType>
</Compile>
......@@ -591,8 +620,12 @@
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="ProThread\ChannelDataSave.cs" />
<Compile Include="ProThread\ChannelDataSave2.cs" />
<Compile Include="ProThread\ChannelDataSave3.cs" />
<Compile Include="ProThread\ChannelDataTh.cs" />
<Compile Include="ProThread\CKvocUpdata.cs" />
<Compile Include="ProThread\CKvocUpdata2.cs" />
<Compile Include="ProThread\CKvocUpdata3.cs" />
<Compile Include="ProThread\DataOutput.cs" />
<Compile Include="ProThread\DataRcv.cs" />
<Compile Include="ProThread\DisplayDataTh.cs" />
......@@ -600,6 +633,7 @@
<Compile Include="ProThread\HMIControl.cs" />
<Compile Include="ProThread\HMISearch.cs" />
<Compile Include="ProThread\HmiStatueTh.cs" />
<Compile Include="ProThread\SignalDataToHw.cs" />
<Compile Include="ProThread\ThreadMonitor.cs" />
<Compile Include="QuitForm.cs">
<SubType>Form</SubType>
......@@ -676,6 +710,12 @@
<EmbeddedResource Include="CK_UI\AdjustFrom.resx">
<DependentUpon>AdjustFrom.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CK_UI\CurveDisPlay2.resx">
<DependentUpon>CurveDisPlay2.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CK_UI\CurveDisPlay3.resx">
<DependentUpon>CurveDisPlay3.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="CK_UI\HistChartForm.resx">
<DependentUpon>HistChartForm.cs</DependentUpon>
</EmbeddedResource>
......@@ -842,6 +882,9 @@
<EmbeddedResource Include="EPCTips.resx">
<DependentUpon>EPCTips.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Form1.resx">
<DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Formdebug.resx">
<DependentUpon>Formdebug.cs</DependentUpon>
</EmbeddedResource>
......@@ -913,6 +956,9 @@
<DependentUpon>WaitForm.cs</DependentUpon>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\app.manifest">
<SubType>Designer</SubType>
</None>
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
......
......@@ -19,11 +19,19 @@ namespace GcDevicePc
{
public partial class MDIBase : Form
{
#region 相关变量
//private int childFormNumber = 0;
private static FormUser _userForm; //用户界面
private static Formdebug _debugForm; //调试界面
private static EPCTips _EPCTipsForm; //EPC报警界面
/// <summary>
/// 三画图
/// </summary>
//CurveDisPlay curdisplay = new CurveDisPlay();
//CurveDisPlay2 curdisplay2 = new CurveDisPlay2();
//CurveDisPlay3 curdisplay3 = new CurveDisPlay3();
private string Formstr;//窗口名称
private string statestr;//状态信息
// private Color stateColor=new Color();//状态颜色;
......@@ -47,7 +55,9 @@ namespace GcDevicePc
/// <summary>
/// Modbus Slave 变量
/// </summary>
GCModbusSlave Slavetest;
//GCModbusSlave Slavetest;
NModbusSlave nmodbusSlave;
/// <summary>
/// Modbus Slave 485 变量
......@@ -63,19 +73,24 @@ namespace GcDevicePc
/// 本地数据保存接口
/// </summary>
ChannelDataSave mydatasave = new ChannelDataSave();
//ChannelDataSave2 mydatasave2 = new ChannelDataSave2();
//ChannelDataSave3 mydatasave3 = new ChannelDataSave3();
ChannelDataSave2 mydatasave2 = new ChannelDataSave2();
ChannelDataSave3 mydatasave3 = new ChannelDataSave3();
/// <summary>
/// 处理数据接口
/// </summary>
CKvocUpdata dataVOC = new CKvocUpdata();
CKvocUpdata2 dataVoc2 = new CKvocUpdata2();
CKvocUpdata3 dataVoc3 = new CKvocUpdata3();
private DataOutput wtd624xOutput = new DataOutput();
private SignalDataToHw signalDataTohw = new SignalDataToHw();
#endregion
#region Author by zjx
CurveDisPlay curdisplay = new CurveDisPlay();
//CurveDisPlay curdisplay = new CurveDisPlay();
/// <summary>
/// 组件初始化
/// </summary>
......@@ -286,6 +301,7 @@ namespace GcDevicePc
private void MDIBase_Load(object sender, EventArgs e)
{
_userForm = new FormUser();
DllInit();
InitConfig();
......@@ -293,7 +309,6 @@ namespace GcDevicePc
//系统检测日志
InitLogTimer();
_debugForm = new Formdebug();
_debugForm.MdiParent = this;
//_debugForm.Dock = DockStyle.Fill;
......@@ -347,7 +362,8 @@ namespace GcDevicePc
SetMenu(LandIn.Island);
autopensys();
this.SizeChanged += new System.EventHandler(this.MDIBase_SizeChanged);
this.SizeChanged += new EventHandler(this.MDIBase_SizeChanged);
(title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOrdBtnClicked += PictureMenu1_PMOrdBtnClicked;
(title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptBtnClicked += PictureMenu1_PMOptBtnClicked;
(title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMSysBtnClicked += PictureMenu1_PMSysBtnClicked;
......@@ -726,7 +742,7 @@ namespace GcDevicePc
/// 1.0.2.3 添加了周期完成后,重新绘图功能
private void timer1_Tick(object sender, EventArgs e)
{
this.Text = String.Format("VOCs在线监测-1.1.3.10 {0}",Formstr);
this.Text = String.Format("VOCs在线监测-1.4.9 {0}",Formstr);
//if (LandIn.Island)
//{
// HmiStatus.Text = String.Format("状态:{0}", statestr);
......@@ -1036,6 +1052,54 @@ namespace GcDevicePc
}
#region 线程接口
//private void Start_Thread()
//{
// mydatasave.ChannelDataStart();
// mydatasave2.ChannelDataStart();
// mydatasave3.ChannelDataStart();
// if (!String.IsNullOrEmpty(globaldata.connection_ip))
// {
// mymodbus.HmiStatueStart();
// mymodbus.ChannelDataStart();
// }
// dataVOC.CKvocUpdataStart();
// dataVoc2.CKvocUpdataStart();
// dataVoc3.CKvocUpdataStart();
// mytcptest.DataRcvStart();
// if (!String.IsNullOrEmpty(globaldata.m_pcbuffer.gcpcinfo.moduleinfo.ip))
// wtd624xOutput.DataOutStart();
//}
//public void Stop_Thread()
//{
// mydatasave.ChannelDataStop();
// mydatasave2.ChannelDataStop();
// mydatasave3.ChannelDataStop();
// if (!String.IsNullOrEmpty(globaldata.connection_ip))
// {
// mymodbus.HmiStatueStop();
// mymodbus.ChannelDataStop();
// ThreadMonitor.GetInstance().MonitorThStop();
// ThreadMonitor.GetInstance().StopALLCommunication();
// }
// dataVOC.CKvocUpdataStop();
// dataVoc2.CKvocUpdataStop();
// dataVoc3.CKvocUpdataStop();
// mytcptest.DataRcvStop();
// if (!String.IsNullOrEmpty(globaldata.m_pcbuffer.gcpcinfo.moduleinfo.ip))
// wtd624xOutput.DataOutStop();
//}
#endregion
private void InitConfig()
{
string tmpname = "";
......@@ -1096,8 +1160,10 @@ namespace GcDevicePc
try
{
Slavetest = new GCModbusSlave();
Slavetest.CModbusSlaveInit(1, 2, 3, 5);
nmodbusSlave = new NModbusSlave();
//Slavetest = new GCModbusSlave();
//Slavetest.CModbusSlaveInit(1, 2, 3, 5);
if (globaldata.m_pcbuffer.gcpcinfo.outputinfo.port != 0)
{
......@@ -1122,6 +1188,7 @@ namespace GcDevicePc
Log.Error(ex.Message);
}
}
Thread gethmistaues;
private void Start_Thread()
{
......@@ -1264,14 +1331,30 @@ namespace GcDevicePc
Status_Show(status_flag, ref status_flag_old);
if (status_flag == 3)
{
if (isStart)
{
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 4;
}
isStop = true;
}
else if (status_flag == 4 || status_flag == 5)
{
if (isStop)
{
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 3;
}
isStart = true;
}
else
{
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 0;
}
if (globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.RunType == 2)
{
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 0;
}
//if (!String.IsNullOrEmpty(globaldata.connection_ip))
//{
......@@ -1657,17 +1740,18 @@ namespace GcDevicePc
count = 0;
ret = Slavetest.CModbusSlaveClose();
while (ret != 0)
{
count++;
ret = Slavetest.CModbusSlaveClose();
Thread.Sleep(100);
if (count > 3)
{
break;
}
}
//ret = Slavetest.CModbusSlaveClose();
nmodbusSlave.NModbusSlaveClose();
//while (ret != 0)
//{
// count++;
// ret = Slavetest.CModbusSlaveClose();
// Thread.Sleep(100);
// if (count > 3)
// {
// break;
// }
//}
if (globaldata.m_pcbuffer.gcpcinfo.outputinfo.port != 0)
{
......@@ -1709,17 +1793,18 @@ namespace GcDevicePc
Thread.Sleep(1500);
count = 0;
ret = Slavetest.CModbusSlaveClose();
while (ret != 0)
{
count++;
ret = Slavetest.CModbusSlaveClose();
Thread.Sleep(100);
if (count > 3)
{
break;
}
}
//ret = Slavetest.CModbusSlaveClose();
nmodbusSlave.NModbusSlaveClose();
//while (ret != 0)
//{
// count++;
// ret = Slavetest.CModbusSlaveClose();
// Thread.Sleep(100);
// if (count > 3)
// {
// break;
// }
//}
if (globaldata.m_pcbuffer.gcpcinfo.outputinfo.port != 0)
{
......@@ -1760,7 +1845,7 @@ namespace GcDevicePc
// private bool isopen = false;
private void open()
{
bool ret = false;
//bool ret = false;
try
{
......@@ -1848,6 +1933,16 @@ namespace GcDevicePc
hmiopt.FireUPWork(flag, time1, time2, time3);
}
private void tcd_setdac(ushort port, ushort val)
{
hmiopt.TCD_SetDAC(port, val);
}
private void tcd_sw(ushort port)
{
hmiopt.TCD_Switch(port);
}
/// <summary>
/// 调试运行表接口
/// </summary>
......@@ -2042,10 +2137,10 @@ namespace GcDevicePc
globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.work_Statue = 0;
}
}
auxtool f_auxtool;
private void AuxToolMenu_Click(object sender, EventArgs e)
{
auxtool f_auxtool = new auxtool();
//auxtool f_auxtool = new auxtool();
int ret = 0;
ushort[] firetime = new ushort[2];
ushort[] firstfiretime = new ushort[1];
......@@ -2066,55 +2161,121 @@ namespace GcDevicePc
f_auxtool.updatefirm += new UpdateFirmCMD(startupdatefirm);
f_auxtool.hairsw += new HAir_SW(hair_sw);
f_auxtool.gctcd_setdac += new TCD_SetDAC(tcd_setdac);
f_auxtool.gctcd_sw += new TCD_SW(tcd_sw);
f_auxtool.Show();
}
else
{
if (f_auxtool.IsDisposed)
else if (f_auxtool.IsDisposed)
{
f_auxtool = null;
f_auxtool = new auxtool(firetime[0], firetime[1], firstfiretime[0]);
f_auxtool.auxtoolforfireup += new AUXTool(fireupopt);
f_auxtool.sfupdatefirm += new StopForUpdateFirm(stopforupdatefirm);
f_auxtool.updatefirm += new UpdateFirmCMD(startupdatefirm);
f_auxtool.hairsw += new HAir_SW(hair_sw);
f_auxtool.Show();
f_auxtool.gctcd_setdac += new TCD_SetDAC(tcd_setdac);
f_auxtool.gctcd_sw += new TCD_SW(tcd_sw);
f_auxtool.Show();
}
else
{
f_auxtool.setfireuptime(firetime[0], firetime[1], firstfiretime[0]);
f_auxtool.auxtoolforfireup -= new AUXTool(fireupopt);
f_auxtool.auxtoolforfireup += new AUXTool(fireupopt);
f_auxtool.sfupdatefirm -= new StopForUpdateFirm(stopforupdatefirm);
f_auxtool.sfupdatefirm += new StopForUpdateFirm(stopforupdatefirm);
f_auxtool.updatefirm -= new UpdateFirmCMD(startupdatefirm);
f_auxtool.updatefirm += new UpdateFirmCMD(startupdatefirm);
f_auxtool.hairsw -= new HAir_SW(hair_sw);
f_auxtool.hairsw += new HAir_SW(hair_sw);
f_auxtool.Show();
}
f_auxtool.Activate();
}
//if (f_auxtool == null)
//{
// f_auxtool = new auxtool(firetime[0], firetime[1], firstfiretime[0]);
// f_auxtool.auxtoolforfireup += new AUXTool(fireupopt);
// f_auxtool.sfupdatefirm += new StopForUpdateFirm(stopforupdatefirm);
// f_auxtool.updatefirm += new UpdateFirmCMD(startupdatefirm);
// f_auxtool.hairsw += new HAir_SW(hair_sw);
// f_auxtool.Show();
//}
//else
//{
// if (f_auxtool.IsDisposed)
// {
// f_auxtool = new auxtool(firetime[0], firetime[1], firstfiretime[0]);
// f_auxtool.auxtoolforfireup += new AUXTool(fireupopt);
// f_auxtool.sfupdatefirm += new StopForUpdateFirm(stopforupdatefirm);
// f_auxtool.updatefirm += new UpdateFirmCMD(startupdatefirm);
// f_auxtool.hairsw += new HAir_SW(hair_sw);
// f_auxtool.Show();
// }
// else
// {
// f_auxtool.setfireuptime(firetime[0], firetime[1], firstfiretime[0]);
// f_auxtool.auxtoolforfireup -= new AUXTool(fireupopt);
// f_auxtool.auxtoolforfireup += new AUXTool(fireupopt);
// f_auxtool.sfupdatefirm -= new StopForUpdateFirm(stopforupdatefirm);
// f_auxtool.sfupdatefirm += new StopForUpdateFirm(stopforupdatefirm);
// f_auxtool.updatefirm -= new UpdateFirmCMD(startupdatefirm);
// f_auxtool.updatefirm += new UpdateFirmCMD(startupdatefirm);
// f_auxtool.hairsw -= new HAir_SW(hair_sw);
// f_auxtool.hairsw += new HAir_SW(hair_sw);
// f_auxtool.Show();
// }
//}
}
UserConfig confu;
private void NetWorkMenu_Click(object sender, EventArgs e)
{
UserConfig confu = new UserConfig();
if (confu == null)
{
confu = new UserConfig();
confu.Show();
}
else if (confu.IsDisposed)
{
confu = null;
confu = new UserConfig();
confu.Show();
}
else
{
confu.Activate();
}
}
RunTables f_runtablef;
private void MethodBatMenu_Click(object sender, EventArgs e)
{
try
{
RunTables f_runtable = new RunTables();
f_runtable.sendupdatecmd -= new SendUpdateCMD(SendPCCMD);
f_runtable.sendupdatecmd += new SendUpdateCMD(SendPCCMD);
f_runtable.sendstopcmd -= new SendStopCMD(SendStopCMD);
f_runtable.sendstopcmd += new SendStopCMD(SendStopCMD);
f_runtable.Show();
if (f_runtablef == null)
{
f_runtablef = new RunTables();
f_runtablef.sendupdatecmd -= new SendUpdateCMD(SendPCCMD);
f_runtablef.sendupdatecmd += new SendUpdateCMD(SendPCCMD);
f_runtablef.sendstopcmd -= new SendStopCMD(SendStopCMD);
f_runtablef.sendstopcmd += new SendStopCMD(SendStopCMD);
f_runtablef.Show();
}
else if (f_runtablef.IsDisposed)
{
f_runtablef = null;
f_runtablef = new RunTables();
f_runtablef.sendupdatecmd -= new SendUpdateCMD(SendPCCMD);
f_runtablef.sendupdatecmd += new SendUpdateCMD(SendPCCMD);
f_runtablef.sendstopcmd -= new SendStopCMD(SendStopCMD);
f_runtablef.sendstopcmd += new SendStopCMD(SendStopCMD);
f_runtablef.Show();
}
else
{
f_runtablef.Activate();
}
}
catch (Exception ex)
......@@ -2124,6 +2285,7 @@ namespace GcDevicePc
}
}
MethodMain myform;
private void NewMethodMenu_Click(object sender, EventArgs e)
{
SaveDialog saveDialog = new SaveDialog(globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.MethodFolder, 0);
......@@ -2145,12 +2307,30 @@ namespace GcDevicePc
methodconfig.SetMethodConfigName(mfilename);
methodconfig.SetMethodSaveName(mfilename);
MethodMain myform = new MethodMain();
if (myform == null)
{
myform = new MethodMain();
myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myform.Show();
}
else if (myform.IsDisposed)
{
myform = new MethodMain();
myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myform.Show();
}
else
{
myform.Activate();
}
}
}
MethodMain myformb;
private void OpenMethodMenu_Click(object sender, EventArgs e)
{
OpenFileDialog fileDlg = new OpenFileDialog();
......@@ -2171,11 +2351,35 @@ namespace GcDevicePc
methodconfig.SetMethodConfigName(mfilename);
methodconfig.SetMethodSaveName(mfilename);
MethodMain myform = new MethodMain(true);
myform.sendupdatecmd += new MethodMain.SendUpdateCMD(SendPCCMD);
myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myform.Show();
if (myformb == null)
{
myformb = new MethodMain(true);
myformb.sendupdatecmd += new MethodMain.SendUpdateCMD(SendPCCMD);
myformb.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myformb.Show();
}
else if (myformb.IsDisposed)
{
myformb = null;
myformb = new MethodMain(true);
myformb.sendupdatecmd += new MethodMain.SendUpdateCMD(SendPCCMD);
myformb.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myformb.Show();
}
else
{
myformb.Activate();
}
//MethodMain myform = new MethodMain(true);
//myform.sendupdatecmd += new MethodMain.SendUpdateCMD(SendPCCMD);
//myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
//myform.Show();
string tmpFileName;
tmpFileName = globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_MethodName;
......@@ -2188,6 +2392,7 @@ namespace GcDevicePc
}
MethodMain myformbb;
private void MethodBrowseMenuItem_Click(object sender, EventArgs e)
{
if (globaldata.m_configDlg.Visible == true)
......@@ -2199,9 +2404,29 @@ namespace GcDevicePc
GCMethodConfig methodconfig = new GCMethodConfig();
methodconfig.SetMethodConfigName(mfilename);
methodconfig.SetMethodSaveName(mfilename);
MethodMain myform = new MethodMain(true, false);
myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myform.Show();
//MethodMain myform = new MethodMain(true, false);
//myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
//myform.Show();
if (myformbb == null)
{
myformbb = new MethodMain(true, false);
myformbb.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myformbb.Show();
}
else if (myformbb.IsDisposed)
{
myformbb = null;
myformbb = new MethodMain(true, false);
myformbb.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myformbb.Show();
}
else
{
myformbb.Activate();
}
}
else
{
......@@ -2218,19 +2443,51 @@ namespace GcDevicePc
GCMethodConfig methodconfig = new GCMethodConfig();
methodconfig.SetMethodConfigName(mfilename);
methodconfig.SetMethodSaveName(mfilename);
MethodMain myform = new MethodMain(true, false);
myform.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myform.Show();
if (myformbb == null)
{
myformbb = new MethodMain(true, false);
myformbb.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myformbb.Show();
}
else if (myformbb.IsDisposed)
{
myformbb = null;
myformbb = new MethodMain(true, false);
myformbb.SetGCConfig(globaldata.m_hwconfig, methodconfig);
myformbb.Show();
}
else
{
myformbb.Activate();
}
}
}
}
WaveTotalForm total;
private void HistoryDataMenu_Click(object sender, EventArgs e)
{
try
{
WaveTotalForm total = new WaveTotalForm();
if (total == null)
{
total = new WaveTotalForm();
total.Show();
}
else if (total.IsDisposed)
{
total = null;
total = new WaveTotalForm();
total.Show();
}
else
{
total.Activate();
}
}
catch (Exception ex)
......@@ -2238,28 +2495,56 @@ namespace GcDevicePc
Log.Error(ex.Message);
}
}
AdjustFrom just;
private void CalibrationMenu_Click(object sender, EventArgs e)
{
try
{
AdjustFrom just = new AdjustFrom();
if (just == null)
{
just = new AdjustFrom();
just.Show();
}
else if (just.IsDisposed)
{
just = null;
just = new AdjustFrom();
just.Show();
}
else
{
just.Activate();
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
}
}
HistChartForm hist;
private void HistoryPicMenu_Click(object sender, EventArgs e)
{
try
{
HistChartForm hist = new HistChartForm();
if (hist == null)
{
hist = new HistChartForm();
hist.Show();
}
else if (hist.IsDisposed)
{
hist = null;
hist = new HistChartForm();
hist.Show();
}
else
{
hist.Activate();
}
}
catch (Exception ex)
{
Log.Error(ex.Message);
......@@ -2282,7 +2567,7 @@ namespace GcDevicePc
//{
// Log.Error(ex.Message);
//}
int ret = 0;
//int ret = 0;
ushort[] version = new ushort[12];
try
......@@ -2323,13 +2608,27 @@ namespace GcDevicePc
}
ShowConfig showConfig;
private void ConfigShowSubMenuItem_Click(object sender, EventArgs e)
{
try
{
ShowConfig f = new ShowConfig();
f.Show();
if (showConfig == null)
{
showConfig = new ShowConfig();
showConfig.Show();
}
else if (showConfig.IsDisposed)
{
showConfig = null;
showConfig = new ShowConfig();
showConfig.Show();
}
else
{
showConfig.Activate();
}
}
catch (Exception ex)
{
......@@ -2377,6 +2676,9 @@ namespace GcDevicePc
globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.work_Statue = 1;
}
private bool isStart;
private bool isStop;
private void SingleStart_Click(object sender, EventArgs e)
{
if (!String.IsNullOrEmpty(globaldata.connection_ip))
......@@ -2389,7 +2691,7 @@ namespace GcDevicePc
{
hmiopt.WriteOpenVal();
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 3;
isStart = false;
}
hmiopt.WriteStartVal();
......@@ -2457,7 +2759,7 @@ namespace GcDevicePc
{
hmiopt.WriteOpenVal();
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 4;
isStop = false;
}
stopbtn();
......@@ -2499,7 +2801,7 @@ namespace GcDevicePc
if (globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.RunType == 0)
{
hmiopt.WriteOpenVal();
(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 4;
//(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 4;
}
cancelbtn();
......
......@@ -39,7 +39,7 @@
this.ClientSize = new System.Drawing.Size(1008, 730);
this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
this.Name = "MainForm";
this.Text = "VOCs在线监测-1.0.0.0 用户窗口";
this.Text = "VOCs在线监测-1.4.9 用户窗口";
this.ResumeLayout(false);
this.PerformLayout();
......
......@@ -5,6 +5,7 @@ using System.Text;
using System.Threading;
using GcDevicePc.GCBuffer;
using System.Diagnostics;
using GcDevicePc.CK_UI;
namespace GcDevicePc.ProThread
{
......
......@@ -5,6 +5,7 @@ using System.Text;
using System.Threading;
using GcDevicePc.GCBuffer;
using System.Diagnostics;
using GcDevicePc.CK_UI;
//using GcDevicePc.CK_UI;
namespace GcDevicePc.ProThread
......
......@@ -16,79 +16,241 @@ namespace GcDevicePc.ProThread
{
ManualResetEvent datamre = new ManualResetEvent(false);
Thread t_DataSave;
//int isstart = 0;
String savefilename;
#region
//private void Monitor_Data()
//{
// double time = 0;
// double value = 0;
// float dtime = 0.0f;
// float dvalue = 0.0f;
// while (!datamre.WaitOne(500))
// {
// if ((globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5) && globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.system_Statue)
// {
// if (globaldata.m_signalbuffer.Draw_Port.Count > 1)
// {
// if (globaldata.startclear || globaldata.stopflag || globaldata.cancelflag)
// {
// time = 0;
// globaldata.startclear = false;
// }
// if (globaldata.stopflag)
// {
// time = 0;
// }
// else
// {
// //if (globaldata.starttimer == 0)
// //{
// // globaldata.starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[0]).ctimer;
// //}
// for (int i = 0; i < globaldata.m_signalbuffer.Draw_Port.Count; i++)
// {
// if (globaldata.starttimer <= ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).ctimer)
// {
// Console.WriteLine("starttimer " + globaldata.starttimer.ToString());
// time += ((((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).ctimer - globaldata.starttimer) / 1000.0f / 60.0f);
// globaldata.starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).ctimer;
// value = (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).cdata * 1000.0f);
// dtime = float.Parse(time.ToString("0.0000"));
// dvalue = float.Parse(value.ToString("0.0000"));
// if (globaldata.startflag && globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
// {
// //AESfile savefile = new AESfile(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName);
// //savefile.Write_filetw(dtime, dvalue);
// }
// }
// }
// }
// }
// // globaldata.m_signalbuffer.Draw_Port.Clear();
// }
// if (globaldata.cancelflag)
// {
// if (globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
// {
// if (File.Exists(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName))
// {
// File.Delete(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName);
// }
// }
// globaldata.cancelflag = false;
// }
// Thread.Sleep(500);
// }
//}
#endregion
private long GetCurrentTimeUnix()
{
TimeSpan cha = (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
long t = (long)cha.TotalSeconds;
return t;
}
private void Monitor_Data()
{
double time = 0;
double value = 0;
float dtime = 0.0f;
float dvalue = 0.0f;
UInt32 starttimer = 0x7FFFFFFF;
UInt32 endtimer = 0x7FFFFFFF;
Boolean saveflag = false;
List<float> listPoint = new List<float>();//临时数据区
List<float> savePoint = new List<float>();
List<uint> timePoint = new List<uint>();//临时数据区
try
{
while (!datamre.WaitOne(500))
{
if ((globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5) && globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.system_Statue)
if ((globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5) || globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.system_Statue)
{
String tmpFileName = globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_MethodName;
String methodfilename = tmpFileName.Substring(tmpFileName.LastIndexOf("\\") + 1);
string[] sArray = methodfilename.Split('.');
String tmpfolder = Path.Combine(globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.DataFolder, sArray[0]);
if (!Directory.Exists(tmpfolder))
{
Directory.CreateDirectory(tmpfolder);
}
tmpfolder = Path.Combine(tmpfolder, DateTime.Now.ToString("yyyyMMdd"));
if (!Directory.Exists(tmpfolder))
{
Directory.CreateDirectory(tmpfolder);
}
String cur_folder = tmpfolder;
String cur_filename = sArray[0] + "_" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒") + "_前.hw";
savefilename = Path.Combine(cur_folder, cur_filename);
lock (globaldata.m_signalbuffer.Save_Port)
{
if (globaldata.m_signalbuffer.Save_Port.Count > 1)
{
if (globaldata.m_hmibuffer.gcinfo.methodstatus < 3 || globaldata.m_hmibuffer.gcinfo.methodstatus > 5)
{
starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[0]).ctimer;
globaldata.m_signalbuffer.Save_Port.Clear();
//if (globaldata.m_hmibuffer.gcinfo.methodstatus > 5 && saveflag)
if (saveflag)
{
if (globaldata.m_signalbuffer.Draw_Port.Count > 1)
starttimer = globaldata.m_hmibuffer.gcinfo.NowStartTime;
endtimer = globaldata.m_hmibuffer.gcinfo.NowEndTime;
int index1 = timePoint.FindIndex(item => item >= starttimer);
int index2 = timePoint.FindLastIndex(item => item <= endtimer);
if (index1 >= 0)
{
if (globaldata.startclear || globaldata.stopflag || globaldata.cancelflag)
if (index2 <= 0)
{
time = 0;
globaldata.startclear = false;
index2 = timePoint.Count;
}
}
if (globaldata.stopflag)
if (index2 > index1 && index1 >= 0)
{
time = 0;
savePoint = listPoint.GetRange(index1, index2 - index1);
TWFile twfile = new TWFile(savefilename);
twfile.TW_Open();
for (int j = 0; j < savePoint.Count; j++)
{
twfile.bw.Write((int)(savePoint[j] * 1000));
}
twfile.TW_Close(savePoint.Count);
}
else
{
//if (globaldata.starttimer == 0)
//{
// globaldata.starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[0]).ctimer;
//}
Log.Info("Channel1 Save Data: " + starttimer.ToString() + "-" + endtimer.ToString());
Log.Info("Channel1 Index1,Index2: " + index1.ToString() + "-" + index2.ToString());
Log.Info("Channel1 timePoint: " + timePoint[0].ToString() + "-" + timePoint[timePoint.Count - 1].ToString());
Log.Info("Channel1 Data Num:" + listPoint.Count.ToString());
}
for (int i = 0; i < globaldata.m_signalbuffer.Draw_Port.Count; i++)
starttimer = 0x7FFFFFFF;
savePoint.Clear();
saveflag = false;
}
}
else if (globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5)
{
for (int i = 0; i < globaldata.m_signalbuffer.Save_Port.Count; i++)
{
if (globaldata.starttimer <= ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).ctimer)
if (globaldata.m_hmibuffer.gcinfo.NowStartTime <= ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[i]).ctimer)//&& (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[i]).ctimer - starttimer) < 3000)
{
Console.WriteLine("starttimer " + globaldata.starttimer.ToString());
time += ((((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).ctimer - globaldata.starttimer) / 1000.0f / 60.0f);
globaldata.starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).ctimer;
value = (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Draw_Port[i]).cdata * 1000.0f);
value = (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[i]).cdata * 1000.0f);
dvalue = (float)Math.Round(value, 4);
dtime = float.Parse(time.ToString("0.0000"));
dvalue = float.Parse(value.ToString("0.0000"));
lock (timePoint)
{
//if (globaldata.startflag) //&& globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
{
timePoint.Add(((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[i]).ctimer);
listPoint.Add(dvalue);
saveflag = true;
}
}
if (globaldata.startflag && globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
}
}
globaldata.m_signalbuffer.Save_Port.Clear();
}
else
{
listPoint.Clear();
timePoint.Clear();
//Console.WriteLine("等待开始按钮!");
if (!globaldata.startflag)
{
// AESfile savefile = new AESfile(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName);
// savefile.Write_filetw(dtime, dvalue);
globaldata.m_signalbuffer.Save_Port.Clear();
}
else
{
starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[0]).ctimer;
}
}
}
}
// globaldata.m_signalbuffer.Draw_Port.Clear();
}
if (globaldata.cancelflag)
if (globaldata.cancelflag1)
{
if (globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
if (this.savefilename != null)
{
if (File.Exists(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName))
if (File.Exists(this.savefilename))
{
File.Delete(globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName);
File.Delete(this.savefilename);
}
}
globaldata.cancelflag = false;
globaldata.cancelflag1 = false;
}
Thread.Sleep(500);
}
}
catch (Exception ex)
{
Log.Error("Channel 1 Data Save Crash!");
Log.Error(ex.Message);
}
}
public void ChannelDataStart()
{
if( datamre != null)
......
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Collections;
using GcDevicePc.Common;
using GcDevicePc.GCBuffer;
using System.Runtime.InteropServices;
using CKVocAnalyzer;
namespace GcDevicePc.ProThread
{
class ChannelDataSave2
{
ManualResetEvent datamre = new ManualResetEvent(false);
Thread t_DataSave;
String savefilename;
private long GetCurrentTimeUnix()
{
TimeSpan cha = (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
long t = (long)cha.TotalSeconds;
return t;
}
#region
private void Monitor_Data()
{
double value = 0;
float dvalue = 0.0f;
UInt32 starttimer = 0x7FFFFFFF;
UInt32 endtimer = 0x7FFFFFFF;
Boolean saveflag = false;
List<float> listPoint = new List<float>();//临时数据区
List<float> savePoint = new List<float>();
List<uint> timePoint = new List<uint>();//临时数据区
try
{
while (!datamre.WaitOne(500))
{
if ((globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5) || globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.system_Statue)
{
String tmpFileName = globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_MethodName;
String methodfilename = tmpFileName.Substring(tmpFileName.LastIndexOf("\\") + 1);
string[] sArray = methodfilename.Split('.');
String tmpfolder = Path.Combine(globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.DataFolder, sArray[0]);
if (!Directory.Exists(tmpfolder))
{
Directory.CreateDirectory(tmpfolder);
}
tmpfolder = Path.Combine(tmpfolder, DateTime.Now.ToString("yyyyMMdd"));
if (!Directory.Exists(tmpfolder))
{
Directory.CreateDirectory(tmpfolder);
}
String cur_folder = tmpfolder;
String cur_filename = sArray[0] + "_" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒") + "_中.hw";
savefilename = Path.Combine(cur_folder, cur_filename);
// savefilename = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.DataFolder + "\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + sArray[0] + "_" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒") + "_中.hw";
lock (globaldata.m_signalbuffer.Save_Port2)
{
if (globaldata.m_signalbuffer.Save_Port2.Count > 1)
{
if (globaldata.m_hmibuffer.gcinfo.methodstatus < 3 || globaldata.m_hmibuffer.gcinfo.methodstatus > 5)
{
starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port2[0]).ctimer;
globaldata.m_signalbuffer.Save_Port2.Clear();
if (saveflag)
//if (globaldata.m_hmibuffer.gcinfo.methodstatus > 5 && saveflag)
{
starttimer = globaldata.m_hmibuffer.gcinfo.NowStartTime;
endtimer = globaldata.m_hmibuffer.gcinfo.NowEndTime;
//Log.Info("Channel2 Save Data: " + starttimer.ToString() + "-" + endtimer.ToString());
//int index1 = timePoint.IndexOf(starttimer);
int index1 = timePoint.FindIndex(item => item >= starttimer);
// int index2 = timePoint.FindIndex(item => item >= endtimer);
// int index2 = timePoint.FindIndex(item => item >= endtimer);
int index2 = timePoint.FindLastIndex(item => item <= endtimer);
if (index1 >= 0)
{
if (index2 <= 0)
{
index2 = timePoint.Count;
}
}
if (index2 > index1 && index1 >= 0)
{
savePoint = listPoint.GetRange(index1, index2 - index1);
TWFile twfile = new TWFile(savefilename);
twfile.TW_Open();
for (int j = 0; j < savePoint.Count; j++)
{
twfile.bw.Write((int)(savePoint[j] * 1000));
}
twfile.TW_Close(savePoint.Count);
}
else
{
Log.Info("Channel2 Save Data: " + starttimer.ToString() + "-" + endtimer.ToString());
Log.Info("Channel2 Index1,Index2: " + index1.ToString() + "-" + index2.ToString());
Log.Info("Channel2 timePoint: " + timePoint[0].ToString() + "-" + timePoint[timePoint.Count - 1].ToString());
Log.Info("Channel2 Data Num:" + listPoint.Count.ToString());
//Log.Info("Channel2 Data Num:" + listPoint.Count.ToString());
}
starttimer = 0x7FFFFFFF;
savePoint.Clear();
saveflag = false;
}
}
else if (globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5)
{
for (int i = 0; i < globaldata.m_signalbuffer.Save_Port2.Count; i++)
{
if (globaldata.m_hmibuffer.gcinfo.NowStartTime <= ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port2[i]).ctimer)//&& (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[i]).ctimer - starttimer) < 3000)
{
value = (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port2[i]).cdata * 1000.0f);
dvalue = (float)Math.Round(value, 4);
lock (timePoint)
{
//if (globaldata.startflag) //&& globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
{
timePoint.Add(((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port2[i]).ctimer);
listPoint.Add(dvalue);
saveflag = true;
}
}
}
}
globaldata.m_signalbuffer.Save_Port2.Clear();
}
else
{
listPoint.Clear();
timePoint.Clear();
//Console.WriteLine("等待开始按钮!");
if (!globaldata.startflag)
{
globaldata.m_signalbuffer.Save_Port2.Clear();
}
else
{
starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port2[0]).ctimer;
}
}
}
}
}
if (globaldata.cancelflag2)
{
if (this.savefilename != null)
{
if (File.Exists(this.savefilename))
{
File.Delete(this.savefilename);
}
}
globaldata.cancelflag2 = false;
}
}
}
catch (Exception ex)
{
Log.Error("Channel 2 Data Save Crash!");
Log.Error(ex.Message);
}
}
#endregion
private void ChannelDataReStart()
{
try
{
t_DataSave = null;
if (datamre != null)
{
datamre.Reset();
}
t_DataSave = new Thread(Monitor_Data);
t_DataSave.IsBackground = true;
t_DataSave.Start();
}
catch
{
Log.Error("Channel 2 Data Save Thread Restart Crash!");
}
}
public void ChannelDataStart()
{
if( datamre != null)
{
datamre.Reset();
}
t_DataSave = new Thread(Monitor_Data);
t_DataSave.IsBackground = true;
t_DataSave.Start();
}
public void ChannelDataStop()
{
datamre.Set();
}
}
}
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Text.RegularExpressions;
using System.Collections;
using GcDevicePc.Common;
using GcDevicePc.GCBuffer;
using System.Runtime.InteropServices;
namespace GcDevicePc.ProThread
{
class ChannelDataSave3
{
ManualResetEvent datamre = new ManualResetEvent(false);
Thread t_DataSave;
String savefilename;
private long GetCurrentTimeUnix()
{
TimeSpan cha = (DateTime.Now - TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1)));
long t = (long)cha.TotalSeconds;
return t;
}
private void Monitor_Data()
{
double value = 0;
float dvalue = 0.0f;
UInt32 starttimer = 0x7FFFFFFF;
UInt32 endtimer = 0x7FFFFFFF;
Boolean saveflag = false;
List<float> listPoint = new List<float>();//临时数据区
List<float> savePoint = new List<float>();
List<uint> timePoint = new List<uint>();//临时数据区
try
{
while (!datamre.WaitOne(500))
{
if ((globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5) || globaldata.m_pcbuffer.gcpcinfo.pcworkinfo.system_Statue)
{
String tmpFileName = globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_MethodName;
String methodfilename = tmpFileName.Substring(tmpFileName.LastIndexOf("\\") + 1);
string[] sArray = methodfilename.Split('.');
String tmpfolder = Path.Combine(globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.DataFolder, sArray[0]);
if (!Directory.Exists(tmpfolder))
{
Directory.CreateDirectory(tmpfolder);
}
tmpfolder = Path.Combine(tmpfolder, DateTime.Now.ToString("yyyyMMdd"));
if (!Directory.Exists(tmpfolder))
{
Directory.CreateDirectory(tmpfolder);
}
String cur_folder = tmpfolder;
String cur_filename = sArray[0] + "_" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒") + "_后.hw";
savefilename = Path.Combine(cur_folder, cur_filename);
//savefilename = globaldata.m_pcbuffer.gcpcinfo.pcfolderinfo.DataFolder + "\\" + DateTime.Now.ToString("yyyyMMdd") + "\\" + sArray[0] + "_" + DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒") + "_后.hw";
lock (globaldata.m_signalbuffer.Save_Port3)
{
if (globaldata.m_signalbuffer.Save_Port3.Count > 1)
{
if (globaldata.m_hmibuffer.gcinfo.methodstatus < 3 || globaldata.m_hmibuffer.gcinfo.methodstatus > 5)
{
starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port3[0]).ctimer;
globaldata.m_signalbuffer.Save_Port3.Clear();
// if (globaldata.m_hmibuffer.gcinfo.methodstatus > 5 && saveflag)
if (saveflag)
{
starttimer = globaldata.m_hmibuffer.gcinfo.NowStartTime;
endtimer = globaldata.m_hmibuffer.gcinfo.NowEndTime;
//Log.Info("Channel3 Save Data: " + starttimer.ToString() + "-" + endtimer.ToString());
int index1 = timePoint.FindIndex(item => item >= starttimer);
// int index2 = timePoint.FindIndex(item => item >= endtimer);
int index2 = timePoint.FindLastIndex(item => item <= endtimer);
if (index1 >= 0)
{
if (index2 <= 0)
{
index2 = timePoint.Count;
}
}
if (index2 > index1 && index1 >= 0)
{
savePoint = listPoint.GetRange(index1, index2 - index1);
TWFile twfile = new TWFile(savefilename);
twfile.TW_Open();
for (int j = 0; j < savePoint.Count; j++)
{
twfile.bw.Write((int)(savePoint[j] * 1000));
}
twfile.TW_Close(savePoint.Count);
}
else
{
Log.Info("Channel3 Save Data: " + starttimer.ToString() + "-" + endtimer.ToString());
Log.Info("Channel3 Index1,Index2: " + index1.ToString() + "-" + index2.ToString());
Log.Info("Channel3 timePoint: " + timePoint[0].ToString() + "-" + timePoint[timePoint.Count - 1].ToString());
Log.Info("Channel3 Data Num:" + listPoint.Count.ToString());
// Log.Info("Channel3 Data Num:" + listPoint.Count.ToString());
}
starttimer = 0x7FFFFFFF;
savePoint.Clear();
saveflag = false;
}
}
else if (globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5)
{
for (int i = 0; i < globaldata.m_signalbuffer.Save_Port3.Count; i++)
{
if (globaldata.m_hmibuffer.gcinfo.NowStartTime <= ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port3[i]).ctimer)//&& (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port[i]).ctimer - starttimer) < 3000)
{
value = (((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port3[i]).cdata * 1000.0f);
dvalue = (float)Math.Round(value, 4);
lock (timePoint)
{
//if (globaldata.startflag) //&& globaldata.m_pcbuffer.gcpcinfo.pcfileinfo.cur_DataName != null)
{
timePoint.Add(((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port3[i]).ctimer);
listPoint.Add(dvalue);
saveflag = true;
}
}
}
}
globaldata.m_signalbuffer.Save_Port3.Clear();
}
else
{
listPoint.Clear();
timePoint.Clear();
//Console.WriteLine("等待开始按钮!");
if (!globaldata.startflag)
{
globaldata.m_signalbuffer.Save_Port3.Clear();
}
else
{
starttimer = ((SignalBuffer.Channel_XY)globaldata.m_signalbuffer.Save_Port3[0]).ctimer;
}
}
}
}
}
if (globaldata.cancelflag3)
{
if (this.savefilename != null)
{
if (File.Exists(this.savefilename))
{
File.Delete(this.savefilename);
}
}
globaldata.cancelflag3 = false;
}
}
}
catch (Exception ex)
{
Log.Error("Channel 3 Data Save Crash!");
Log.Error(ex.Message);
}
}
private void ChannelDataReStart()
{
try
{
t_DataSave = null;
if (datamre != null)
{
datamre.Reset();
}
t_DataSave = new Thread(Monitor_Data);
t_DataSave.IsBackground = true;
t_DataSave.Start();
}
catch
{
Log.Error("Channel 3 Data Save Thread Restart Crash!");
}
}
public void ChannelDataStart()
{
if( datamre != null)
{
datamre.Reset();
}
t_DataSave = new Thread(Monitor_Data);
t_DataSave.IsBackground = true;
t_DataSave.Start();
}
public void ChannelDataStop()
{
datamre.Set();
}
}
}
......@@ -96,7 +96,6 @@ namespace GcDevicePc.ProThread
}
}
public int WriteStartVal()
{
int ret = -1;
......@@ -426,7 +425,6 @@ namespace GcDevicePc.ProThread
return (ret == 0) ? true : false;
}
public bool SetBatCount(ushort val)
{
ushort mystate = val;
......
......@@ -6,6 +6,7 @@ using System.Threading;
using System.Collections;
using System.Net.NetworkInformation;
using GcDevicePc.Common;
using System.IO;
namespace GcDevicePc.ProThread
{
......@@ -43,10 +44,20 @@ namespace GcDevicePc.ProThread
Log.Info("Start Get PC Local IP...");
try
{
string file = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.StartupPath), "GC_Config\\GC_Set\\启动参数\\startup.ini");
INIOperation test = new INIOperation(file);
string Meshport = test.INIGetStringValue("NetWorkConfig", "网口", null);
if (string.IsNullOrEmpty(Meshport))
{
Meshport = "本地连接";
}
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
if (adapter.Name == "本地连接")
if (adapter.Name == Meshport)
{
bool pd1 = (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet || adapter.NetworkInterfaceType == NetworkInterfaceType.Wireless80211); //判断是否是以太网连接
if (pd1)
......
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading;
using GcDevicePc.IniParam;
namespace GcDevicePc.ProThread
{
class SignalDataToHw
{
[DllImport(@"HWSendData.dll", EntryPoint = "SendDataToHW")]
public static extern void GCSendDataToHW(Int32 data1, Int32 data2, Int32 data3);
#region 私有变量
ManualResetEvent datamre = new ManualResetEvent(false);
Thread t_DataToHw;
//String savefilename;
#endregion
#region HW控制功能函数
private void StartSendDataToHW()
{
GCSendDataToHW(1, 0, 1);
GCSendDataToHW(0, 1, 1);
}
private void StopSendDataToHW()
{
GCSendDataToHW(1, 0, 2);
GCSendDataToHW(0, 1, 2);
}
private void SendDataToHW_A(Int32 data)
{
GCSendDataToHW(data, 0, 3);
GCSendDataToHW(0, 0, 4);
}
private void SendDataToHW_B(Int32 data)
{
GCSendDataToHW(0, data, 4);
GCSendDataToHW(0, 0, 3);
}
private void SendDataToHW_AB(Int32 dataA, Int32 dataB)
{
GCSendDataToHW(dataA, dataB, 0);
}
#endregion
#region 数据输出逻辑
private ushort CheckNumandTime(int num, ushort[] Det, ushort[] Time)
{
ushort count = 0;
for (int i = 0; i < Det.Length; i++)
{
if (num == Det[i] || num == Time[i])
{
break;
}
else
{
count++;
}
}
return count;
}
private void CleanAllToHWData()
{
lock (globaldata.channelA_A)
{
globaldata.channelA_A.Clear();
}
lock (globaldata.channelA_B)
{
globaldata.channelA_B.Clear();
}
lock (globaldata.channelA_C)
{
globaldata.channelA_C.Clear();
}
lock (globaldata.channelB_A)
{
globaldata.channelB_A.Clear();
}
lock (globaldata.channelB_B)
{
globaldata.channelB_B.Clear();
}
lock (globaldata.channelB_C)
{
globaldata.channelB_C.Clear();
}
}
private void InitSendToHWData()
{
int mydataA = 0;
int mydataB = 0;
int i = 0;
for (i = 0; i < 5; i++)
{
switch (CProfileDevice.m_DevParam.signal.uDetA[0])
{
case 1:
if (globaldata.channelA_A.Count >= 1)
{
mydataA = Int32.Parse(globaldata.channelA_A[globaldata.channelA_A.Count - 1].ToString());
globaldata.channelA_A.RemoveAt(0);
}
break;
case 2:
if (globaldata.channelA_B.Count >= 1)
{
mydataA = Int32.Parse(globaldata.channelA_B[globaldata.channelA_B.Count - 1].ToString());
globaldata.channelA_B.RemoveAt(0);
}
break;
case 3:
if (globaldata.channelA_C.Count >= 1)
{
mydataA = Int32.Parse(globaldata.channelA_C[globaldata.channelA_C.Count - 1].ToString());
globaldata.channelA_C.RemoveAt(0);
}
break;
}
switch (CProfileDevice.m_DevParam.signal.uDetB[0])
{
case 1:
if (globaldata.channelB_A.Count >= 1)
{
mydataB = Int32.Parse(globaldata.channelB_A[globaldata.channelB_A.Count - 1].ToString());
globaldata.channelB_A.RemoveAt(0);
}
break;
case 2:
if (globaldata.channelB_B.Count >= 1)
{
mydataB = Int32.Parse(globaldata.channelB_B[globaldata.channelB_B.Count - 1].ToString());
globaldata.channelB_B.RemoveAt(0);
}
break;
case 3:
if (globaldata.channelB_C.Count >= 1)
{
mydataB = Int32.Parse(globaldata.channelB_C[globaldata.channelB_C.Count - 1].ToString());
globaldata.channelB_C.RemoveAt(0);
}
break;
}
if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1 && CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
{
SendDataToHW_AB(mydataA, mydataB);
Thread.Sleep(50);
}
//写入A
if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1 && CProfileDevice.m_DevParam.signal.u16ChannelB != 1)
{
SendDataToHW_A(mydataA);
Thread.Sleep(50);
}
//写入B
if (CProfileDevice.m_DevParam.signal.u16ChannelA != 1 && CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
{
SendDataToHW_B(mydataB);
Thread.Sleep(50);
}
}
}
private void EndSendToHWData(ushort lastA, int offsetA, ushort lastB, int offsetB)
{
int mydataA = 0;
int mydataB = 0;
int i = 0;
for (i = 0; i < 5; i++)
{
switch (CProfileDevice.m_DevParam.signal.uDetA[lastA])
{
case 1:
if (globaldata.channelA_A.Count >= 1)
{
mydataA = Int32.Parse(globaldata.channelA_A[0].ToString()) - offsetA;
globaldata.channelA_A.RemoveAt(0);
}
break;
case 2:
if (globaldata.channelA_B.Count >= 1)
{
mydataA = Int32.Parse(globaldata.channelA_B[0].ToString()) - offsetA;
globaldata.channelA_B.RemoveAt(0);
}
break;
case 3:
if (globaldata.channelA_C.Count >= 1)
{
mydataA = Int32.Parse(globaldata.channelA_C[0].ToString()) - offsetA;
globaldata.channelA_C.RemoveAt(0);
}
break;
}
switch (CProfileDevice.m_DevParam.signal.uDetB[lastB])
{
case 1:
if (globaldata.channelB_A.Count >= 1)
{
mydataB = Int32.Parse(globaldata.channelB_A[0].ToString()) - offsetB;
globaldata.channelB_A.RemoveAt(0);
}
break;
case 2:
if (globaldata.channelB_B.Count >= 1)
{
mydataB = Int32.Parse(globaldata.channelB_B[0].ToString()) - offsetB;
globaldata.channelB_B.RemoveAt(0);
}
break;
case 3:
if (globaldata.channelB_C.Count >= 1)
{
mydataB = Int32.Parse(globaldata.channelB_C[0].ToString()) - offsetB;
globaldata.channelB_C.RemoveAt(0);
}
break;
}
if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1 && CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
{
SendDataToHW_AB(mydataA, mydataB);
Thread.Sleep(50);
}
//写入A
if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1 && CProfileDevice.m_DevParam.signal.u16ChannelB != 1)
{
SendDataToHW_A(mydataA);
Thread.Sleep(50);
}
//写入B
if (CProfileDevice.m_DevParam.signal.u16ChannelA != 1 && CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
{
SendDataToHW_B(mydataB);
Thread.Sleep(50);
}
}
}
private void SendToHW_Draw()
{
DateTime StartTimeA;
DateTime StartTimeB;
DateTime EndTimeA;
DateTime EndTimeB;
TimeSpan tsA;
TimeSpan tsB;
int secA;
int secB;
int mydataA = 0;
int mydataA_old = 0;
int mydataB = 0;
int mydataB_old = 0;
int offetA = 0;
int offetB = 0;
int StepA = 0;
int StepB = 0;
//bool StepA_flag = false;
// bool StepB_flag = false;
bool changeA_flag = false;
bool changeB_flag = false;
bool run_stop = false;
ushort SendNumA = 0;
ushort SendNumB = 0;
ushort MAXNum = 0;
//int i = 0;
bool runflag = false;
while (true)
{
if ((globaldata.m_hmibuffer.gcinfo.methodstatus == 4 || globaldata.m_hmibuffer.gcinfo.methodstatus == 5) && globaldata.m_hmibuffer.gcinfo.hmistatus == 4 && run_stop != true)
{
InitSendToHWData();
//清除所有数据,准备传输
CleanAllToHWData();
//开启绘图通知
StartSendDataToHW();
//绘图通知开启flag
runflag = true;
if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1)
{
SendNumA = CheckNumandTime(0, CProfileDevice.m_DevParam.signal.uDetA, CProfileDevice.m_DevParam.signal.u16DetTimeLengthA);
}
if (CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
{
SendNumB = CheckNumandTime(0, CProfileDevice.m_DevParam.signal.uDetB, CProfileDevice.m_DevParam.signal.u16DetTimeLengthB);
}
// LogHelper.I("StepA StpeB is", SendNumA.ToString() + " "+ SendNumB.ToString());
MAXNum = SendNumA > SendNumB ? SendNumA : SendNumB;
if (CProfileDevice.m_DevParam.signal.u16ChannelA == 1 || CProfileDevice.m_DevParam.signal.u16ChannelB == 1)
{
StepA = 0;
StepB = 0;
{
StartTimeA = DateTime.Now;
StartTimeB = DateTime.Now;
changeA_flag = false;
changeB_flag = false;
mydataA = 0;
mydataB = 0;
while (true)
{
EndTimeA = DateTime.Now;
tsA = StartTimeA.Subtract(EndTimeA).Duration();
secA = (int)tsA.TotalSeconds;
EndTimeB = DateTime.Now;
tsB = StartTimeB.Subtract(EndTimeB).Duration();
secB = (int)tsB.TotalSeconds;
if (StepA < SendNumA)
{
if (secA <= CProfileDevice.m_DevParam.signal.u16DetTimeLengthA[StepA])
{
//Console.WriteLine("总共:" + SendNumA.ToString() + " 阶段,现在是第" + StepA.ToString() + "个阶段:" + secA.ToString() + "/" + CProfileDevice.m_DevParam.signal.u16DetTimeLengthA[i].ToString());
switch (CProfileDevice.m_DevParam.signal.uDetA[StepA])
{
case 1:
if (globaldata.channelA_A.Count >= 1)
{
if (changeA_flag)
{
offetA = Int32.Parse(globaldata.channelA_A[0].ToString()) - mydataA_old;
changeA_flag = false;
}
mydataA = Int32.Parse(globaldata.channelA_A[0].ToString()) - offetA;
mydataA_old = mydataA;
}
break;
case 2:
if (globaldata.channelA_B.Count >= 1)
{
if (changeA_flag)
{
offetA = Int32.Parse(globaldata.channelA_B[0].ToString()) - mydataA_old;
changeA_flag = false;
}
mydataA = Int32.Parse(globaldata.channelA_B[0].ToString()) - offetA;
mydataA_old = mydataA;
}
break;
case 3:
if (globaldata.channelA_C.Count >= 1)
{
if (changeA_flag)
{
offetA = Int32.Parse(globaldata.channelA_C[0].ToString()) - mydataA_old;
changeA_flag = false;
}
mydataA = Int32.Parse(globaldata.channelA_C[0].ToString()) - offetA;
mydataA_old = mydataA;
}
break;
}
if (globaldata.channelA_A.Count >= 1)
{
globaldata.channelA_A.RemoveAt(0);
}
if (globaldata.channelA_B.Count >= 1)
{
globaldata.channelA_B.RemoveAt(0);
}
if (globaldata.channelA_C.Count >= 1)
{
globaldata.channelA_C.RemoveAt(0);
}
}
else
{
// LogHelper.I("StepA++ ", StepA.ToString() + " " + SendNumA.ToString());
StepA++;
StartTimeA = DateTime.Now;
changeA_flag = true;
}
}
if (StepB < SendNumB)
{
if (secB <= CProfileDevice.m_DevParam.signal.u16DetTimeLengthB[StepB])
{
//Console.WriteLine("总共:" + SendNumB.ToString() + " 阶段,现在是第" + StepB.ToString() + "个阶段:" + secB.ToString() + "/" + CProfileDevice.m_DevParam.signal.u16DetTimeLengthB[i].ToString());
switch (CProfileDevice.m_DevParam.signal.uDetB[StepB])
{
case 1:
if (globaldata.channelB_A.Count >= 1)
{
if (changeB_flag)
{
offetB = Int32.Parse(globaldata.channelB_A[0].ToString()) - mydataB_old;
changeB_flag = false;
}
mydataB = Int32.Parse(globaldata.channelB_A[0].ToString()) - offetB;
mydataB_old = mydataB;
}
break;
case 2:
if (globaldata.channelB_B.Count >= 1)
{
if (changeB_flag)
{
offetB = Int32.Parse(globaldata.channelB_B[0].ToString()) - mydataB_old;
changeB_flag = false;
}
mydataB = Int32.Parse(globaldata.channelB_B[0].ToString()) - offetB;
mydataB_old = mydataB;
}
break;
case 3:
if (globaldata.channelB_C.Count >= 1)
{
if (changeB_flag)
{
offetB = Int32.Parse(globaldata.channelB_C[0].ToString()) - mydataB_old;
changeB_flag = false;
}
mydataB = Int32.Parse(globaldata.channelB_C[0].ToString()) - offetB;
mydataB_old = mydataB;
}
break;
}
if (globaldata.channelB_A.Count >= 1)
{
globaldata.channelB_A.RemoveAt(0);
}
if (globaldata.channelB_B.Count >= 1)
{
globaldata.channelB_B.RemoveAt(0);
}
if (globaldata.channelB_C.Count >= 1)
{
globaldata.channelB_C.RemoveAt(0);
}
}
else
{
// LogHelper.I("StepB ", StepB.ToString() + " " + SendNumB.ToString());
StepB++;
StartTimeB = DateTime.Now;
changeB_flag = true;
}
}
//写入AB
if (StepA < SendNumA && StepB < SendNumB)
{
//LogHelper.I("SendDataToHW A B", secA.ToString() + " "+ secB.ToString());
SendDataToHW_AB(mydataA, mydataB);
Thread.Sleep(50);
}
//写入A
if (StepA < SendNumA && StepB >= SendNumB)
{
// LogHelper.I("SendDataToHW_A", secA.ToString());
SendDataToHW_A(mydataA);
Thread.Sleep(50);
}
//写入B
if (StepB < SendNumB && StepA >= SendNumA)
{
// LogHelper.I("SendDataToHW_B", secB.ToString());
SendDataToHW_B(mydataB);
Thread.Sleep(50);
}
if (StepB >= SendNumB && StepA >= SendNumA)
{
run_stop = true;
break;
}
if ((globaldata.m_hmibuffer.gcinfo.methodstatus != 4 && globaldata.m_hmibuffer.gcinfo.methodstatus != 5))
{
//LogHelper.I("methodstatus", "stop");
run_stop = true;
break;
}
}
//if ((globaldata.m_hmibuffer.gcinfo.methodstatus != 4 && globaldata.m_hmibuffer.gcinfo.methodstatus != 5))
//{
// break;
//}
}
}
}
if ((globaldata.m_hmibuffer.gcinfo.methodstatus != 4 && globaldata.m_hmibuffer.gcinfo.methodstatus != 5) || run_stop)
{
if (runflag)
{
StopSendDataToHW();
CleanAllToHWData();
runflag = false;
run_stop = false;
}
}
}
}
#endregion
public void DataToHwStart()
{
if (datamre != null)
{
datamre.Reset();
}
t_DataToHw = new Thread(SendToHW_Draw);
t_DataToHw.IsBackground = true;
t_DataToHw.Start();
}
public void DataToHwStop()
{
datamre.Set();
}
}
}
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="1.0.0.0" name="MyApplication.app" />
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<!-- UAC 清单选项
如果想要更改 Windows 用户帐户控制级别,请使用
以下节点之一替换 requestedExecutionLevel 节点。n
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
指定 requestedExecutionLevel 元素将禁用文件和注册表虚拟化。
如果你的应用程序需要此虚拟化来实现向后兼容性,则删除此
元素。
-->
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
</requestedPrivileges>
<applicationRequestMinimum>
<defaultAssemblyRequest permissionSetReference="Custom" />
<PermissionSet class="System.Security.PermissionSet" version="1" ID="Custom" SameSite="site" Unrestricted="true" />
</applicationRequestMinimum>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- 设计此应用程序与其一起工作且已针对此应用程序进行测试的
Windows 版本的列表。取消评论适当的元素,
Windows 将自动选择最兼容的环境。 -->
<!-- Windows Vista -->
<!--<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}" />-->
<!-- Windows 7 -->
<!--<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}" />-->
<!-- Windows 8 -->
<!--<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}" />-->
<!-- Windows 8.1 -->
<!--<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}" />-->
<!-- Windows 10 -->
<!--<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />-->
</application>
</compatibility>
<!-- 指示该应用程序可以感知 DPI 且 Windows 在 DPI 较高时将不会对其进行
自动缩放。Windows Presentation Foundation (WPF)应用程序自动感知 DPI,无需
选择加入。选择加入此设置的 Windows 窗体应用程序(目标设定为 .NET Framework 4.6 )还应
在其 app.config 中将 "EnableWindowsFormsHighDpiAutoResizing" 设置设置为 "true"。-->
<!--
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>
-->
<!-- 启用 Windows 公共控件和对话框的主题(Windows XP 和更高版本) -->
<!--
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
-->
</assembly>
\ No newline at end of file
......@@ -30,6 +30,7 @@
{
this.button1 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
this.gcTitle1 = new GcDevicePc.Controls.GCTitle();
this.SuspendLayout();
//
// button1
......@@ -44,7 +45,7 @@
//
// button2
//
this.button2.Location = new System.Drawing.Point(81, 211);
this.button2.Location = new System.Drawing.Point(250, 364);
this.button2.Name = "button2";
this.button2.Size = new System.Drawing.Size(75, 23);
this.button2.TabIndex = 1;
......@@ -52,11 +53,20 @@
this.button2.UseVisualStyleBackColor = true;
this.button2.Click += new System.EventHandler(this.button2_Click);
//
// gcTitle1
//
this.gcTitle1.Dock = System.Windows.Forms.DockStyle.Top;
this.gcTitle1.Location = new System.Drawing.Point(0, 0);
this.gcTitle1.Name = "gcTitle1";
this.gcTitle1.Size = new System.Drawing.Size(800, 20);
this.gcTitle1.TabIndex = 2;
//
// TestForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(800, 583);
this.Controls.Add(this.gcTitle1);
this.Controls.Add(this.button2);
this.Controls.Add(this.button1);
this.Name = "TestForm";
......@@ -69,5 +79,6 @@
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private Controls.GCTitle gcTitle1;
}
}
\ No newline at end of file
using GcDevicePc.Controls;
using GcDevicePc.ConfigMethod;
using GcDevicePc.Controls;
using System;
using System.Collections.Generic;
using System.ComponentModel;
......@@ -17,9 +18,12 @@ namespace GcDevicePc
public TestForm()
{
InitializeComponent();
bgWorker.DoWork += BgWorker_DoWork;
bgWorker.RunWorkerCompleted += BgWorker_RunWorkerCompleted;
//bgWorker.DoWork += BgWorker_DoWork;
//title.Show();
//bgWorker.RunWorkerCompleted += BgWorker_RunWorkerCompleted;
}
//GCTitle title = new GCTitle();
BackgroundWorker bgWorker = new BackgroundWorker();
PrompBox loadingCtl = new PrompBox(162, true);//定义加载控件
......@@ -35,19 +39,59 @@ namespace GcDevicePc
loadingCtl.Hide();
}
Form1 form1;
private void btnShow_Click(object sender, EventArgs e)
{
loadingCtl.TipsInfo = "提示信息";
//显示加载动画
loadingCtl.ShowLoading(this);
Application.DoEvents();
bgWorker.RunWorkerAsync();
//loadingCtl.TipsInfo = "提示信息";
////显示加载动画
//loadingCtl.ShowLoading(this);
//Application.DoEvents();
//bgWorker.RunWorkerAsync();
//this.pictureMenu1.PMOptbtnstatus = 3;
//(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 4;
//kailiang
if (form1 == null)
{
form1 = new Form1("asdasdasdsa");
form1.Show();
}
else if(form1.IsDisposed)
{
form1 = new Form1("asdasdasdsa");
form1.Show();
}
else
{
form1.Activate();
}
}
private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("asd");
//MessageBox.Show("asd");
//this.pictureMenu1.PMOptbtnstatus = 4;
//(this.title.Controls.Find("pictureMenu1", true)[0] as PictureMenu).PMOptbtnstatus = 3;
//tinfliang
if (form1 == null)
{
form1 = new Form1(1111);
form1.Show();
}
else if (form1.IsDisposed)
{
form1 = new Form1(1111);
form1.Show();
}
else
{
form1.Activate();
}
}
}
}
......@@ -69,6 +69,8 @@
this.label12 = new System.Windows.Forms.Label();
this.groupBox7 = new System.Windows.Forms.GroupBox();
this.permin = new System.Windows.Forms.CheckBox();
this.label15 = new System.Windows.Forms.Label();
this.cmbMeshport = new System.Windows.Forms.ComboBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
......@@ -80,6 +82,8 @@
//
// groupBox1
//
this.groupBox1.Controls.Add(this.cmbMeshport);
this.groupBox1.Controls.Add(this.label15);
this.groupBox1.Controls.Add(this.label8);
this.groupBox1.Controls.Add(this.label7);
this.groupBox1.Controls.Add(this.mac6);
......@@ -130,6 +134,7 @@
this.mac6.Size = new System.Drawing.Size(35, 21);
this.mac6.TabIndex = 7;
this.mac6.Text = "00";
this.mac6.Click += new System.EventHandler(this.CaseNo_TextClick);
this.mac6.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CaseNo_KeyPress);
//
// mac5
......@@ -140,6 +145,8 @@
this.mac5.Size = new System.Drawing.Size(35, 21);
this.mac5.TabIndex = 6;
this.mac5.Text = "00";
this.mac5.Click += new System.EventHandler(this.CaseNo_TextClick);
this.mac5.TextChanged += new System.EventHandler(this.CaseNo_TextBoxChange);
this.mac5.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CaseNo_KeyPress);
//
// label6
......@@ -175,11 +182,12 @@
// label3
//
this.label3.AutoSize = true;
this.label3.Location = new System.Drawing.Point(103, 26);
this.label3.Location = new System.Drawing.Point(333, 89);
this.label3.Name = "label3";
this.label3.Size = new System.Drawing.Size(107, 12);
this.label3.TabIndex = 7;
this.label3.Text = "00:00:00:00:00:00";
this.label3.Visible = false;
//
// changemac
//
......@@ -199,6 +207,8 @@
this.mac4.Size = new System.Drawing.Size(35, 21);
this.mac4.TabIndex = 5;
this.mac4.Text = "00";
this.mac4.Click += new System.EventHandler(this.CaseNo_TextClick);
this.mac4.TextChanged += new System.EventHandler(this.CaseNo_TextBoxChange);
this.mac4.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CaseNo_KeyPress);
//
// mac3
......@@ -209,6 +219,8 @@
this.mac3.Size = new System.Drawing.Size(35, 21);
this.mac3.TabIndex = 4;
this.mac3.Text = "00";
this.mac3.Click += new System.EventHandler(this.CaseNo_TextClick);
this.mac3.TextChanged += new System.EventHandler(this.CaseNo_TextBoxChange);
this.mac3.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CaseNo_KeyPress);
//
// mac2
......@@ -219,6 +231,8 @@
this.mac2.Size = new System.Drawing.Size(35, 21);
this.mac2.TabIndex = 3;
this.mac2.Text = "00";
this.mac2.Click += new System.EventHandler(this.CaseNo_TextClick);
this.mac2.TextChanged += new System.EventHandler(this.CaseNo_TextBoxChange);
this.mac2.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CaseNo_KeyPress);
//
// mac1
......@@ -229,6 +243,8 @@
this.mac1.Size = new System.Drawing.Size(35, 21);
this.mac1.TabIndex = 2;
this.mac1.Text = "00";
this.mac1.Click += new System.EventHandler(this.CaseNo_TextClick);
this.mac1.TextChanged += new System.EventHandler(this.CaseNo_TextBoxChange);
this.mac1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.CaseNo_KeyPress);
//
// label2
......@@ -243,11 +259,12 @@
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(7, 26);
this.label1.Location = new System.Drawing.Point(237, 89);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(83, 12);
this.label1.TabIndex = 0;
this.label1.Text = "目前MAC绑定:";
this.label1.Visible = false;
//
// groupBox2
//
......@@ -485,6 +502,24 @@
this.permin.UseVisualStyleBackColor = true;
this.permin.CheckedChanged += new System.EventHandler(this.permin_CheckedChanged);
//
// label15
//
this.label15.AutoSize = true;
this.label15.Location = new System.Drawing.Point(43, 26);
this.label15.Name = "label15";
this.label15.Size = new System.Drawing.Size(47, 12);
this.label15.TabIndex = 14;
this.label15.Text = "网 口:";
//
// cmbMeshport
//
this.cmbMeshport.FormattingEnabled = true;
this.cmbMeshport.Location = new System.Drawing.Point(97, 21);
this.cmbMeshport.Name = "cmbMeshport";
this.cmbMeshport.Size = new System.Drawing.Size(148, 20);
this.cmbMeshport.TabIndex = 15;
this.cmbMeshport.SelectedIndexChanged += new System.EventHandler(this.cmbMeshport_SelectedIndexChanged);
//
// UserConfig
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
......@@ -561,5 +596,7 @@
private System.Windows.Forms.Button changelocal;
private System.Windows.Forms.GroupBox groupBox7;
private System.Windows.Forms.CheckBox permin;
private System.Windows.Forms.ComboBox cmbMeshport;
private System.Windows.Forms.Label label15;
}
}
\ No newline at end of file
......@@ -112,10 +112,21 @@ namespace GcDevicePc
private bool ChosenAdapter(string localip)
{
string file = Path.Combine(Path.GetDirectoryName(System.Windows.Forms.Application.StartupPath), "GC_Config\\GC_Set\\启动参数\\startup.ini");
INIOperation test = new INIOperation(file);
string Meshport = test.INIGetStringValue("NetWorkConfig", "网口", null);
if (string.IsNullOrEmpty(Meshport))
{
Meshport = "本地连接";
}
NetworkInterface[] nics = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in nics)
{
if (adapter.Name == "本地连接")
if (adapter.Name == Meshport)
{
bool Pd1 = (adapter.NetworkInterfaceType == NetworkInterfaceType.Ethernet); //判断是否是以太网连接
if (Pd1)
......@@ -148,6 +159,7 @@ namespace GcDevicePc
INIOperation test = new INIOperation(file);
string MAC = test.INIGetStringValue("NetWorkConfig", "MAC地址", null);
string Meshport = test.INIGetStringValue("NetWorkConfig", "网口", null);
string value = test.INIGetStringValue("StartUp", "自启动", null);
string opensys = test.INIGetStringValue("StartUp", "打开系统", null);
string runtype = test.INIGetStringValue("StartUp", "运行类型", null);
......@@ -156,8 +168,16 @@ namespace GcDevicePc
string err_log = test.INIGetStringValue("Logs", "ErrLog", null);
string hmi_log = test.INIGetStringValue("Logs", "HmiLog", null);
try
{
NetworkInterface[] port = NetworkInterface.GetAllNetworkInterfaces();
foreach (NetworkInterface adapter in port)
{
cmbMeshport.Items.Add(adapter.Name);
}
if (String.IsNullOrEmpty(MAC))
{
this.label1.Text = "目前Mac(未绑定):";
......@@ -185,6 +205,10 @@ namespace GcDevicePc
{
}
if (!string.IsNullOrEmpty(Meshport))
{
cmbMeshport.SelectedText = Meshport;
}
if (Convert.ToInt32(value) == 1)
{
......@@ -300,8 +324,23 @@ namespace GcDevicePc
else e.Handled = true;
}
}
}
private void CaseNo_TextBoxChange(object sender, EventArgs e)
{
TextBox text = sender as TextBox;
if (text.Text.Length == 2)
{
text.Parent.SelectNextControl(ActiveControl, true, true, true, true);
}
}
private void CaseNo_TextClick(object sender, EventArgs e)
{
TextBox text = sender as TextBox;
text.SelectAll();
}
private void changemac_Click(object sender, EventArgs e)
{
//bool ret = false;
......@@ -570,5 +609,22 @@ namespace GcDevicePc
}
}
private void cmbMeshport_SelectedIndexChanged(object sender, EventArgs e)
{
string file = Path.Combine(Path.GetDirectoryName(Application.StartupPath), "GC_Config\\GC_Set\\启动参数\\startup.ini");
try
{
INIOperation test = new INIOperation(file);
test.INIWriteValue(file, "NetWorkConfig", "网口", cmbMeshport.Items[cmbMeshport.SelectedIndex].ToString());
}
catch
{
}
}
}
}
......@@ -61,11 +61,30 @@
this.hair_h2 = new System.Windows.Forms.Button();
this.hair_a1 = new System.Windows.Forms.Button();
this.hair_h1 = new System.Windows.Forms.Button();
this.groupBox5 = new System.Windows.Forms.GroupBox();
this.tcdset3 = new System.Windows.Forms.Button();
this.tcdset2 = new System.Windows.Forms.Button();
this.label13 = new System.Windows.Forms.Label();
this.label12 = new System.Windows.Forms.Label();
this.tcddac3 = new System.Windows.Forms.TextBox();
this.tcddac2 = new System.Windows.Forms.TextBox();
this.label11 = new System.Windows.Forms.Label();
this.label10 = new System.Windows.Forms.Label();
this.label9 = new System.Windows.Forms.Label();
this.label8 = new System.Windows.Forms.Label();
this.groupBox6 = new System.Windows.Forms.GroupBox();
this.tcd2_sw = new System.Windows.Forms.Button();
this.tcd3_sw = new System.Windows.Forms.Button();
this.tcd1_sw = new System.Windows.Forms.Button();
this.tcdset1 = new System.Windows.Forms.Button();
this.tcddac1 = new System.Windows.Forms.TextBox();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox3.SuspendLayout();
this.groupBox4.SuspendLayout();
this.groupBox8.SuspendLayout();
this.groupBox5.SuspendLayout();
this.groupBox6.SuspendLayout();
this.SuspendLayout();
//
// groupBox1
......@@ -206,7 +225,7 @@
this.groupBox3.Controls.Add(this.chosenbtn);
this.groupBox3.Controls.Add(this.ProName);
this.groupBox3.Controls.Add(this.label3);
this.groupBox3.Location = new System.Drawing.Point(12, 155);
this.groupBox3.Location = new System.Drawing.Point(12, 287);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(495, 112);
this.groupBox3.TabIndex = 2;
......@@ -280,7 +299,7 @@
this.groupBox4.Controls.Add(this.progressBar2);
this.groupBox4.Controls.Add(this.label5);
this.groupBox4.Controls.Add(this.firmwareupdate);
this.groupBox4.Location = new System.Drawing.Point(12, 273);
this.groupBox4.Location = new System.Drawing.Point(12, 405);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(495, 84);
this.groupBox4.TabIndex = 3;
......@@ -335,7 +354,7 @@
this.groupBox8.Controls.Add(this.hair_h2);
this.groupBox8.Controls.Add(this.hair_a1);
this.groupBox8.Controls.Add(this.hair_h1);
this.groupBox8.Location = new System.Drawing.Point(12, 363);
this.groupBox8.Location = new System.Drawing.Point(12, 495);
this.groupBox8.Name = "groupBox8";
this.groupBox8.Size = new System.Drawing.Size(495, 72);
this.groupBox8.TabIndex = 6;
......@@ -382,11 +401,181 @@
this.hair_h1.UseVisualStyleBackColor = true;
this.hair_h1.Click += new System.EventHandler(this.hair_h1_Click);
//
// groupBox5
//
this.groupBox5.Controls.Add(this.tcdset3);
this.groupBox5.Controls.Add(this.tcdset2);
this.groupBox5.Controls.Add(this.label13);
this.groupBox5.Controls.Add(this.label12);
this.groupBox5.Controls.Add(this.tcddac3);
this.groupBox5.Controls.Add(this.tcddac2);
this.groupBox5.Controls.Add(this.label11);
this.groupBox5.Controls.Add(this.label10);
this.groupBox5.Controls.Add(this.label9);
this.groupBox5.Controls.Add(this.label8);
this.groupBox5.Controls.Add(this.groupBox6);
this.groupBox5.Controls.Add(this.tcdset1);
this.groupBox5.Controls.Add(this.tcddac1);
this.groupBox5.Location = new System.Drawing.Point(12, 155);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(495, 129);
this.groupBox5.TabIndex = 7;
this.groupBox5.TabStop = false;
this.groupBox5.Text = "TCD设置";
//
// tcdset3
//
this.tcdset3.Location = new System.Drawing.Point(209, 92);
this.tcdset3.Name = "tcdset3";
this.tcdset3.Size = new System.Drawing.Size(51, 23);
this.tcdset3.TabIndex = 12;
this.tcdset3.Text = "设置";
this.tcdset3.UseVisualStyleBackColor = true;
this.tcdset3.Click += new System.EventHandler(this.tcdset3_Click);
//
// tcdset2
//
this.tcdset2.Location = new System.Drawing.Point(207, 61);
this.tcdset2.Name = "tcdset2";
this.tcdset2.Size = new System.Drawing.Size(51, 23);
this.tcdset2.TabIndex = 11;
this.tcdset2.Text = "设置";
this.tcdset2.UseVisualStyleBackColor = true;
this.tcdset2.Click += new System.EventHandler(this.tcdset2_Click);
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(178, 97);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(17, 12);
this.label13.TabIndex = 10;
this.label13.Text = "mA";
//
// label12
//
this.label12.AutoSize = true;
this.label12.Location = new System.Drawing.Point(178, 66);
this.label12.Name = "label12";
this.label12.Size = new System.Drawing.Size(17, 12);
this.label12.TabIndex = 9;
this.label12.Text = "mA";
//
// tcddac3
//
this.tcddac3.Location = new System.Drawing.Point(85, 93);
this.tcddac3.Name = "tcddac3";
this.tcddac3.Size = new System.Drawing.Size(87, 21);
this.tcddac3.TabIndex = 8;
//
// tcddac2
//
this.tcddac2.Location = new System.Drawing.Point(85, 62);
this.tcddac2.Name = "tcddac2";
this.tcddac2.Size = new System.Drawing.Size(87, 21);
this.tcddac2.TabIndex = 7;
//
// label11
//
this.label11.AutoSize = true;
this.label11.Location = new System.Drawing.Point(178, 33);
this.label11.Name = "label11";
this.label11.Size = new System.Drawing.Size(17, 12);
this.label11.TabIndex = 6;
this.label11.Text = "mA";
//
// label10
//
this.label10.AutoSize = true;
this.label10.Location = new System.Drawing.Point(25, 96);
this.label10.Name = "label10";
this.label10.Size = new System.Drawing.Size(59, 12);
this.label10.TabIndex = 5;
this.label10.Text = "TCD(后):";
//
// label9
//
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(26, 65);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(59, 12);
this.label9.TabIndex = 4;
this.label9.Text = "TCD(中):";
//
// label8
//
this.label8.AutoSize = true;
this.label8.Location = new System.Drawing.Point(26, 32);
this.label8.Name = "label8";
this.label8.Size = new System.Drawing.Size(59, 12);
this.label8.TabIndex = 3;
this.label8.Text = "TCD(前):";
//
// groupBox6
//
this.groupBox6.Controls.Add(this.tcd2_sw);
this.groupBox6.Controls.Add(this.tcd3_sw);
this.groupBox6.Controls.Add(this.tcd1_sw);
this.groupBox6.Location = new System.Drawing.Point(278, 15);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(211, 105);
this.groupBox6.TabIndex = 2;
this.groupBox6.TabStop = false;
this.groupBox6.Text = "桥流开关";
//
// tcd2_sw
//
this.tcd2_sw.Location = new System.Drawing.Point(121, 29);
this.tcd2_sw.Name = "tcd2_sw";
this.tcd2_sw.Size = new System.Drawing.Size(75, 23);
this.tcd2_sw.TabIndex = 2;
this.tcd2_sw.Text = "中TCD(关)";
this.tcd2_sw.UseVisualStyleBackColor = true;
this.tcd2_sw.Click += new System.EventHandler(this.tcd2_sw_Click);
//
// tcd3_sw
//
this.tcd3_sw.Location = new System.Drawing.Point(71, 70);
this.tcd3_sw.Name = "tcd3_sw";
this.tcd3_sw.Size = new System.Drawing.Size(75, 23);
this.tcd3_sw.TabIndex = 1;
this.tcd3_sw.Text = "后TCD(关)";
this.tcd3_sw.UseVisualStyleBackColor = true;
this.tcd3_sw.Click += new System.EventHandler(this.tcd3_sw_Click);
//
// tcd1_sw
//
this.tcd1_sw.Location = new System.Drawing.Point(19, 29);
this.tcd1_sw.Name = "tcd1_sw";
this.tcd1_sw.Size = new System.Drawing.Size(75, 23);
this.tcd1_sw.TabIndex = 0;
this.tcd1_sw.Text = "前TCD(关)";
this.tcd1_sw.UseVisualStyleBackColor = true;
this.tcd1_sw.Click += new System.EventHandler(this.tcd1_sw_Click);
//
// tcdset1
//
this.tcdset1.Location = new System.Drawing.Point(209, 28);
this.tcdset1.Name = "tcdset1";
this.tcdset1.Size = new System.Drawing.Size(51, 23);
this.tcdset1.TabIndex = 1;
this.tcdset1.Text = "设置";
this.tcdset1.UseVisualStyleBackColor = true;
this.tcdset1.Click += new System.EventHandler(this.tcdset1_Click);
//
// tcddac1
//
this.tcddac1.Location = new System.Drawing.Point(85, 29);
this.tcddac1.Name = "tcddac1";
this.tcddac1.Size = new System.Drawing.Size(87, 21);
this.tcddac1.TabIndex = 0;
//
// auxtool
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(519, 448);
this.ClientSize = new System.Drawing.Size(519, 572);
this.Controls.Add(this.groupBox5);
this.Controls.Add(this.groupBox8);
this.Controls.Add(this.groupBox4);
this.Controls.Add(this.groupBox3);
......@@ -408,6 +597,9 @@
this.groupBox4.ResumeLayout(false);
this.groupBox4.PerformLayout();
this.groupBox8.ResumeLayout(false);
this.groupBox5.ResumeLayout(false);
this.groupBox5.PerformLayout();
this.groupBox6.ResumeLayout(false);
this.ResumeLayout(false);
}
......@@ -446,5 +638,22 @@
private System.Windows.Forms.Button hair_h1;
private System.Windows.Forms.TextBox firstfiredelay;
private System.Windows.Forms.Label label14;
private System.Windows.Forms.GroupBox groupBox5;
private System.Windows.Forms.Button tcdset3;
private System.Windows.Forms.Button tcdset2;
private System.Windows.Forms.Label label13;
private System.Windows.Forms.Label label12;
private System.Windows.Forms.TextBox tcddac3;
private System.Windows.Forms.TextBox tcddac2;
private System.Windows.Forms.Label label11;
private System.Windows.Forms.Label label10;
private System.Windows.Forms.Label label9;
private System.Windows.Forms.Label label8;
private System.Windows.Forms.GroupBox groupBox6;
private System.Windows.Forms.Button tcd2_sw;
private System.Windows.Forms.Button tcd3_sw;
private System.Windows.Forms.Button tcd1_sw;
private System.Windows.Forms.Button tcdset1;
private System.Windows.Forms.TextBox tcddac1;
}
}
\ No newline at end of file
......@@ -500,6 +500,121 @@ namespace GcDevicePc
hairsw(4);
}
public event TCD_SetDAC gctcd_setdac;
public event TCD_SW gctcd_sw;
private void tcdset1_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(tcddac1.Text))
{
MessageBox.Show("设置值不能为空!!!");
}
else
{
ushort val = ushort.Parse(tcddac1.Text);
if (val >= 0 && val < 150)
{
gctcd_setdac(0, val);
}
else
{
MessageBox.Show("超过设置值(0~150)!!!");
}
}
}
private void tcdset2_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(tcddac2.Text))
{
MessageBox.Show("设置值不能为空!!!");
}
else
{
ushort val = ushort.Parse(tcddac2.Text);
if (val >= 0 && val < 150)
{
gctcd_setdac(1, val);
}
else
{
MessageBox.Show("超过设置值(0~150)!!!");
}
}
}
private void tcdset3_Click(object sender, EventArgs e)
{
if (String.IsNullOrEmpty(tcddac3.Text))
{
MessageBox.Show("设置值不能为空!!!");
}
else
{
ushort val = ushort.Parse(tcddac3.Text);
if (val >= 0 && val < 150)
{
gctcd_setdac(2, val);
}
else
{
MessageBox.Show("超过设置值(0~150)!!!");
}
}
}
private void tcd1_sw_Click(object sender, EventArgs e)
{
String tcd1_flag = tcd1_sw.Text;
string[] sArray = tcd1_flag.Split(new char[2] { '(', ')' });
if (sArray[1] == "关")
{
tcd1_sw.Text = "前TCD(开)";
}
else if (sArray[1] == "开")
{
tcd1_sw.Text = "前TCD(关)";
}
Console.WriteLine(sArray[1]);
gctcd_sw(0);
}
private void tcd2_sw_Click(object sender, EventArgs e)
{
String tcd2_flag = tcd2_sw.Text;
string[] sArray = tcd2_flag.Split(new char[2] { '(', ')' });
if (sArray[1] == "关")
{
tcd2_sw.Text = "中TCD(开)";
}
else if (sArray[1] == "开")
{
tcd2_sw.Text = "中TCD(关)";
}
Console.WriteLine(sArray[1]);
gctcd_sw(1);
}
private void tcd3_sw_Click(object sender, EventArgs e)
{
String tcd3_flag = tcd3_sw.Text;
string[] sArray = tcd3_flag.Split(new char[2] { '(', ')' });
if (sArray[1] == "关")
{
tcd3_sw.Text = "后TCD(开)";
}
else if (sArray[1] == "开")
{
tcd3_sw.Text = "后TCD(关)";
}
Console.WriteLine(sArray[1]);
gctcd_sw(2);
}
}
}
......@@ -6,6 +6,7 @@ using System.Text;
using GcDevicePc.Common;
using GcDevicePc.IniParam;
using GcDevicePc.GCBuffer;
using System.Net;
namespace GcDevicePc
{
......@@ -98,19 +99,19 @@ namespace GcDevicePc
//
public static HWConfig m_hwconfig = new HWConfig();
//public static long channel_A = 0;
//public static long channel_B = 0;
//public static long channel_C = 0;
public static long channel_A = 0;
public static long channel_B = 0;
public static long channel_C = 0;
//public static ArrayList channelA_A = new ArrayList();
//public static ArrayList channelA_B = new ArrayList();
//public static ArrayList channelA_C = new ArrayList();
public static ArrayList channelA_A = new ArrayList();
public static ArrayList channelA_B = new ArrayList();
public static ArrayList channelA_C = new ArrayList();
//public static ArrayList channelB_A = new ArrayList();
//public static ArrayList channelB_B = new ArrayList();
//public static ArrayList channelB_C = new ArrayList();
public static ArrayList channelB_A = new ArrayList();
public static ArrayList channelB_B = new ArrayList();
public static ArrayList channelB_C = new ArrayList();
// public static RingBufferManager m_rsbuffer = new RingBufferManager(100000);
//public static RingBufferManager m_rsbuffer = new RingBufferManager(100000);
public static bool OS_STOP = false;
......@@ -177,6 +178,7 @@ namespace GcDevicePc
///
public static String DeviceNo; //HMI编号
public static String DeviceName; //HMI名字
public static IPAddress myIpaddr;
//public static AppInit m_appinit = new AppInit(); //程序初始化
......
......@@ -4,5 +4,6 @@
<package id="ini.net" version="1.1.0" targetFramework="net45" />
<package id="log4net" version="2.0.8" targetFramework="net45" />
<package id="M2Mqtt" version="4.3.0.0" targetFramework="net45" />
<package id="NModbus4" version="2.1.0" targetFramework="net45" />
<package id="WinFormAnimation" version="1.5.6298.3372" targetFramework="net40" />
</packages>
\ No newline at end of file
No preview for this file type
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment