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();
}
}
......@@ -34,6 +34,12 @@
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<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">
<HintPath>..\..\packages\Newtonsoft.Json.12.0.1\lib\net40\Newtonsoft.Json.dll</HintPath>
</Reference>
......@@ -41,7 +47,17 @@
<HintPath>..\..\packages\PropertyChanged2.Fody.2.5.13\lib\net40\PropertyChanged2.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<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.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
......@@ -61,6 +77,9 @@
<Compile Include="Common\NotifyBufferChangedEventArgs.cs" />
<Compile Include="Common\FlyData_WarningHistory.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\IPLCProxySystemService.cs" />
<Compile Include="IService\IPropertyOpt.cs" />
......@@ -103,6 +122,7 @@
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
......@@ -113,5 +133,7 @@
</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\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>
<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>
\ No newline at end of file
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="EntityFramework" version="6.2.0" targetFramework="net40" />
<package id="Fody" version="3.2.13" targetFramework="net40" developmentDependency="true" />
<package id="Newtonsoft.Json" version="12.0.1" 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>
\ No newline at end of file
......@@ -91,6 +91,8 @@ namespace FLY.Thick.Base.Server
}
}
public Range Border = new Range();
private int width;
/// <summary>
/// 当前膜宽,测量出来的,单位是 脉冲
......@@ -319,6 +321,9 @@ namespace FLY.Thick.Base.Server
N3 = 1000;
SensorWidth = 250;
Width = 0;
Border_Backw.Reset();
Border_Forw.Reset();
Border.Reset();
Mid = Valid.Mid;
TempRange = 500;
......@@ -357,12 +362,10 @@ namespace FLY.Thick.Base.Server
public void Init()
{
Border_Backw.Begin = Misc.MyBase.NULL_VALUE;
Border_Backw.End = Misc.MyBase.NULL_VALUE;
Border_Forw.Begin = Misc.MyBase.NULL_VALUE;
Border_Forw.End = Misc.MyBase.NULL_VALUE;
Border_Backw.Reset();
Border_Forw.Reset();
Width = 0;
Border.Reset();
Mid = Valid.Mid;
}
public Range GetScanRange()
......@@ -765,18 +768,25 @@ namespace FLY.Thick.Base.Server
if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin))
{
Width = ((border[0].Width) + (border[1].Width)) / 2 - SensorWidth + 1;
Mid = (border[0].Mid + border[1].Mid) / 2;
Border.Begin = (border[0].Begin + border[1].Begin) / 2 + SensorWidth / 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))
{
Width = (border[0].Width) - SensorWidth + 1;
Mid = border[0].Mid / 2;
Border.Copy(border[0]);
Width = Border.Width;
Mid = Border.Mid;
}
else if (Misc.MyBase.ISVALIDATA(border[1].Begin))
{
Width = (border[1].Width) - SensorWidth + 1;
Mid = border[1].Mid / 2;
Border.Copy(border[1]);
Width = Border.Width;
Mid = Border.Mid;
}
//膜宽
......
......@@ -128,18 +128,25 @@ namespace FLY.Thick.Base.Server
if (Misc.MyBase.ISVALIDATA(border[0].Begin) && Misc.MyBase.ISVALIDATA(border[1].Begin))
{
Width = ((border[0].Width) + (border[1].Width)) / 2 - SensorWidth + 1;
Mid = (border[0].Mid + border[1].Mid) / 2;
Border.Begin = (border[0].Begin + border[1].Begin) / 2 + SensorWidth / 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))
{
Width = (border[0].Width) - SensorWidth + 1;
Mid = border[0].Mid / 2;
Border.Copy(border[0]);
Width = Border.Width;
Mid = Border.Mid;
}
else if (Misc.MyBase.ISVALIDATA(border[1].Begin))
{
Width = (border[1].Width) - SensorWidth + 1;
Mid = border[1].Mid / 2;
Border.Copy(border[1]);
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