Commit 60903c07 authored by 潘栩锋's avatar 潘栩锋 🚴

1.修改了 边界查找

parent 0ca8cbdc
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
<providers>
<provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" />
<provider invariantName="System.Data.SQLite.EF6" type="System.Data.SQLite.EF6.SQLiteProviderServices, System.Data.SQLite.EF6" />
</providers>
</entityFramework>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite.EF6" />
<add name="SQLite Data Provider (Entity Framework 6)" invariant="System.Data.SQLite.EF6" description=".NET Framework Data Provider for SQLite (Entity Framework 6)" type="System.Data.SQLite.EF6.SQLiteProviderFactory, System.Data.SQLite.EF6" />
<remove invariant="System.Data.SQLite" /><add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".NET Framework Data Provider for SQLite" type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite" /></DbProviderFactories>
</system.data>
</configuration>
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
namespace FLY.OBJComponents.Common.SQLite
{
public class DBTable<T> : IDBTable
where T : new()
{
public List<SQLiteHelper.ArrayFieldTypeInfo> ArrayFieldTypeInfos = new List<SQLiteHelper.ArrayFieldTypeInfo>();
public string TableName { get; private set; }
public string DDL
{
get
{
return SQLiteHelper.GetCreateTableCommandText(typeof(T), ArrayFieldTypeInfos.ToArray());
}
}
SQLiteHelper sqliteHelper;
public DBTable()
{
TableName = SQLiteHelper.GetTableName(typeof(T));
}
public void Init(string connectionString)
{
sqliteHelper = new SQLiteHelper
{
ConnectionString = connectionString
};
}
public void Create()
{
sqliteHelper.ExecuteNonQuery(SQLiteHelper.GetCreateTableCommandText(typeof(T), ArrayFieldTypeInfos.ToArray()));
}
public void Add(T t)
{
sqliteHelper.ExecuteNonQuery(SQLiteHelper.GetInsertCommandText(t));
}
public void Update(T t, string condition)
{
sqliteHelper.ExecuteNonQuery(SQLiteHelper.GetUpdateCommandText(t, condition));
}
public bool AddRange(IEnumerable<T> array)
{
List<string> querys = new List<string>();
foreach (T t in array)
{
querys.Add(SQLiteHelper.GetInsertCommandText(t));
}
return sqliteHelper.QueryTran(querys);
}
public List<T> Find(string condition)
{
string sql = $"SELECT * FROM {TableName}";
if (!string.IsNullOrEmpty(condition))
sql += " " + condition;
DataTable dataTable = sqliteHelper.ExecuteReader(sql);
return SQLiteHelper.ToObjs<T>(dataTable, ArrayFieldTypeInfos.ToArray());
}
/// <summary>
/// 获取最后N行数据
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
public List<T> Last(int count)
{
return Find($"LIMIT (SELECT COUNT()-{count} FROM {TableName}),{count}");
}
/// <summary>
/// 获取前面N行数据
/// </summary>
/// <param name="count"></param>
/// <returns></returns>
public List<T> First(int count)
{
return Find($"LIMIT {count}");
}
public void Remove()
{
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace FLY.OBJComponents.Common.SQLite
{
public interface IDBTable
{
string TableName { get; }
string DDL { get; }
void Create();
}
}
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Data;
using System.Data.SQLite;
using System.Linq;
using System.Reflection;
using System.Text;
namespace FLY.OBJComponents.Common.SQLite
{
public class SQLiteHelper
{
#region 静态操作
public class SQLiteFieldTypeInfo
{
/// <summary>
/// sqlite field 类型
/// </summary>
public string FieldType { get; set; }
/// <summary>
/// C# 类型
/// </summary>
public Type PropertyType { get; set; }
/// <summary>
/// C# 类型转 sqlite 字符串
/// </summary>
public Func<object, string> PtoS { get; set; } = DefaultToS;
public Func<object, object> StoP { get; set; } = DefaultToP;
public static string DefaultToS(object obj)
{
return obj.ToString();
}
public static object DefaultToP(object obj)
{
return obj;
}
public SQLiteFieldTypeInfo(string fieldtype, Type propertytype)
{
FieldType = fieldtype;
PropertyType = propertytype;
}
public SQLiteFieldTypeInfo(string fieldtype, Type propertytype, Func<object, string> ptos, Func<object, object> stop)
{
FieldType = fieldtype;
PropertyType = propertytype;
PtoS = ptos;
StoP = stop;
}
}
public static List<SQLiteFieldTypeInfo> FieldTypeInfo { get; set; }
static SQLiteHelper()
{
FieldTypeInfo = new List<SQLiteFieldTypeInfo>
{
new SQLiteFieldTypeInfo("INTEGER",typeof(int),
SQLiteFieldTypeInfo.DefaultToS,
(obj)=>{
return Convert.ToInt32(obj);
}
),
new SQLiteFieldTypeInfo("INTEGER",typeof(Int64)),
new SQLiteFieldTypeInfo("BOOLEAN",typeof(bool)),
new SQLiteFieldTypeInfo("DOUBLE",typeof(double),
(obj)=>{
if(double.IsNaN((double)obj))
return "NULL";
else return obj.ToString();
},
(obj)=>{
if(obj == DBNull.Value)
return double.NaN;
else
return obj;
}
),
new SQLiteFieldTypeInfo("STRING",typeof(string),
(obj)=>"'" + obj + "'",
SQLiteFieldTypeInfo.DefaultToP
),
new SQLiteFieldTypeInfo("DATETIME",typeof(DateTime),
(obj)=>"'" + ((DateTime)obj).ToString("yyyy-MM-dd HH:mm:ss.fff") + "'",
SQLiteFieldTypeInfo.DefaultToP
)
};
}
public class ArrayFieldTypeInfo
{
/// <summary>
/// 属性名
/// </summary>
public string PropertyName { get; set; }
/// <summary>
/// 数组大小
/// </summary>
public int Length { get; set; }
public ArrayFieldTypeInfo(string propertyname, int length)
{
PropertyName = propertyname;
Length = length;
}
}
public static string GetTableName(Type type)
{
var attributes = type.GetCustomAttributes(typeof(TableAttribute), false);
if (attributes.Count() > 0)
{
return ((TableAttribute)attributes.First()).Name;
}
else
{
return type.Name;
}
}
public static string GetCreateTableCommandText(Type type, params ArrayFieldTypeInfo[] arrayFieldTypeInfos)
{
//CREATE TABLE table_name(
//column1 datatype PRIMARY KEY,
//column2 datatype,
// column3 datatype,
// .....
// columnN datatype,
//)
string tablename = GetTableName(type);
string fieldtext = "";
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
if (fieldtext != "")
{
fieldtext += ",";
}
if (propertyInfo.PropertyType.IsArray)//是数组,需要明确大小
{
int length = arrayFieldTypeInfos.First((a) => a.PropertyName == propertyInfo.Name).Length;
Type elementType = propertyInfo.PropertyType.GetElementType();
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == elementType);
for (int i = 0; i < length; i++)
{
if (i != 0)
fieldtext += ",";
fieldtext += string.Format("{0}{1} {2}",
propertyInfo.Name,
i,
fieldTypeInfo.FieldType);
}
}
else
{
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == propertyInfo.PropertyType);
fieldtext += string.Format("{0} {1}", propertyInfo.Name, fieldTypeInfo.FieldType);
//主键
if (propertyInfo.GetCustomAttributes(typeof(KeyAttribute), false).Count() > 0)
fieldtext += " PRIMARY KEY";
}
}
string commandText = string.Format("CREATE TABLE {0} ({1})", tablename, fieldtext);
return commandText;
}
public static string GetInsertCommandText(object cell)
{
//不用
//INSERT INTO TABLE_NAME[(column1, column2, column3,...columnN)]
//VALUES(value1, value2, value3,...valueN);
//使用
//INSERT INTO TABLE_NAME VALUES(value1, value2, value3,...valueN);
Type type = cell.GetType();
string tablename = GetTableName(type);
string fieldtext = "";
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
if (fieldtext != "")
{
fieldtext += ",";
}
if (propertyInfo.PropertyType.IsArray)//是数组,需要明确大小
{
Type elementType = propertyInfo.PropertyType.GetElementType();
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == elementType);
Array a = propertyInfo.GetValue(cell, null) as Array;
for (int i = 0; i < a.Length; i++)
{
if (i != 0)
fieldtext += ",";
fieldtext += fieldTypeInfo.PtoS(a.GetValue(i));
}
}
else
{
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == propertyInfo.PropertyType);
object o = propertyInfo.GetValue(cell, null);
fieldtext += fieldTypeInfo.PtoS(o);
}
}
string commandText = string.Format("INSERT INTO {0} VALUES({1})", tablename, fieldtext);
return commandText;
}
public static string GetUpdateCommandText(object cell, string condition)
{
//UPDATE table_name
//SET column1 = value1, column2 = value2...., columnN = valueN
//WHERE[condition];
Type type = cell.GetType();
string tablename = GetTableName(type);
string fieldtext = "";
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
if (fieldtext != "")
{
fieldtext += ",";
}
if (propertyInfo.PropertyType.IsArray)//是数组,需要明确大小
{
Type elementType = propertyInfo.PropertyType.GetElementType();
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == elementType);
Array a = propertyInfo.GetValue(cell, null) as Array;
for (int i = 0; i < a.Length; i++)
{
if (i != 0)
fieldtext += ",";
fieldtext += string.Format("{0}{1} = {2}", propertyInfo.PropertyType.Name, i, fieldTypeInfo.PtoS(a.GetValue(i)));
}
}
else
{
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == propertyInfo.PropertyType);
object o = propertyInfo.GetValue(cell, null);
fieldtext += string.Format("{0} = {1}", propertyInfo.PropertyType.Name, fieldTypeInfo.PtoS(o));
}
}
string commandText = string.Format("UPDATE {0} SET {1} {2}", tablename, fieldtext, condition);
return commandText;
}
public static List<T> ToObjs<T>(DataTable dataTable, params ArrayFieldTypeInfo[] arrayFieldTypeInfos)
where T : new()
{
Type type = typeof(T);
List<T> list = new List<T>();
foreach (DataRow dataRow in dataTable.Rows)
{
list.Add(ToObj<T>(dataRow, arrayFieldTypeInfos));
}
return list;
}
public static T ToObj<T>(DataRow dataRow, params ArrayFieldTypeInfo[] arrayFieldTypeInfos)
where T : new()
{
Type type = typeof(T);
T t = new T();
PropertyInfo[] propertyInfos = type.GetProperties();
foreach (var propertyInfo in propertyInfos)
{
Type ptype = propertyInfo.PropertyType;
if (ptype.IsArray)//是数组,需要明确大小
{
Type elementType = propertyInfo.PropertyType.GetElementType();
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == elementType);
int length = arrayFieldTypeInfos.First((a) => a.PropertyName == propertyInfo.Name).Length;
Array array = (Array)ptype.Assembly.CreateInstance(ptype.FullName, false, BindingFlags.CreateInstance, null, new object[] { length }, null, null);
for (int i = 0; i < length; i++)
{
object o = fieldTypeInfo.StoP(dataRow[propertyInfo.Name + i]);
array.SetValue(o, i);
}
propertyInfo.SetValue(t, array, null);
}
else
{
SQLiteFieldTypeInfo fieldTypeInfo = FieldTypeInfo.Find((fti) => fti.PropertyType == ptype);
object o = fieldTypeInfo.StoP(dataRow[propertyInfo.Name]);
propertyInfo.SetValue(t, o, null);
}
}
return t;
}
#endregion
public string ConnectionString;
/// <summary>
/// 查询数据库中的所有数据类型信息。
/// </summary>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public DataTable ExecuteReader(string sql)
{
DataTable data;
using (SQLiteConnection conn = new SQLiteConnection(ConnectionString))
{
conn.Open();
SQLiteCommand command = conn.CreateCommand();
command.CommandText = sql;
// 开始读取
SQLiteDataAdapter adapter = new SQLiteDataAdapter(command);
data = new DataTable();
adapter.Fill(data);
conn.Close();
}
return data;
}
/// <summary>
/// 对SQLite数据库执行增删改操作,返回受影响的行数。
/// </summary>
/// <param name="sql">要执行的增删改的SQL语句。</param>
/// <param name="parameters">执行增删改语句所需要的参数,参数必须以它们在SQL语句中的顺序为准。</param>
/// <returns></returns>
/// <exception cref="Exception"></exception>
public void ExecuteNonQuery(string sql)
{
using (SQLiteConnection connection = new SQLiteConnection(ConnectionString))
{
using (SQLiteCommand command = new SQLiteCommand(connection))
{
connection.Open();
command.CommandText = sql;
command.ExecuteNonQuery();
}
}
}
/// <summary>
/// 多行执行
/// </summary>
/// <param name="queryList"></param>
/// <returns></returns>
public bool QueryTran(IEnumerable<string> queryList)
{
using (SQLiteConnection conn = new SQLiteConnection(ConnectionString))
{
using (SQLiteCommand cmd = new SQLiteCommand(conn))
{
conn.Open();
SQLiteTransaction tran = conn.BeginTransaction();
bool check = false;
try
{
foreach (string item in queryList)
{
cmd.CommandText = item;
cmd.ExecuteNonQuery();
}
tran.Commit();
check = true;
}
catch (Exception ex)
{
tran.Rollback();
check = false;
throw ex;
}
finally
{
conn.Close();
}
return check;
}
}
}
}
}
...@@ -34,6 +34,12 @@ ...@@ -34,6 +34,12 @@
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\EntityFramework.6.2.0\lib\net40\EntityFramework.dll</HintPath>
</Reference>
<Reference Include="EntityFramework.SqlServer, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\EntityFramework.6.2.0\lib\net40\EntityFramework.SqlServer.dll</HintPath>
</Reference>
<Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> <Reference Include="Newtonsoft.Json, Version=12.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL">
<HintPath>..\..\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll</HintPath> <HintPath>..\..\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference> </Reference>
...@@ -41,7 +47,17 @@ ...@@ -41,7 +47,17 @@
<HintPath>..\..\packages\PropertyChanged2.Fody.2.5.13\lib\net40\PropertyChanged2.dll</HintPath> <HintPath>..\..\packages\PropertyChanged2.Fody.2.5.13\lib\net40\PropertyChanged2.dll</HintPath>
</Reference> </Reference>
<Reference Include="System" /> <Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Core" /> <Reference Include="System.Core" />
<Reference Include="System.Data.SQLite, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\lib\net40\System.Data.SQLite.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.EF6, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.EF6.1.0.109.0\lib\net40\System.Data.SQLite.EF6.dll</HintPath>
</Reference>
<Reference Include="System.Data.SQLite.Linq, Version=1.0.109.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139, processorArchitecture=MSIL">
<HintPath>..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Linq.1.0.109.0\lib\net40\System.Data.SQLite.Linq.dll</HintPath>
</Reference>
<Reference Include="System.Xml.Linq" /> <Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" /> <Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" /> <Reference Include="Microsoft.CSharp" />
...@@ -61,6 +77,9 @@ ...@@ -61,6 +77,9 @@
<Compile Include="Common\NotifyBufferChangedEventArgs.cs" /> <Compile Include="Common\NotifyBufferChangedEventArgs.cs" />
<Compile Include="Common\FlyData_WarningHistory.cs" /> <Compile Include="Common\FlyData_WarningHistory.cs" />
<Compile Include="Common\PropertiesManager.cs" /> <Compile Include="Common\PropertiesManager.cs" />
<Compile Include="Common\SQLite\DBTable.cs" />
<Compile Include="Common\SQLite\IDBTable.cs" />
<Compile Include="Common\SQLite\SQLiteHelper.cs" />
<Compile Include="IService\IBuffer.cs" /> <Compile Include="IService\IBuffer.cs" />
<Compile Include="IService\IPLCProxySystemService.cs" /> <Compile Include="IService\IPLCProxySystemService.cs" />
<Compile Include="IService\IPropertyOpt.cs" /> <Compile Include="IService\IPropertyOpt.cs" />
...@@ -103,6 +122,7 @@ ...@@ -103,6 +122,7 @@
</ProjectReference> </ProjectReference>
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="App.config" />
<None Include="packages.config" /> <None Include="packages.config" />
</ItemGroup> </ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
...@@ -113,5 +133,7 @@ ...@@ -113,5 +133,7 @@
</PropertyGroup> </PropertyGroup>
<Error Condition="!Exists('..\..\packages\Fody.3.2.13\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Fody.3.2.13\build\Fody.targets'))" /> <Error Condition="!Exists('..\..\packages\Fody.3.2.13\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\Fody.3.2.13\build\Fody.targets'))" />
<Error Condition="!Exists('..\..\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props'))" /> <Error Condition="!Exists('..\..\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\..\packages\PropertyChanged2.Fody.2.5.13\build\PropertyChanged2.Fody.props'))" />
<Error Condition="!Exists('..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net40\System.Data.SQLite.Core.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net40\System.Data.SQLite.Core.targets'))" />
</Target> </Target>
<Import Project="..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net40\System.Data.SQLite.Core.targets" Condition="Exists('..\..\..\Project.FLY.Thick.Normal\packages\System.Data.SQLite.Core.1.0.109.2\build\net40\System.Data.SQLite.Core.targets')" />
</Project> </Project>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<packages> <packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net40" />
<package id="Fody" version="3.2.13" targetFramework="net40" developmentDependency="true" /> <package id="Fody" version="3.2.13" targetFramework="net40" developmentDependency="true" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="net40" /> <package id="Newtonsoft.Json" version="12.0.1" targetFramework="net40" />
<package id="PropertyChanged2.Fody" version="2.5.13" targetFramework="net40" /> <package id="PropertyChanged2.Fody" version="2.5.13" targetFramework="net40" />
<package id="System.Data.SQLite" version="1.0.109.2" targetFramework="net40" />
<package id="System.Data.SQLite.Core" version="1.0.109.2" targetFramework="net40" />
<package id="System.Data.SQLite.EF6" version="1.0.109.0" targetFramework="net40" />
<package id="System.Data.SQLite.Linq" version="1.0.109.0" targetFramework="net40" />
</packages> </packages>
\ No newline at end of file
...@@ -91,6 +91,8 @@ namespace FLY.Thick.Base.Server ...@@ -91,6 +91,8 @@ namespace FLY.Thick.Base.Server
} }
} }
public Range Border = new Range();
private int width; private int width;
/// <summary> /// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲 /// 当前膜宽,测量出来的,单位是 脉冲
...@@ -319,6 +321,9 @@ namespace FLY.Thick.Base.Server ...@@ -319,6 +321,9 @@ namespace FLY.Thick.Base.Server
N3 = 1000; N3 = 1000;
SensorWidth = 250; SensorWidth = 250;
Width = 0; Width = 0;
Border_Backw.Reset();
Border_Forw.Reset();
Border.Reset();
Mid = Valid.Mid; Mid = Valid.Mid;
TempRange = 500; TempRange = 500;
...@@ -357,12 +362,10 @@ namespace FLY.Thick.Base.Server ...@@ -357,12 +362,10 @@ namespace FLY.Thick.Base.Server
public void Init() public void Init()
{ {
Border_Backw.Begin = Misc.MyBase.NULL_VALUE; Border_Backw.Reset();
Border_Backw.End = Misc.MyBase.NULL_VALUE; Border_Forw.Reset();
Border_Forw.Begin = Misc.MyBase.NULL_VALUE;
Border_Forw.End = Misc.MyBase.NULL_VALUE;
Width = 0; Width = 0;
Border.Reset();
Mid = Valid.Mid; Mid = Valid.Mid;
} }
public Range GetScanRange() public Range GetScanRange()
...@@ -765,18 +768,25 @@ namespace FLY.Thick.Base.Server ...@@ -765,18 +768,25 @@ namespace FLY.Thick.Base.Server
if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin)) if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin))
{ {
Width = ((border[0].Width) + (border[1].Width)) / 2 - SensorWidth + 1; Border.Begin = (border[0].Begin + border[1].Begin) / 2 + SensorWidth / 2;
Mid = (border[0].Mid + border[1].Mid) / 2; Border.End = (border[0].End + border[1].End) / 2 - SensorWidth / 2;
Width = Border.Width;
Mid = Border.Mid;
} }
else if (Misc.MyBase.ISVALIDATA(border[0].Begin)) else if (Misc.MyBase.ISVALIDATA(border[0].Begin))
{ {
Width = (border[0].Width) - SensorWidth + 1; Border.Copy(border[0]);
Mid = border[0].Mid / 2;
Width = Border.Width;
Mid = Border.Mid;
} }
else if (Misc.MyBase.ISVALIDATA(border[1].Begin)) else if (Misc.MyBase.ISVALIDATA(border[1].Begin))
{ {
Width = (border[1].Width) - SensorWidth + 1; Border.Copy(border[1]);
Mid = border[1].Mid / 2;
Width = Border.Width;
Mid = Border.Mid;
} }
//膜宽 //膜宽
......
...@@ -128,18 +128,25 @@ namespace FLY.Thick.Base.Server ...@@ -128,18 +128,25 @@ namespace FLY.Thick.Base.Server
if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin)) if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin))
{ {
Width = ((border[0].Width) + (border[1].Width)) / 2 - SensorWidth + 1; Border.Begin = (border[0].Begin + border[1].Begin) / 2 + SensorWidth / 2;
Mid = (border[0].Mid + border[1].Mid) / 2; Border.End = (border[0].End + border[1].End) / 2 - SensorWidth / 2;
Width = Border.Width;
Mid = Border.Mid;
} }
else if (Misc.MyBase.ISVALIDATA(border[0].Begin)) else if (Misc.MyBase.ISVALIDATA(border[0].Begin))
{ {
Width = (border[0].Width) - SensorWidth + 1; Border.Copy(border[0]);
Mid = border[0].Mid / 2;
Width = Border.Width;
Mid = Border.Mid;
} }
else if (Misc.MyBase.ISVALIDATA(border[1].Begin)) else if (Misc.MyBase.ISVALIDATA(border[1].Begin))
{ {
Width = (border[1].Width) - SensorWidth + 1; Border.Copy(border[1]);
Mid = border[1].Mid / 2;
Width = Border.Width;
Mid = Border.Mid;
} }
//膜宽 //膜宽
......
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