Commit 819bd750 authored by shaxuezheng's avatar shaxuezheng

修改控制定时处理

parent b5267af2
This diff is collapsed.
...@@ -6,7 +6,13 @@ using System.Threading.Tasks; ...@@ -6,7 +6,13 @@ using System.Threading.Tasks;
namespace ModbusDemo namespace ModbusDemo
{ {
class startAddress
{
private ushort address;
private ushort num;
public ushort Address { get => address; set => address = value; }
public ushort Num { get => num; set => num = value; }
}
class WTDR18X class WTDR18X
{ {
public string addr { get; set; } public string addr { get; set; }
...@@ -75,4 +81,110 @@ namespace ModbusDemo ...@@ -75,4 +81,110 @@ namespace ModbusDemo
} }
} }
public class Ctrl
{
public string taskId;
public void settaskId(string taskId)
{
this.taskId = taskId;
}
public string gettaskId()
{
return taskId;
}
public List<Ss> ss { get; set; }
}
public class Op
{
public int duration;
public long startTime;
public int d0
{
get => D0;
set => D0 = value;
}
public int d1
{
get => D1;
set => D1 = value;
}
public int d2
{
get => D2;
set => D2 = value;
}
public int d3
{
get => D3;
set => D3 = value;
}
public int d4
{
get => D4;
set => D4 = value;
}
public int d5
{
get => D5;
set => D5 = value;
}
public long ts
{
get => Ts;
set => Ts = value;
}
private int D0;
private int D1;
private int D2;
private int D3;
private int D4;
private int D5;
private long Ts;
public void setDuration(int duration)
{
this.duration = duration;
}
public int getDuration()
{
return duration;
}
public void setStartTime(long startTime)
{
this.startTime = startTime;
}
public long getStartTime()
{
return startTime;
}
}
public class Ss
{
public byte addr;
public Op op;
public void setAddr(byte addr)
{
this.addr = addr;
}
public byte getAddr()
{
return addr;
}
public void setOp(Op op)
{
this.op = op;
}
public Op getOp()
{
return op;
}
}
} }
...@@ -11,6 +11,8 @@ ...@@ -11,6 +11,8 @@
<AssemblyName>WTG93UG</AssemblyName> <AssemblyName>WTG93UG</AssemblyName>
<TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion> <TargetFrameworkVersion>v4.5.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
<IsWebBootstrapper>false</IsWebBootstrapper>
<TargetFrameworkProfile />
<PublishUrl>publish\</PublishUrl> <PublishUrl>publish\</PublishUrl>
<Install>true</Install> <Install>true</Install>
<InstallFrom>Disk</InstallFrom> <InstallFrom>Disk</InstallFrom>
...@@ -23,10 +25,8 @@ ...@@ -23,10 +25,8 @@
<MapFileExtensions>true</MapFileExtensions> <MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision> <ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion> <ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust> <UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled> <BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x86</PlatformTarget> <PlatformTarget>x86</PlatformTarget>
...@@ -81,37 +81,29 @@ ...@@ -81,37 +81,29 @@
<Reference Include="System.Xml" /> <Reference Include="System.Xml" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Compile Include="414P.cs" /> <Compile Include="application\Pond.cs" />
<Compile Include="478C.cs" /> <Compile Include="Modular\414P.cs" />
<Compile Include="418X.cs" /> <Compile Include="Modular\478C.cs" />
<Compile Include="Modular\418X.cs" />
<Compile Include="Common\Modbuslib.cs" /> <Compile Include="Common\Modbuslib.cs" />
<Compile Include="ConvertJson.cs" />
<Compile Include="windows\Form1.cs"> <Compile Include="windows\Form1.cs">
<SubType>Form</SubType> <SubType>Form</SubType>
</Compile> </Compile>
<Compile Include="windows\Form1.Designer.cs"> <Compile Include="windows\Form1.Designer.cs">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</Compile> </Compile>
<Compile Include="mqttpacke.cs" /> <Compile Include="MessageFormat\mqttpacke.cs" />
<Compile Include="RData.cs" /> <Compile Include="MessageFormat\RData.cs" />
<Compile Include="UData.cs" /> <Compile Include="MessageFormat\UData.cs" />
<Compile Include="Common\ModSearch.cs" /> <Compile Include="Common\ModSearch.cs" />
<Compile Include="Common\WTModbus.cs" /> <Compile Include="Common\WTModbus.cs" />
<Compile Include="windows\frmInputValue.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="windows\frmInputValue.designer.cs">
<DependentUpon>frmInputValue.cs</DependentUpon>
</Compile>
<Compile Include="Program.cs" /> <Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Totxt.cs" /> <Compile Include="Common\Totxt.cs" />
<Compile Include="application\TransferPool.cs" />
<EmbeddedResource Include="windows\Form1.resx"> <EmbeddedResource Include="windows\Form1.resx">
<DependentUpon>Form1.cs</DependentUpon> <DependentUpon>Form1.cs</DependentUpon>
</EmbeddedResource> </EmbeddedResource>
<EmbeddedResource Include="windows\frmInputValue.resx">
<DependentUpon>frmInputValue.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Properties\Resources.resx"> <EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator> <Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput> <LastGenOutput>Resources.Designer.cs</LastGenOutput>
......
...@@ -54,8 +54,6 @@ namespace ModbusDemo ...@@ -54,8 +54,6 @@ namespace ModbusDemo
public string[] Value(ushort[] typeData, ushort[] Inputtype) public string[] Value(ushort[] typeData, ushort[] Inputtype)
{ {
string[] Valuepass = new string[MAX_AN_CH_NUM]; string[] Valuepass = new string[MAX_AN_CH_NUM];
if (typeData != null || Inputtype != null)
{
/********************/ /********************/
users.UserId = 0;//通道 users.UserId = 0;//通道
users.Data = typeData[0];//数据 users.Data = typeData[0];//数据
...@@ -129,11 +127,6 @@ namespace ModbusDemo ...@@ -129,11 +127,6 @@ namespace ModbusDemo
Valuepass[7] = current(users7.NegMin[users7.UserModel], users7.NegMax[users7.UserModel], users7.PosMin[users7.UserModel], Valuepass[7] = current(users7.NegMin[users7.UserModel], users7.NegMax[users7.UserModel], users7.PosMin[users7.UserModel],
users7.PosMax[users7.UserModel], users7.usMin[users7.UserModel], users7.usMax[users7.UserModel], users7.PosMax[users7.UserModel], users7.usMin[users7.UserModel], users7.usMax[users7.UserModel],
users7.Data); //处理函数 users7.Data); //处理函数
}
else
{
Valuepass = null;
}
return Valuepass; return Valuepass;
} }
...@@ -262,7 +255,7 @@ namespace ModbusDemo ...@@ -262,7 +255,7 @@ namespace ModbusDemo
/*****************有效判断*****************************/ /*****************有效判断*****************************/
if (text[0] == "0.000") if (text[0] == "0.000")
{ {
text[0] = "0"; text[0] = "Burn_out";
return text; return text;
} }
else else
......
...@@ -14,13 +14,9 @@ namespace ModbusDemo ...@@ -14,13 +14,9 @@ namespace ModbusDemo
[STAThread] [STAThread]
static void Main() static void Main()
{ {
Application.EnableVisualStyles(); Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1()); Application.Run(new Form1());
//Application.Run(new Demo_818X());
//Application.Run(new ProTest());
//Application.Run(new MDemo());
} }
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using ModbusDemo;
namespace ModbusDemo.application
{
class Pond
{
private string Sname;//池子的名称
private bool state;
private double Dlevel;//池子的液位
private double Lowwaterlevel;//液位最低水位
private double Peaklevel;//液位最高水位
private string Agitator;//搅拌器
private ushort current;//电流
private ushort Voltage;//电压
public string Sname1 { get => Sname; set => Sname = value; }
public bool State { get => state; set => state = value; }
public double Dlevel1 { get => Dlevel; set => Dlevel = value; }
public double Lowwaterlevel1 { get => Lowwaterlevel; set => Lowwaterlevel = value; }
public double Peaklevel1 { get => Peaklevel; set => Peaklevel = value; }
public ushort Voltage1 { get => Voltage; set => Voltage = value; }
public ushort Current { get => current; set => current = value; }
public string Agitator1 { get => Agitator; set => Agitator = value; }
//public class Agitator : ModbusAttribute //搅拌器
//{
// public bool state;
// public ushort[] current;//电流
// public ushort[] Voltage;//电压
//}
//public class pump : ModbusAttribute//泵
//{
// public bool state;
// public ushort[] current;//电流
// public ushort[] Voltage;//电压
//}
//public class Level : ModbusAttribute //液位属性
//{
// public ushort[] level;//液位
// public ushort[] passageway; //液位通道
// public double[] Lowwaterlevel; // 液位最低水位
// public double[] Peaklevel; // 液位最高水位
//}
//public class ModbusAttribute //modbus属性
//{
// public byte[] SlaveAddress;
// public ushort[] RegisterAddress;
//}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Timers;
namespace ModbusDemo.windows
{
class TransferPool
{
public string position;//位置
public class Source: ModbusAttribute //水源
{
public string Southeastwater; //东南水
public string Northeastwater; //东北水
public string Southwestwater; //西南水
public string Northwestwater; //西北水
public string Timingtime; //定时时间
public bool system_Statue;
}
public class passageway //通道
{
public Agitator agitator;
public pump pump;
public Level Level;//液位属性
}
public class Agitator: ModbusAttribute //搅拌器
{
public bool state;
public ushort[] current;//电流
public ushort[] Voltage;//电压
}
public class pump: ModbusAttribute//泵
{
public bool state;
public ushort[] current;//电流
public ushort[] Voltage;//电压
}
public class Level: ModbusAttribute //液位属性
{
public ushort[] level;//液位
public ushort[] passageway; //液位通道
public double[] Lowwaterlevel; // 液位最低水位
public double[] Peaklevel; // 液位最高水位
}
public class ModbusAttribute //modbus属性
{
public byte[] SlaveAddress;
public ushort[] RegisterAddress;
}
}
}
This diff is collapsed.
This diff is collapsed.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace ModbusRTU_Master
{
public partial class frmInputValue : Form
{
public frmInputValue()
{
InitializeComponent();
}
public double Value
{
set
{
this.txtValue.Text = value.ToString();
}
get { return Convert_To_Double(this.txtValue.Text); }
}
public string StringValue
{
set
{
this.txtValue.Text = value;
}
get
{
return this.txtValue.Text;
}
}
private double Convert_To_Double(string sKey)
{
if (sKey == "")
sKey = "0";
return double.Parse(sKey);
}
private void Number_Click(object sender, EventArgs e)
{
txtValue.Text = txtValue.Text + ((Button)sender).Tag;
}
private void btcommon_Click(object sender, EventArgs e)
{
if (txtValue.Text.IndexOf(".") < 0)
txtValue.Text += ".";
}
private void btdel_Click(object sender, EventArgs e)
{
txtValue.Text = txtValue.Text.Substring(0, txtValue.Text.Length - 1);
}
private void btClr_Click(object sender, EventArgs e)
{
txtValue.Text = "";
}
private void btMinus_Click(object sender, EventArgs e)
{
if (Convert_To_Double(txtValue.Text) > 0)
{
txtValue.Text = (Convert_To_Double(txtValue.Text) * (-1)).ToString();
}
}
private void btPlus_Click(object sender, EventArgs e)
{
if (Convert_To_Double(txtValue.Text) < 0)
{
txtValue.Text = (Convert_To_Double(txtValue.Text) * (-1)).ToString();
}
}
}
}
\ No newline at end of file
<?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=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>
\ No newline at end of file
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