添加项目文件。

This commit is contained in:
Admin 2025-12-10 17:55:48 +08:00
parent e2c748ef4f
commit 9798c01b1f
245 changed files with 78841 additions and 0 deletions

2273
Community/ADTMC.cs Normal file

File diff suppressed because it is too large Load Diff

176
Community/AccHelpers.cs Normal file
View File

@ -0,0 +1,176 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Data;
using System.Data.OleDb;
using System.Windows;
namespace Community
{
public class AccHelpers
{
/// <summary>
/// Appconfig中用于连接数据库的字符串
/// </summary>
public static string connStr = ConfigurationManager.ConnectionStrings["dbConnstr"].ConnectionString;
/// <summary>
/// 数据库执行操作的方法,只返回受影响的行数
/// </summary>
/// <param name="sql"></param>
/// <param name="parameter"></param>
/// <returns></returns>
public static int ExecuteNonQuery(string sql, params OleDbParameter[] parameter)
{
//using (OleDbConnection conn = new OleDbConnection(connStr))
//{
// conn.Open();
// using (OleDbCommand cmd = new OleDbCommand(sql, conn))
// {
// cmd.Parameters.AddRange(parameter);
// return cmd.ExecuteNonQuery();
// }
//}
//速度更快
ConnectOpen();
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
return cmd.ExecuteNonQuery();
}
}
public static int ExecuteNonQuery(CommandType type, string sql, params OleDbParameter[] parameter)
{
using (OleDbConnection conn = new OleDbConnection(connStr))
{
conn.Open();
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
cmd.CommandType = type;
return cmd.ExecuteNonQuery();
}
}
}
/// <summary>
/// 查询获取单个结果集的方法
/// </summary>
/// <param name="sql"></param>
/// <param name="parameter"></param>
/// <returns></returns>
public static object ExecuteScalar(string sql, params OleDbParameter[] parameter)
{
//速度更快
ConnectOpen();
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
return cmd.ExecuteScalar();
}
}
public static object ExecuteScalar(CommandType type, string sql, params OleDbParameter[] parameter)
{
//速度更快
ConnectOpen();
conn.Open();
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
cmd.CommandType = type;
return cmd.ExecuteScalar();
}
}
/// <summary>
/// 查询获取结果集的方法
/// </summary>
/// <param name="sql"></param>
/// <param name="paramaeter"></param>
/// <returns></returns>
public static DataTable ExecuteDataTable(string sql, params OleDbParameter[] paramaeter)
{
//using (OleDbConnection conn = new OleDbConnection(connStr))
//{
// conn.Open();
// using (OleDbCommand cmd = new OleDbCommand(sql, conn))
// {
// cmd.Parameters.AddRange(paramaeter);
// OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
// DataSet dataset = new DataSet();
// adapter.Fill(dataset);
// return dataset.Tables[0];
// }
//}
//速度更快
ConnectOpen();
using (OleDbCommand cmd = new OleDbCommand(sql, conn))
{
cmd.Parameters.AddRange(paramaeter);
OleDbDataAdapter adapter = new OleDbDataAdapter(cmd);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
return dataset.Tables[0];
}
}
static OleDbConnection conn;
/// <summary>
/// 数据库连接
/// </summary>
public static bool ConnectOpen()
{
try
{
if (conn == null)
{
conn = new OleDbConnection(connStr);
conn.Open();
return true;
}
if (conn.State == ConnectionState.Open)
{
return true;
}
else
{
conn = new OleDbConnection(connStr);
conn.Open();
return true;
}
}
catch (Exception)
{
// MessageBox.Show("本地数据库连接失败");
return false;
}
}
}
}

View File

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{40BD9B86-2281-4E16-BFAB-558CB18E873C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>Community</RootNamespace>
<AssemblyName>Community</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>AnyCPU</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="ControlzEx, Version=4.0.0.0, Culture=neutral, PublicKeyToken=69f1c32f803d307e, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.4.3.2\lib\net45\ControlzEx.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=2.0.0.0, Culture=neutral, PublicKeyToken=51482d6f650b2b3f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.2.2.0\lib\net452\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="AccHelpers.cs" />
<Compile Include="adt8949.cs" />
<Compile Include="adtIO3224.cs" />
<Compile Include="ADTMC.cs" />
<Compile Include="DelegateCommand.cs" />
<Compile Include="IOC0640.cs" />
<Compile Include="LTDMC.cs" />
<Compile Include="LTSMC.cs" />
<Compile Include="MyMessageBox.cs" />
<Compile Include="NotificationObject.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="SerialCom.cs" />
<Compile Include="ShareHelp.cs" />
<Compile Include="SqlHelpers.cs" />
<Compile Include="Zmcaux.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

View File

@ -0,0 +1,37 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Input;
namespace Community
{
public class DelegateCommand : ICommand
{
public event EventHandler CanExecuteChanged;
public bool CanExecute(object parameter)
{
if (this.CanExecuteFunc == null)
{
return true;
}
return this.CanExecuteFunc(parameter);
}
public void Execute(object parameter)
{
if (this.ExecuteAction == null)
{
return;
}
this.ExecuteAction(parameter);
}
public Action<object> ExecuteAction { get; set; }
public Func<object, bool> CanExecuteFunc { get; set; }
}
}

61
Community/IOC0640.cs Normal file
View File

@ -0,0 +1,61 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Community
{
/// <summary>
/// 雷赛IO640卡
/// </summary>
public class IOC0640
{
[DllImport("IOC0640.dll", EntryPoint = "ioc_board_init", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_board_init();
[DllImport("IOC0640.dll", EntryPoint = "ioc_board_close", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern void ioc_board_close();
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_inbit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_read_inbit(ushort cardno, ushort bitno);
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_outbit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_read_outbit(ushort cardno, ushort bitno);
[DllImport("IOC0640.dll", EntryPoint = "ioc_write_outbit", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_write_outbit(ushort cardno, ushort bitno, int on_off);
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_inport", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_read_inport(ushort cardno, ushort m_PortNo);
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_outport", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_read_outport(ushort cardno, ushort m_PortNo);
[DllImport("IOC0640.dll", EntryPoint = "ioc_write_outport", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_write_outport(ushort cardno, ushort m_PortNo, uint port_value);
public delegate uint IOC0640_OPERATE(IntPtr operate_data);
[DllImport("IOC0640.dll", EntryPoint = "ioc_int_enable", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_int_enable(ushort cardno, IOC0640_OPERATE funcIntHandler, IntPtr operate_data);
[DllImport("IOC0640.dll", EntryPoint = "ioc_int_disable", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_int_disable(ushort cardno);
[DllImport("IOC0640.dll", EntryPoint = "ioc_config_intbitmode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_config_intbitmode(ushort cardno, ushort bitno, ushort enable, ushort logic);
[DllImport("IOC0640.dll", EntryPoint = "ioc_config_intbitmode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_config_intbitmode(ushort cardno, ushort bitno, ushort[] enable, ushort[] logic);
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_intbitstatus", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_read_intbitstatus(ushort cardno, ushort bitno);
[DllImport("IOC0640.dll", EntryPoint = "ioc_config_intporten", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_config_intporten(ushort cardno, ushort m_PortNo, uint port_en);
[DllImport("IOC0640.dll", EntryPoint = "ioc_config_intportlogic", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_config_intportlogic(ushort cardno, ushort m_PortNo, uint port_logic);
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_intportmode", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_read_intportmode(ushort cardno, ushort m_PortNo, uint[] enable, uint[] logic);
[DllImport("IOC0640.dll", EntryPoint = "ioc_read_intportstatus", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern int ioc_read_intportstatus(ushort cardno, ushort m_PortNo);
[DllImport("IOC0640.dll", EntryPoint = "ioc_set_filter", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
public static extern uint ioc_set_filter(ushort cardno, double filter);
}
}

4075
Community/LTDMC.cs Normal file

File diff suppressed because it is too large Load Diff

945
Community/LTSMC.cs Normal file
View File

@ -0,0 +1,945 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Runtime.InteropServices;
namespace Community
{
public partial class LTSMC
{
/*********************************************************************************************************
功能函数
***********************************************************************************************************/
//板卡配置
[DllImport("LTSMC.dll")]
public static extern short smc_board_init(ushort ConnectNo, ushort ConnectType, string pconnectstring, uint baud);
[DllImport("LTSMC.dll")]
public static extern short smc_board_init_ex(ushort ConnectNo, ushort type, string pconnectstring, uint dwBaudRate, uint dwByteSize, uint dwParity, uint dwStopBits);
[DllImport("LTSMC.dll")]
public static extern short smc_board_close(ushort ConnectNo);
[DllImport("LTSMC.dll")]
public static extern short smc_get_CardInfList(ref ushort CardNum, uint[] CardTypeList, ushort[] ConnectTypeList);
[DllImport("LTSMC.dll")]
public static extern short smc_get_card_version(ushort ConnectNo, ref uint CardVersion);
[DllImport("LTSMC.dll")]
public static extern short smc_get_card_soft_version(ushort ConnectNo, ref uint FirmID, ref uint SubFirmID);
[DllImport("LTSMC.dll")]
public static extern short smc_get_release_version(ushort ConnectNo, byte[] ReleaseVersion);
[DllImport("LTSMC.dll")]
public static extern short smc_get_card_lib_version(ref uint LibVer);
[DllImport("LTSMC.dll")]
public static extern short smc_get_total_axes(ushort ConnectNo, ref uint TotalAxis); //读取指定卡轴数
[DllImport("LTSMC.dll")]
public static extern short smc_get_total_ionum(ushort ConnectNo, ref ushort TotalIn, ref ushort TotalOut);
[DllImport("LTSMC.dll")]
public static extern short smc_get_total_adcnum(ushort ConnectNo, ref ushort TotalIn, ref ushort TotalOut);
[DllImport("LTSMC.dll")]
public static extern short smc_get_total_liners(ushort ConnectNo, ref uint TotalLiner);
[DllImport("LTSMC.dll")]
public static extern short smc_set_debug_mode(ushort mode, char[] FileName);
[DllImport("LTSMC.dll")]
public static extern short smc_get_debug_mode(ref ushort mode, char[] FileName);
[DllImport("LTSMC.dll")]
public static extern short smc_format_flash(ushort ConnectNo);
[DllImport("LTSMC.dll")]
public static extern short smc_set_ipaddr(ushort ConnectNo, byte[] IpAddr);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ipaddr(ushort ConnectNo, byte[] IpAddr);
[DllImport("LTSMC.dll")]
public static extern short smc_set_com(ushort ConnectNo, ushort com, uint dwBaudRate, ushort wByteSize, ushort wParity, ushort wStopBits);
[DllImport("LTSMC.dll")]
public static extern short smc_get_com(ushort ConnectNo, ushort com, ref uint dwBaudRate, ref ushort wByteSize, ref ushort wParity, ref ushort dwStopBits);
//序列号
[DllImport("LTSMC.dll")]
public static extern short smc_write_sn(ushort ConnectNo, UInt64 sn);
[DllImport("LTSMC.dll")]
public static extern short smc_read_sn(ushort ConnectNo, ref UInt64 sn);
//加密
[DllImport("LTSMC.dll")]
public static extern short smc_write_password(ushort ConnectNo, string str_pass);
[DllImport("LTSMC.dll")]
public static extern short smc_check_password(ushort ConnectNo, string str_pass);
//脉冲模式
[DllImport("LTSMC.dll")]
public static extern short smc_set_pulse_outmode(ushort ConnectNo, ushort axis, ushort outmode); //设定脉冲输出模式
[DllImport("LTSMC.dll")]
public static extern short smc_get_pulse_outmode(ushort ConnectNo, ushort axis, ref ushort outmode); //读取脉冲输出模式
//脉冲当量
[DllImport("LTSMC.dll")]
public static extern short smc_set_equiv(ushort ConnectNo, ushort axis, double equiv);
[DllImport("LTSMC.dll")]
public static extern short smc_get_equiv(ushort ConnectNo, ushort axis, ref double equiv);
//反向间隙
[DllImport("LTSMC.dll")]
public static extern short smc_set_backlash_unit(ushort ConnectNo, ushort axis, double backlash);
[DllImport("LTSMC.dll")]
public static extern short smc_get_backlash_unit(ushort ConnectNo, ushort axis, ref double backlash);
//编码器
[DllImport("LTSMC.dll")]
public static extern short smc_set_counter_inmode(ushort ConnectNo, ushort axis, ushort mode); //设定编码器的计数方式
[DllImport("LTSMC.dll")]
public static extern short smc_get_counter_inmode(ushort ConnectNo, ushort axis, ref ushort mode); //读取编码器的计数方式
[DllImport("LTSMC.dll")]
public static extern int smc_get_encoder(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_set_encoder(ushort ConnectNo, ushort axis, int encoder_value);
[DllImport("LTSMC.dll")]
public static extern short smc_set_ez_mode(ushort ConnectNo, ushort axis, ushort ez_logic, ushort ez_mode, double filter); //设置EZ信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_ez_mode(ushort ConnectNo, ushort axis, ref ushort ez_logic, ref ushort ez_mode, ref double filter); //读取设置EZ信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_counter_reverse(ushort ConnectNo, ushort axis, ushort reverse);
[DllImport("LTSMC.dll")]
public static extern short smc_get_counter_reverse(ushort ConnectNo, ushort axis, ref ushort reverse);
//辅助编码器
[DllImport("LTSMC.dll")]
public static extern short smc_set_extra_encoder(ushort ConnectNo, ushort axis, int pos);
[DllImport("LTSMC.dll")]
public static extern short smc_get_extra_encoder(ushort ConnectNo, ushort axis, ref int pos);
//单轴速度参数
[DllImport("LTSMC.dll")]
public static extern short smc_set_profile_unit(ushort ConnectNo, ushort axis, double Min_Vel, double Max_Vel, double Tacc, double Tdec, double Stop_Vel);
[DllImport("LTSMC.dll")]
public static extern short smc_get_profile_unit(ushort ConnectNo, ushort axis, ref double Min_Vel, ref double Max_Vel, ref double Tacc, ref double Tdec, ref double Stop_Vel);
[DllImport("LTSMC.dll")]
public static extern short smc_set_s_profile(ushort ConnectNo, ushort axis, ushort s_mode, double s_para); //设置平滑速度曲线参数
[DllImport("LTSMC.dll")]
public static extern short smc_get_s_profile(ushort ConnectNo, ushort axis, ushort s_mode, ref double s_para); //读取平滑速度曲线参数 兼容DMC5800 s_mode改用指针返回参数值
//单轴运动
[DllImport("LTSMC.dll")]
public static extern short smc_pmove_unit(ushort ConnectNo, ushort axis, double Dist, ushort posi_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_vmove(ushort ConnectNo, ushort axis, ushort dir); //指定轴做连续运动
[DllImport("LTSMC.dll")]
public static extern short smc_change_speed(ushort ConnectNo, ushort axis, double Curr_Vel, double Taccdec); //在线改变指定轴的当前运动速度
//回零运动
[DllImport("LTSMC.dll")]
public static extern short smc_set_home_pin_logic(ushort ConnectNo, ushort axis, ushort org_logic, double filter); //设置HOME信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_home_pin_logic(ushort ConnectNo, ushort axis, ref ushort org_logic, ref double filter); //读取设置HOME信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_home_profile_unit(ushort ConnectNo, ushort axis, double Low_Vel, double High_Vel, double Tacc, double Tdec);
[DllImport("LTSMC.dll")]
public static extern short smc_get_home_profile_unit(ushort ConnectNo, ushort axis, ref double Low_Vel, ref double High_Vel, ref double Tacc, ref double Tdec);
[DllImport("LTSMC.dll")]
public static extern short smc_set_ez_count(ushort ConnectNo, ushort axis, ushort ez_count);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ez_count(ushort ConnectNo, ushort axis, ref ushort ez_count);
[DllImport("LTSMC.dll")]
public static extern short smc_set_homemode(ushort ConnectNo, ushort axis, ushort home_dir, double vel_mode, ushort mode, ushort pos_source);//设定指定轴的回原点模式
[DllImport("LTSMC.dll")]
public static extern short smc_get_homemode(ushort ConnectNo, ushort axis, ref ushort home_dir, ref double vel_mode, ref ushort home_mode, ref ushort pos_source);//读取指定轴的回原点模式
[DllImport("LTSMC.dll")]
public static extern short smc_home_move(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_get_home_result(ushort ConnectNo, ushort axis, ref ushort state);
[DllImport("LTSMC.dll")]
public static extern short smc_set_home_position_unit(ushort ConnectNo, ushort axis, ushort enable, double position);
[DllImport("LTSMC.dll")]
public static extern short smc_get_home_position_unit(ushort ConnectNo, ushort axis, ref ushort enable, ref double position);
//手轮运动(旧)
[DllImport("LTSMC.dll")]
public static extern short smc_set_handwheel_channel(ushort CardNo, ushort index);
[DllImport("LTSMC.dll")]
public static extern short smc_get_handwheel_channel(ushort CardNo, ref ushort index);
[DllImport("LTSMC.dll")]
public static extern short smc_set_handwheel_inmode(ushort CardNo, ushort axis, ushort inmode, int multi, double vh);
[DllImport("LTSMC.dll")]
public static extern short smc_get_handwheel_inmode(ushort CardNo, ushort axis, ref ushort inmode, ref int multi, ref double vh);
[DllImport("LTSMC.dll")]
public static extern short smc_set_handwheel_inmode_extern(ushort CardNo, ushort inmode, ushort AxisNum, ushort[] AxisList, int[] multi);
[DllImport("LTSMC.dll")]
public static extern short smc_get_handwheel_inmode_extern(ushort CardNo, ref ushort inmode, ref ushort AxisNum, ushort[] AxisList, int[] multi);
//[DllImport("LTSMC.dll")]
//public static extern short smc_handwheel_move(ushort CardNo, ushort axis);
//手轮运动
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_set_axislist(ushort ConnectNo, ushort AxisSelIndex, ushort AxisNum, ushort[] AxisList);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_get_axislist(ushort ConnectNo, ushort AxisSelIndex, ref ushort AxisNum, ushort[] AxisList);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_set_ratiolist(ushort ConnectNo, ushort AxisSelIndex, ushort StartRatioIndex, ushort RatioSelNum, double[] RatioList);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_get_ratiolist(ushort ConnectNo, ushort AxisSelIndex, ushort StartRatioIndex, ushort RatioSelNum, double[] RatioList);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_set_mode(ushort ConnectNo, ushort InMode, ushort IfHardEnable);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_get_mode(ushort ConnectNo, ref ushort InMode, ref ushort IfHardEnable);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_set_index(ushort ConnectNo, ushort AxisSelIndex, ushort RatioSelIndex);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_get_index(ushort ConnectNo, ref ushort AxisSelIndex, ref ushort RatioSelIndex);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_move(ushort ConnectNo, ushort ForceMove);
[DllImport("LTSMC.dll")]
public static extern short smc_handwheel_stop(ushort ConnectNo);
//原点锁存
[DllImport("LTSMC.dll")]
public static extern short smc_set_homelatch_mode(ushort ConnectNo, ushort axis, ushort enable, ushort logic, ushort source);
[DllImport("LTSMC.dll")]
public static extern short smc_get_homelatch_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort logic, ref ushort source);
[DllImport("LTSMC.dll")]
public static extern int smc_get_homelatch_flag(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_reset_homelatch_flag(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_get_homelatch_value_unit(ushort ConnectNo, ushort axis, ref double value);
//EZ锁存
[DllImport("LTSMC.dll")]
public static extern short smc_set_ezlatch_mode(ushort ConnectNo, ushort axis, ushort enable, ushort logic, ushort source);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ezlatch_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort logic, ref ushort source);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ezlatch_flag(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_reset_ezlatch_flag(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ezlatch_value_unit(ushort ConnectNo, ushort axis, ref double pos_by_mm);
//高速锁存(旧)
[DllImport("LTSMC.dll")]
public static extern short smc_set_ltc_mode(ushort ConnectNo, ushort axis, ushort ltc_logic, ushort ltc_mode, double filter); //设置LTC信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_ltc_mode(ushort ConnectNo, ushort axis, ref ushort ltc_logic, ref ushort ltc_mode, ref double filter); //读取设置LTC信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_latch_mode(ushort ConnectNo, ushort axis, ushort latchmode, ushort latch_source, ushort latch_channel); //设置锁存方式
[DllImport("LTSMC.dll")]
public static extern short smc_get_latch_mode(ushort ConnectNo, ushort axis, ref ushort latchmode, ref ushort latch_source, ref ushort latch_channel);
[DllImport("LTSMC.dll")]
public static extern short smc_SetLtcOutMode(ushort ConnectNo, ushort axis, ushort enable, ushort bitno);//反相输出
[DllImport("LTSMC.dll")]
public static extern short smc_GetLtcOutMode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort bitno);
[DllImport("LTSMC.dll")]
public static extern short smc_get_latch_flag(ushort ConnectNo, ushort axis); //读取锁存器标志
[DllImport("LTSMC.dll")]
public static extern short smc_reset_latch_flag(ushort ConnectNo, ushort axis); //复位锁存器标志
[DllImport("LTSMC.dll")]
public static extern short smc_get_latch_value_unit(ushort ConnectNo, ushort axis, ref double value); //读取编码器锁存器的值
[DllImport("LTSMC.dll")]
public static extern short smc_get_latch_flag_extern(ushort ConnectNo, ushort axis); //读取锁存器标志
[DllImport("LTSMC.dll")]
public static extern int smc_get_latch_value_extern(ushort ConnectNo, ushort axis, ushort index); //按索引取值
[DllImport("LTSMC.dll")]
public static extern short smc_set_latch_stop_time(ushort ConnectNo, ushort axis, int time); //触发急停时间
[DllImport("LTSMC.dll")]
public static extern short smc_get_latch_stop_time(ushort ConnectNo, ushort axis, ref int time);
//高速锁存(新)
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_set_mode(ushort ConnectNo, ushort latch, ushort ltc_mode, ushort ltc_logic, double filter);
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_get_mode(ushort ConnectNo, ushort latch, ref ushort ltc_mode, ref ushort ltc_logic, ref double filter);
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_set_source(ushort ConnectNo, ushort latch, ushort axis, ushort ltc_source);
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_get_source(ushort ConnectNo, ushort latch, ushort axis, ref ushort ltc_source);
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_reset(ushort ConnectNo, ushort latch);
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_get_number(ushort ConnectNo, ushort latch, ushort axis, ref int number);
[DllImport("LTSMC.dll")]
public static extern short smc_ltc_get_value_unit(ushort ConnectNo, ushort latch, ushort axis, ref double value);
//软锁存
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_set_mode(ushort ConnectNo, ushort latch, ushort ltc_enable, ushort ltc_mode, ushort ltc_inbit, ushort ltc_logic, double filter);
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_get_mode(ushort ConnectNo, ushort latch, ref ushort ltc_enable, ref ushort ltc_mode, ref ushort ltc_inbit, ref ushort ltc_logic, ref double filter);
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_set_source(ushort ConnectNo, ushort latch, ushort axis, ushort ltc_source);
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_get_source(ushort ConnectNo, ushort latch, ushort axis, ref ushort ltc_source);
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_reset(ushort ConnectNo, ushort latch);
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_get_number(ushort ConnectNo, ushort latch, ushort axis, ref int number);
[DllImport("LTSMC.dll")]
public static extern short smc_softltc_get_value_unit(ushort ConnectNo, ushort latch, ushort axis, ref double value);
//PVT运动
[DllImport("LTSMC.dll")]
public static extern short smc_pvt_table_unit(ushort ConnectNo, ushort iaxis, uint count, double[] pTime, double[] pPos, double[] pVel);
[DllImport("LTSMC.dll")]
public static extern short smc_pts_table_unit(ushort ConnectNo, ushort iaxis, uint count, double[] pTime, double[] pPos, double[] pPercent);
[DllImport("LTSMC.dll")]
public static extern short smc_pvts_table_unit(ushort ConnectNo, ushort iaxis, uint count, double[] pTime, double[] pPos, double velBegin, double velEnd);
[DllImport("LTSMC.dll")]
public static extern short smc_ptt_table_unit(ushort ConnectNo, ushort iaxis, uint count, double[] pTime, double[] pPos);
[DllImport("LTSMC.dll")]
public static extern short smc_pvt_move(ushort ConnectNo, ushort AxisNum, ushort[] AxisList);
//安全机制
[DllImport("LTSMC.dll")]
public static extern short smc_set_el_mode(ushort ConnectNo, ushort axis, ushort enable, ushort el_logic, ushort el_mode); //设置EL信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_el_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort el_logic, ref ushort el_mode); //读取设置EL信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_emg_mode(ushort ConnectNo, ushort axis, ushort enable, ushort emg_logic); //设置EMG信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_emg_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort emg_logic); //读取设置EMG信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_softlimit_unit(ushort ConnectNo, ushort axis, ushort enable, ushort source_sel, ushort SL_action, double N_limit, double P_limit); //设置软限位参数
[DllImport("LTSMC.dll")]
public static extern short smc_get_softlimit_unit(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort source_sel, ref ushort SL_action, ref double N_limit, ref double P_limit); //读取软限位参数
//轴IO映射
[DllImport("LTSMC.dll")]
public static extern short smc_set_axis_io_map(ushort ConnectNo, ushort Axis, ushort IoType, ushort MapIoType, ushort MapIoIndex, double Filter);
[DllImport("LTSMC.dll")]
public static extern short smc_get_axis_io_map(ushort ConnectNo, ushort Axis, ushort IoType, ref ushort MapIoType, ref ushort MapIoIndex, ref double Filter);
//状态监控
[DllImport("LTSMC.dll")]
public static extern short smc_check_done(ushort ConnectNo, ushort axis); //读取指定轴的运动状态
[DllImport("LTSMC.dll")]
public static extern short smc_stop(ushort ConnectNo, ushort axis, ushort stop_mode); //单轴停止
[DllImport("LTSMC.dll")]
public static extern short smc_emg_stop(ushort ConnectNo); //紧急停止所有轴
[DllImport("LTSMC.dll")]
public static extern short smc_check_done_multicoor(ushort ConnectNo, ushort Crd);
[DllImport("LTSMC.dll")]
public static extern short smc_stop_multicoor(ushort ConnectNo, ushort Crd, ushort stop_mode);
[DllImport("LTSMC.dll")]
public static extern uint smc_axis_io_status(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern uint smc_axis_io_enable_status(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_get_axis_run_mode(ushort ConnectNo, ushort axis, ref ushort run_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_read_current_speed_unit(ushort ConnectNo, ushort axis, ref double current_speed);
[DllImport("LTSMC.dll")]
public static extern short smc_set_position_unit(ushort ConnectNo, ushort axis, double pos);
[DllImport("LTSMC.dll")]
public static extern short smc_get_position_unit(ushort ConnectNo, ushort axis, ref double pos);
[DllImport("LTSMC.dll")]
public static extern int smc_get_target_position_unit(ushort ConnectNo, ushort axis, ref double pos); //读取指定轴的目标位置
[DllImport("LTSMC.dll")]
public static extern short smc_set_workpos_unit(ushort ConnectNo, ushort axis, double pos);
[DllImport("LTSMC.dll")]
public static extern short smc_get_workpos_unit(ushort ConnectNo, ushort axis, ref double pos);
[DllImport("LTSMC.dll")]
public static extern short smc_get_stop_reason(ushort ConnectNo, ushort axis, ref int StopReason);
[DllImport("LTSMC.dll")]
public static extern short smc_clear_stop_reason(ushort ConnectNo, ushort axis);
//通用IO
[DllImport("LTSMC.dll")]
public static extern short smc_read_inbit(ushort ConnectNo, ushort bitno); //读取输入口的状态
[DllImport("LTSMC.dll")]
public static extern short smc_write_outbit(ushort ConnectNo, ushort bitno, ushort on_off); //设置输出口的状态
[DllImport("LTSMC.dll")]
public static extern short smc_read_outbit(ushort ConnectNo, ushort bitno); //读取输出口的状态
[DllImport("LTSMC.dll")]
public static extern uint smc_read_inport(ushort ConnectNo, ushort portno); //读取输入端口的值
[DllImport("LTSMC.dll")]
public static extern uint smc_read_outport(ushort ConnectNo, ushort portno); //读取输出端口的值
[DllImport("LTSMC.dll")]
public static extern short smc_write_outport(ushort ConnectNo, ushort portno, uint outport_val); //设置输出端口的值
[DllImport("LTSMC.dll")]
public static extern short smc_reverse_outbit(ushort ConnectNo, ushort bitno, double reverse_time);
[DllImport("LTSMC.dll")]
public static extern short smc_set_io_count_mode(ushort ConnectNo, ushort bitno, ushort mode, double filter);
[DllImport("LTSMC.dll")]
public static extern short smc_get_io_count_mode(ushort ConnectNo, ushort bitno, ref ushort mode, ref double filter);
[DllImport("LTSMC.dll")]
public static extern short smc_set_io_count_value(ushort ConnectNo, ushort bitno, uint CountValue);
[DllImport("LTSMC.dll")]
public static extern short smc_get_io_count_value(ushort ConnectNo, ushort bitno, ref uint CountValue);
[DllImport("LTSMC.dll")]
public static extern short smc_set_io_dstp_mode(ushort ConnectNo, ushort axis, ushort enable, ushort logic); //enable:0-禁用,1-按时间减速停止,2-按距离减速停止
[DllImport("LTSMC.dll")]
public static extern short smc_get_io_dstp_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort logic);
[DllImport("LTSMC.dll")]
public static extern short smc_set_dec_stop_time(ushort ConnectNo, ushort axis, double time);
[DllImport("LTSMC.dll")]
public static extern short smc_get_dec_stop_time(ushort ConnectNo, ushort axis, ref double time);
[DllImport("LTSMC.dll")]
public static extern short smc_set_io_pwmoutput(ushort ConnectNo, ushort outbit, double time1, double time2, uint counts);//设置IO输出一定脉冲个数的PWM波形曲线
[DllImport("LTSMC.dll")]
public static extern short smc_clear_io_pwmoutput(ushort ConnectNo, ushort outbit);//清除IO输出PWM波形曲线
//专用IO操作
[DllImport("LTSMC.dll")]
public static extern short smc_set_alm_mode(ushort ConnectNo, ushort axis, ushort enable, ushort alm_logic, ushort alm_action); //设置ALM信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_alm_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort alm_logic, ref ushort alm_action); //读取设置ALM信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_inp_mode(ushort ConnectNo, ushort axis, ushort enable, ushort inp_logic); //设置INP信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_inp_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort inp_logic); //读取设置INP信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_rdy_mode(ushort ConnectNo, ushort axis, ushort enable, ushort rdy_logic); //设置RDY信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_rdy_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort rdy_logic); //读取设置RDY信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_erc_mode(ushort ConnectNo, ushort axis, ushort enable, ushort erc_logic, ushort erc_width, ushort erc_off_time); //设置ERC信号
[DllImport("LTSMC.dll")]
public static extern short smc_get_erc_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort erc_logic, ref ushort erc_width, ref ushort erc_off_time); //读取设置ERC信号
[DllImport("LTSMC.dll")]
public static extern short smc_write_sevon_pin(ushort ConnectNo, ushort axis, ushort on_off); //输出SEVON信号
[DllImport("LTSMC.dll")]
public static extern short smc_read_sevon_pin(ushort ConnectNo, ushort axis); //读取SEVON信号
[DllImport("LTSMC.dll")]
public static extern short smc_read_rdy_pin(ushort ConnectNo, ushort axis); //读取RDY状态
[DllImport("LTSMC.dll")]
public static extern short smc_write_erc_pin(ushort ConnectNo, ushort axis, ushort on_off); //控制ERC信号输出
[DllImport("LTSMC.dll")]
public static extern short smc_read_erc_pin(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short smc_write_sevrst_pin(ushort ConnectNo, ushort axis, ushort on_off); //输出伺服复位信号
[DllImport("LTSMC.dll")]
public static extern short smc_read_sevrst_pin(ushort ConnectNo, ushort axis); //读伺服复位信号
[DllImport("LTSMC.dll")]
public static extern short smc_set_dstp_mode(ushort ConnectNo, ushort axis, ushort enable, ushort logic, uint time);
[DllImport("LTSMC.dll")]
public static extern short smc_get_dstp_mode(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort logic, ref uint time);
[DllImport("LTSMC.dll")]
public static extern short smc_set_dstp_time(ushort ConnectNo, ushort axis, uint time);
[DllImport("LTSMC.dll")]
public static extern short smc_get_dstp_time(ushort ConnectNo, ushort axis, ref uint time);
[DllImport("LTSMC.dll")]
public static extern short smc_set_io_dstp_bitno(ushort ConnectNo, ushort axis, ushort bitno, double filter); //设置通用输入口的一位位减速停止IO口
[DllImport("LTSMC.dll")]
public static extern short smc_get_io_dstp_bitno(ushort ConnectNo, ushort axis, ref ushort bitno, ref double filter);
//插补参数设置
[DllImport("LTSMC.dll")]
public static extern short smc_set_vector_profile_unit(ushort ConnectNo, ushort Crd, double Min_Vel, double Max_Vel, double Tacc, double Tdec, double Stop_Vel);
[DllImport("LTSMC.dll")]
public static extern short smc_get_vector_profile_unit(ushort ConnectNo, ushort Crd, ref double Min_Vel, ref double Max_Vel, ref double Tacc, ref double Tdec, ref double Stop_Vel);
[DllImport("LTSMC.dll")]
public static extern short smc_set_vector_tacc(ushort ConnectNo, ushort Crd, double Tacc);
[DllImport("LTSMC.dll")]
public static extern short smc_set_vector_acc(ushort ConnectNo, ushort Crd, double acc);
[DllImport("LTSMC.dll")]
public static extern short smc_set_vector_speed_unit(ushort ConnectNo, ushort Crd, double Max_vel);
[DllImport("LTSMC.dll")]
public static extern short smc_set_vector_s_profile(ushort ConnectNo, ushort Crd, ushort s_mode, double s_para); //设置平滑速度曲线参数
[DllImport("LTSMC.dll")]
public static extern short smc_get_vector_s_profile(ushort ConnectNo, ushort Crd, ushort s_mode, ref double s_para);
[DllImport("LTSMC.dll")]
public static extern short smc_set_vector_dec_stop_time(ushort ConnectNo, ushort Crd, double time);
[DllImport("LTSMC.dll")]
public static extern short smc_get_vector_dec_stop_time(ushort ConnectNo, ushort Crd, ref double time);
//单段插补
[DllImport("LTSMC.dll")]
public static extern short smc_line_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Dist, ushort posi_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_arc_move_center_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Target_Pos, double[] Cen_Pos, ushort Arc_Dir, int Circle, ushort posi_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_arc_move_radius_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Target_Pos, double Arc_Radius, ushort Arc_Dir, int Circle, ushort posi_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_arc_move_3points_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Target_Pos, double[] Mid_Pos, int Circle, ushort posi_mode);
//连续插补
[DllImport("LTSMC.dll")]
public static extern short smc_conti_open_list(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList); //打开连续缓存区
[DllImport("LTSMC.dll")]
public static extern short smc_conti_close_list(ushort ConnectNo, ushort Crd); //关闭连续缓存区
[DllImport("LTSMC.dll")]
public static extern short smc_conti_stop_list(ushort ConnectNo, ushort Crd, ushort stop_mode); //连续插补中停止
[DllImport("LTSMC.dll")]
public static extern short smc_conti_pause_list(ushort ConnectNo, ushort Crd); //连续插补中暂停
[DllImport("LTSMC.dll")]
public static extern short smc_conti_start_list(ushort ConnectNo, ushort Crd); //开始连续插补
[DllImport("LTSMC.dll")]
public static extern short smc_conti_check_done(ushort ConnectNo, ushort Crd);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_get_run_state(ushort ConnectNo, ushort Crd);//0-运行,1-暂停,2-正常停止,3-未启动,4-空闲
[DllImport("LTSMC.dll")]
public static extern int smc_conti_remain_space(ushort ConnectNo, ushort Crd); //查连续插补剩余缓存数
[DllImport("LTSMC.dll")]
public static extern int smc_conti_read_current_mark(ushort ConnectNo, ushort Crd); //读取当前连续插补段的标号
[DllImport("LTSMC.dll")]
public static extern short smc_conti_change_speed_ratio(ushort ConnectNo, ushort Crd, double percent); //设置插补中动态变速
//Blend模式
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_blend(ushort ConnectNo, ushort Crd, ushort enable);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_get_blend(ushort ConnectNo, ushort Crd, ref ushort enable);
//小线段前瞻
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_lookahead_mode(ushort ConnectNo, ushort Crd, ushort enable, int LookaheadSegments, double PathError, double LookaheadAcc);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_get_lookahead_mode(ushort ConnectNo, ushort Crd, ref ushort enable, ref int LookaheadSegments, ref double PathError, ref double LookaheadAcc);
//设置每段速度
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_taccdec(ushort ConnectNo, ushort Crd, double Taccdec);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_speed_unit(ushort ConnectNo, ushort Crd, double Max_vel);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_override(ushort ConnectNo, ushort Crd, double Percent);
//连续插补IO
[DllImport("LTSMC.dll")]
public static extern short smc_conti_wait_input(ushort ConnectNo, ushort Crd, ushort bitno, ushort on_off, double TimeOut, int mark);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_delay_outbit_to_start(ushort ConnectNo, ushort Crd, ushort bitno, ushort on_off, double delay_value, ushort delay_mode, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_delay_outbit_to_stop(ushort ConnectNo, ushort Crd, ushort bitno, ushort on_off, double delay_time, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_ahead_outbit_to_stop(ushort ConnectNo, ushort Crd, ushort bitno, ushort on_off, double ahead_value, ushort ahead_mode, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_accurate_outbit_unit(ushort ConnectNo, ushort Crd, ushort cmp_no, ushort on_off, ushort axis, double abs_pos, ushort pos_source, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_write_outbit(ushort ConnectNo, ushort Crd, ushort bitno, ushort on_off, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_clear_io_action(ushort ConnectNo, ushort Crd, uint Io_Mask);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_pause_output(ushort ConnectNo, ushort Crd, ushort action, int mask, int state);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_get_pause_output(ushort ConnectNo, ushort Crd, ref ushort action, ref int mask, ref int state);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_delay(ushort ConnectNo, ushort Crd, double delay_time, int mark);//延时指令
//连续插补轨迹
[DllImport("LTSMC.dll")]
public static extern short smc_conti_line_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] pPosList, ushort posi_mode, int mark);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_arc_move_center_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Target_Pos, double[] Cen_Pos, ushort Arc_Dir, int Circle, ushort posi_mode, int mark);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_arc_move_radius_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Target_Pos, double Arc_Radius, ushort Arc_Dir, int Circle, ushort posi_mode, int mark);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_arc_move_3points_unit(ushort ConnectNo, ushort Crd, ushort AxisNum, ushort[] AxisList, double[] Target_Pos, double[] Mid_Pos, int Circle, ushort posi_mode, int mark);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_pmove_unit(ushort ConnectNo, ushort Crd, ushort axis, double dist, ushort posi_mode, ushort mode, int imark);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_involute_mode(ushort ConnectNo, ushort Crd, ushort mode);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_get_involute_mode(ushort ConnectNo, ushort Crd, ref ushort mode);
//连续插补PWM
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_pwm_output(ushort ConnectNo, ushort Crd, ushort PwmNo, double fDuty, double fFre);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_set_pwm_follow_speed(ushort ConnectNo, ushort Crd, ushort pwm_no, ushort mode, double MaxVel, double MaxValue, double OutValue);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_get_pwm_follow_speed(ushort ConnectNo, ushort Crd, ushort pwm_no, ref ushort mode, ref double MaxVel, ref double MaxValue, ref double OutValue);
//设置PWM开关对应的占空比
[DllImport("LTSMC.dll")]
public static extern short smc_set_pwm_onoff_duty(ushort ConnectNo, ushort PwmNo, double fOnDuty, double fOffDuty);
[DllImport("LTSMC.dll")]
public static extern short smc_get_pwm_onoff_duty(ushort ConnectNo, ushort PwmNo, ref double fOnDuty, ref double fOffDuty);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_delay_pwm_to_start(ushort ConnectNo, ushort Crd, ushort pwmno, ushort on_off, double delay_value, ushort delay_mode, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_delay_pwm_to_stop(ushort ConnectNo, ushort Crd, ushort pwmno, ushort on_off, double delay_time, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_ahead_pwm_to_stop(ushort ConnectNo, ushort Crd, ushort bitno, ushort on_off, double ahead_value, ushort ahead_mode, double ReverseTime);
[DllImport("LTSMC.dll")]
public static extern short smc_conti_write_pwm(ushort ConnectNo, ushort Crd, ushort pwmno, ushort on_off, double ReverseTime);
//PWM功能
[DllImport("LTSMC.dll")]
public static extern short smc_set_pwm_enable(ushort ConnectNo, ushort enable);
[DllImport("LTSMC.dll")]
public static extern short smc_get_pwm_enable(ushort ConnectNo, ref ushort enable);
[DllImport("LTSMC.dll")]
public static extern short smc_set_pwm_output(ushort ConnectNo, ushort PwmNo, double fDuty, double fFre);
[DllImport("LTSMC.dll")]
public static extern short smc_get_pwm_output(ushort ConnectNo, ushort PwmNo, ref double fDuty, ref double fFre);
//位置比较
//单轴位置比较
[DllImport("LTSMC.dll")]
public static extern short smc_compare_set_config(ushort ConnectNo, ushort axis, ushort enable, ushort cmp_source); //配置比较器
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_config(ushort ConnectNo, ushort axis, ref ushort enable, ref ushort cmp_source); //读取配置比较器
[DllImport("LTSMC.dll")]
public static extern short smc_compare_clear_points(ushort ConnectNo, ushort axis); //清除所有比较点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_add_point_unit(ushort ConnectNo, ushort axis, double pos, ushort dir, ushort action, uint actpara); //添加比较点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_current_point_unit(ushort ConnectNo, ushort axis, ref double pos); //读取当前比较点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_points_runned(ushort ConnectNo, ushort axis, ref int pointNum); //查询已经比较过的点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_points_remained(ushort ConnectNo, ushort axis, ref int pointNum); //查询可以加入的比较点数量
[DllImport("LTSMC.dll")]
public static extern short smc_compare_add_point_cycle(ushort CardNo, ushort cmp, int pos, ushort dir, uint bitno, uint cycle, ushort level);
//二维位置比较
[DllImport("LTSMC.dll")]
public static extern short smc_compare_set_config_extern(ushort ConnectNo, ushort enable, ushort cmp_source); //配置比较器
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_config_extern(ushort ConnectNo, ref ushort enable, ref ushort cmp_source); //读取配置比较器
[DllImport("LTSMC.dll")]
public static extern short smc_compare_clear_points_extern(ushort ConnectNo); //清除所有比较点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_add_point_extern_unit(ushort ConnectNo, ushort[] axis, double[] pos, ushort[] dir, ushort action, uint actpara); //添加两轴位置比较点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_current_point_extern_unit(ushort ConnectNo, double[] pos); //读取当前比较点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_points_runned_extern(ushort ConnectNo, ref int pointNum); //查询已经比较过的点
[DllImport("LTSMC.dll")]
public static extern short smc_compare_get_points_remained_extern(ushort ConnectNo, ref int pointNum); //查询可以加入的比较点数量
//高速位置比较
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_set_mode(ushort ConnectNo, ushort hcmp, ushort cmp_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_get_mode(ushort ConnectNo, ushort hcmp, ref ushort cmp_mode);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_set_config(ushort ConnectNo, ushort hcmp, ushort axis, ushort cmp_source, ushort cmp_logic, int time);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_get_config(ushort ConnectNo, ushort hcmp, ref ushort axis, ref ushort cmp_source, ref ushort cmp_logic, ref int time);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_add_point_unit(ushort ConnectNo, ushort hcmp, double cmp_pos);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_set_liner_unit(ushort ConnectNo, ushort hcmp, double Increment, int Count);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_get_liner_unit(ushort ConnectNo, ushort hcmp, ref double Increment, ref int Count);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_get_current_state_unit(ushort ConnectNo, ushort hcmp, ref int remained_points, ref double current_point, ref int runned_points);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_clear_points(ushort ConnectNo, ushort hcmp);
[DllImport("LTSMC.dll")]
public static extern short smc_read_cmp_pin(ushort ConnectNo, ushort hcmp);
[DllImport("LTSMC.dll")]
public static extern short smc_write_cmp_pin(ushort ConnectNo, ushort hcmp, ushort on_off);
//高速二维位置比较
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_set_enable(ushort ConnectNo, ushort hcmp, ushort cmp_enable);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_get_enable(ushort ConnectNo, ushort hcmp, ref ushort cmp_enable);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_set_config_unit(ushort ConnectNo, ushort hcmp, ushort cmp_mode, ushort x_axis, ushort x_cmp_source, double x_cmp_error, ushort y_axis, ushort y_cmp_source, double y_cmp_error, ushort cmp_logic, int time);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_get_config_unit(ushort ConnectNo, ushort hcmp, ref ushort cmp_mode, ref ushort x_axis, ref ushort x_cmp_source, ref double x_cmp_error, ref ushort y_axis, ref ushort y_cmp_source, ref double y_cmp_error, ref ushort cmp_logic, ref int time);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_set_pwmoutput(ushort ConnectNo, ushort hcmp, ushort pwm_enable, double duty, double freq, ushort pwm_number);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_get_pwmoutput(ushort ConnectNo, ushort hcmp, ref ushort pwm_enable, ref double duty, ref double freq, ref ushort pwm_number);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_add_point_unit(ushort ConnectNo, ushort hcmp, double x_cmp_pos, double y_cmp_pos, ushort cmp_outbit);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_get_current_state(ushort ConnectNo, ushort hcmp, ref int remained_points, ref double x_current_point, ref double y_current_point, ref int runned_points, ref ushort current_state, ref ushort current_outbit);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_clear_points(ushort ConnectNo, ushort hcmp);
[DllImport("LTSMC.dll")]
public static extern short smc_hcmp_2d_force_output(ushort ConnectNo, ushort hcmp, ushort outbit);
//模拟量操作
//AD
[DllImport("LTSMC.dll")]
public static extern double smc_get_ain(ushort ConnectNo, ushort channel);
[DllImport("LTSMC.dll")]
public static extern short smc_set_ain_action(ushort ConnectNo, ushort channel, ushort mode, double fvoltage, ushort action, double actpara);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ain_action(ushort ConnectNo, ushort channel, ref ushort mode, ref double fvoltage, ref ushort action, ref double actpara);
[DllImport("LTSMC.dll")]
public static extern short smc_get_ain_state(ushort ConnectNo, ushort channel);
[DllImport("LTSMC.dll")]
public static extern short smc_set_ain_state(ushort ConnectNo, ushort channel);
//DA
[DllImport("LTSMC.dll")]
public static extern short smc_set_da_output(ushort ConnectNo, ushort channel, double Vout);
[DllImport("LTSMC.dll")]
public static extern short smc_get_da_output(ushort ConnectNo, ushort channel, ref double Vout);
//点胶参数设置
[DllImport("LTSMC.dll")]
public static extern short smc_glue_set_profile(ushort ConnectNo, ushort glue, ushort io, ushort on_off, double[] Offset, double[] dist, double[] time);
[DllImport("LTSMC.dll")]
public static extern short smc_glue_get_profile(ushort ConnectNo, ushort glue, ref ushort io, ref ushort on_off, double[] Offset, double[] dist, double[] time);
//文件操作
[DllImport("LTSMC.dll")]
public static extern short smc_download_file(ushort CardNo, string pfilename, byte[] pfilenameinControl, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_download_memfile(ushort CardNo, byte[] pbuffer, uint buffsize, byte[] pfilenameinControl, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_upload_file(ushort CardNo, string pfilename, byte[] pfilenameinControl, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_upload_memfile(ushort CardNo, byte[] pbuffer, uint buffsize, byte[] pfilenameinControl, ref uint puifilesize, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_download_file_to_ram(ushort CardNo, string pfilename, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_download_memfile_to_ram(ushort CardNo, byte[] pbuffer, uint buffsize, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_get_progress(ushort ConnectNo, ref float progress);
//寄存器操作
[DllImport("LTSMC.dll")]
public static extern short smc_set_modbus_0x(ushort CardNo, ushort start, ushort inum, byte[] pdata);
[DllImport("LTSMC.dll")]
public static extern short smc_get_modbus_0x(ushort CardNo, ushort start, ushort inum, byte[] pdata);
[DllImport("LTSMC.dll")]
public static extern short smc_set_modbus_4x(ushort CardNo, ushort start, ushort inum, ushort[] pdata);
[DllImport("LTSMC.dll")]
public static extern short smc_get_modbus_4x(ushort CardNo, ushort start, ushort inum, ushort[] pdata);
//Basic变量
[DllImport("LTSMC.dll")]
public static extern short smc_read_array(ushort CardNo, string name, uint index, long[] var, ref int num);
[DllImport("LTSMC.dll")]
public static extern short smc_modify_array(ushort CardNo, string name, uint index, long[] var, int num);
[DllImport("LTSMC.dll")]
public static extern short smc_read_var(ushort CardNo, string varstring, long[] var, ref int num);
[DllImport("LTSMC.dll")]
public static extern short smc_modify_var(ushort CardNo, string varstring, long[] var, int varnum);
[DllImport("LTSMC.dll")]
public static extern short smc_read_array_ex(ushort ConnectNo, string name, uint index, double[] var, ref int num);
[DllImport("LTSMC.dll")]
public static extern short smc_modify_array_ex(ushort ConnectNo, string name, uint index, double[] var, int num);
[DllImport("LTSMC.dll")]
public static extern short smc_read_var_ex(ushort ConnectNo, string varstring, double[] var, ref int num);
[DllImport("LTSMC.dll")]
public static extern short smc_modify_var_ex(ushort ConnectNo, string varstring, double[] var, int varnum);
[DllImport("LTSMC.dll")]
public static extern short smc_write_array_ex(ushort ConnectNo, string name, uint startindex, double[] var, int num);
[DllImport("LTSMC.dll")]
public static extern short smc_get_stringtype(ushort CardNo, string varstring, ref int m_Type, ref int num);
//Basic控制
[DllImport("LTSMC.dll")]
public static extern short smc_basic_state(ushort CardNo, ref ushort State);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_run(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_pause(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_stop(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_continue_run(ushort CardNo);
//Basic调试
[DllImport("LTSMC.dll")]
public static extern short smc_basic_current_line(ushort CardNo, ref int line);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_break_info(ushort CardNo, int[] line, int linenum);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_step_over(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_step_run(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_message(ushort CardNo, byte[] pbuff, uint uimax, ref uint puiread);
[DllImport("LTSMC.dll")]
public static extern short smc_basic_command(ushort CardNo, byte[] pszCommand, byte[] psResponse, uint uiResponseLength);
//G代码
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_start(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_stop(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_pause(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_state(ushort CardNo, ref ushort state);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_clear_file(ushort CardNo);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_delete_file(ushort CardNo, byte[] pfilenameinControl);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_current_line(ushort CardNo, ref uint line, byte[] pCurLine);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_set_current_file(ushort CardNo, byte[] pFileName);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_get_current_file(ushort CardNo, byte[] pFileName, ref short fileid);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_get_first_file(ushort CardNo, byte[] pfilenameinControl, ref uint pFileSize);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_get_next_file(ushort CardNo, byte[] pfilenameinControl, ref uint pFileSize);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_check_file(ushort CardNo, byte[] pfilenameinControl, ref byte pbIfExist, ref uint pFileSize);
[DllImport("LTSMC.dll")]
public static extern short smc_gcode_get_file_profile(ushort CardNo, ref uint maxfilenum, ref uint maxfilesize);
/******************************************
U盘文件管理
***************************************/
[DllImport("LTSMC.dll")]
public static extern short smc_udisk_get_state(ushort ConnectNo, ref ushort state);
[DllImport("LTSMC.dll")]
public static extern short smc_udisk_check_file(ushort ConnectNo, byte[] filename, ref int filesize, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_udisk_get_first_file(ushort ConnectNo, byte[] filename, ref int filesize, ref int fileid, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_udisk_get_next_file(ushort ConnectNo, byte[] filename, ref int filesize, ref int fileid, ushort filetype);
[DllImport("LTSMC.dll")]
public static extern short smc_udisk_copy_file(ushort ConnectNo, string SrcFileName, string DstFileName, ushort filetype, ushort mode);
//当前位置
[DllImport("LTSMC.dll")]
public static extern short smc_set_encoder_unit(ushort ConnectNo, ushort axis, double pos);
[DllImport("LTSMC.dll")]
public static extern short smc_get_encoder_unit(ushort ConnectNo, ushort axis, ref double pos);
//变速变位
[DllImport("LTSMC.dll")]
public static extern short smc_reset_target_position_unit(ushort ConnectNo, ushort axis, double New_Pos);
[DllImport("LTSMC.dll")]
public static extern short smc_update_target_position_unit(ushort ConnectNo, ushort axis, double New_Pos);
[DllImport("LTSMC.dll")]
public static extern short smc_change_speed_unit(ushort ConnectNo, ushort axis, double New_Vel, double Taccdec);
[DllImport("LTSMC.dll")]
public static extern short smc_enter_password(ushort ConnectNo, byte[] str_pass);
[DllImport("LTSMC.dll")]
public static extern short smc_modify_password(ushort ConnectNo, byte[] spassold, byte[] spass);
//掉电保存寄存器操作
[DllImport("LTSMC.dll")]
public static extern short smc_set_persistent_reg(ushort ConnectNo, ushort start, ushort inum, byte[] pdata);
[DllImport("LTSMC.dll")]
public static extern short smc_get_persistent_reg(ushort ConnectNo, ushort start, ushort inum, byte[] pdata);
//参数文件
[DllImport("LTSMC.dll")]
public static extern short smc_download_parafile(ushort ConnectNo, byte[] FileName);
[DllImport("LTSMC.dll")]
public static extern short smc_upload_parafile(ushort ConnectNo, byte[] FileName);
//圆弧限制
[DllImport("LTSMC.dll")]
public static extern short smc_set_arc_limit(ushort ConnectNo, ushort Crd, ushort Enable, double MaxCenAcc, double MaxArcError);
[DllImport("LTSMC.dll")]
public static extern short smc_get_arc_limit(ushort ConnectNo, ushort Crd, ref ushort Enable, ref double MaxCenAcc, ref double MaxArcError);
//
[DllImport("LTSMC.dll")]
public static extern short smc_read_trace_data(ushort ConnectNo, ushort axis, int bufsize, double[] time, double[] pos, double[] vel, double[] acc, ref int recv_num);
[DllImport("LTSMC.dll")]
public static extern short smc_trace_start(ushort ConnectNo, ushort AxisNum, ushort[] AxisList);
[DllImport("LTSMC.dll")]
public static extern short smc_trace_stop(ushort ConnectNo);
[DllImport("LTSMC.dll")]
public static extern short smc_trace_set_source(ushort ConnectNo, ushort source);
//
//实时时钟
[DllImport("LTSMC.dll")]
public static extern short smc_rtc_get_time(ushort ConnectNo, ref int year, ref int month, ref int day, ref int hour, ref int min, ref int sec);
[DllImport("LTSMC.dll")]
public static extern short smc_rtc_set_time(ushort ConnectNo, int year, int month, int day, int hour, int min, int sec);
//
//
[DllImport("LTSMC.dll")]
public static extern short smc_soft_reset(ushort ConnectNo);
[DllImport("LTSMC.dll")]
public static extern short nmcs_reset_canopen(ushort ConnectNo);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_total_axes(ushort ConnectNo, ref uint TotalAxis); //读取指定卡轴数
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_total_ionum(ushort ConnectNo, ref ushort TotalIn, ref ushort TotalOut);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_total_adcnum(ushort ConnectNo, ref ushort TotalIn, ref ushort TotalOut);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_slave_nodes(ushort ConnectNo, ushort PortNum, ushort baudrate, ushort[] NodeID, ref ushort NodeNum);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_EmergeneyMessege_Nodes(ushort CardNo, ushort PortNum, uint[] NodeMsg, ref ushort MsgNum);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_LostHeartbeat_Nodes(ushort CardNo, ushort PortNum, ushort[] NodeID, ref ushort NodeNum);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_manager_od(ushort CardNo, ushort PortNum, ushort index, ushort subindex, ushort valuelength, ref uint value);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_manager_para(ushort CardNo, ushort PortNum, ref uint baudrate, ref ushort ManagerID);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_node_od(ushort CardNo, ushort PortNum, ushort nodenum, ushort index, ushort subindex, ushort valuelength, ref uint value);
[DllImport("LTSMC.dll")]
public static extern short nmcs_reset_to_factory(ushort CardNo, ushort PortNum, ushort NodeNum);
[DllImport("LTSMC.dll")]
public static extern short nmcs_SendNmtCommand(ushort CardNo, ushort PortNum, ushort NodeID, ushort NmtCommand);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_alarm_clear(ushort CardNo, ushort PortNum, ushort nodenum);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_axis_enable(ushort CardNo, ushort PortNum, ushort nodenum);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_manager_od(ushort CardNo, ushort PortNum, ushort index, ushort subindex, ushort valuelength, uint value);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_manager_para(ushort CardNo, ushort PortNum, int baudrate, ushort ManagerID);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_node_od(ushort CardNo, ushort PortNum, ushort nodenum, ushort index, ushort subindex, ushort valuelength, uint value);
[DllImport("LTSMC.dll")]
public static extern short nmcs_syn_move(ushort CardNo, ushort AxisNum, ushort[] AxisList, int[] Position, ushort[] PosiMode);
[DllImport("LTSMC.dll")]
public static extern short nmcs_write_outbit(ushort ConnectNo, ushort PortNum, ushort NodeID, ushort IoBit, ushort IoValue);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_outbit(ushort ConnectNo, ushort PortNum, ushort NodeID, ushort IoBit, ref ushort IoValue);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_inbit(ushort ConnectNo, ushort PortNum, ushort NodeID, ushort IoBit, ref ushort IoValue);
[DllImport("LTSMC.dll")]
public static extern short nmcs_write_outport(ushort ConnectNo, ushort PortNum, ushort NodeID, ushort PortNo, int IoValue);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_outport(ushort ConnectNo, ushort PortNum, ushort NodeID, ushort PortNo, ref int IoValue);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_inport(ushort ConnectNo, ushort PortNum, ushort NodeID, ushort PortNo, ref int IoValue);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_controller_workmode(ushort ConnectNo, ushort controller_mode);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_controller_workmode(ushort ConnectNo, ref ushort controller_mode);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_cycletime(ushort ConnectNo, ushort FieldbusType, uint CycleTime);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_cycletime(ushort ConnectNo, ushort FieldbusType, ref uint CycleTime);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_state_machine(ushort ConnectNo, ushort axis, ref ushort Axis_StateMachine);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_statusword(ushort ConnectNo, ushort axis, ref int statusword);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_setting_contrlmode(ushort ConnectNo, ushort axis, ref int contrlmode);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_contrlword(ushort ConnectNo, ushort axis, ref int contrlword);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_type(ushort ConnectNo, ushort axis, ref ushort Axis_Type);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_consume_time_fieldbus(ushort ConnectNo, ushort Fieldbustype, ref uint Average_time, ref uint Max_time, ref UInt64 Cycles);
[DllImport("LTSMC.dll")]
public static extern short nmcs_clear_consume_time_fieldbus(ushort ConnectNo, ushort Fieldbustype);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_axis_enable(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_axis_disable(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_node_address(ushort ConnectNo, ushort axis, ref ushort SlaveAddr, ref ushort Sub_SlaveAddr);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_total_slaves(ushort ConnectNo, ushort PortNum, ref ushort TotalSlaves);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_home_profile(ushort ConnectNo, ushort axis, ushort home_mode, double High_Vel, double Low_Vel, double Tacc, double Tdec, double offsetpos);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_home_profile(ushort ConnectNo, ushort axis, ref ushort home_mode, ref double High_Vel, ref double Low_Vel, ref double Tacc, ref double Tdec, ref double offsetpos);
[DllImport("LTSMC.dll")]
public static extern short nmcs_home_move(ushort ConnectNo, ushort axis);
//
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_errcode(ushort CardNo, ushort channel, ref ushort errcode);
[DllImport("LTSMC.dll")]
public static extern short nmcs_clear_errcode(ushort CardNo, ushort channel);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_axis_errcode(ushort CardNo, ushort axis, ref ushort Errcode);
[DllImport("LTSMC.dll")]
public static extern short nmcs_clear_axis_errcode(ushort CardNo, ushort axis);
//
[DllImport("LTSMC.dll")]
public static extern short nmcs_write_rxpdo_extra(ushort ConnectNo, ushort PortNum, ushort address, ushort DataLen, uint Value);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_rxpdo_extra(ushort ConnectNo, ushort PortNum, ushort address, ushort DataLen, ref uint Value);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_txpdo_extra(ushort ConnectNo, ushort PortNum, ushort address, ushort DataLen, ref uint Value);
//
//RTEX
//
[DllImport("LTSMC.dll")]
public static extern short nmcs_start_connect(ushort ConnectNo, ushort chan, ushort[] info, ref ushort len);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_vendor_info(ushort ConnectNo, ushort axis, byte[] info, ref ushort len);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_slave_type_info(ushort ConnectNo, ushort axis, byte[] info, ref ushort len);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_slave_name_info(ushort ConnectNo, ushort axis, byte[] info, ref ushort len);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_slave_version_info(ushort ConnectNo, ushort axis, byte[] info, ref ushort len);
[DllImport("LTSMC.dll")]
public static extern short nmcs_write_parameter(ushort ConnectNo, ushort axis, ushort index, ushort subindex, uint para_data);
[DllImport("LTSMC.dll")]
public static extern short nmcs_write_slave_eeprom(ushort ConnectNo, ushort axis);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_parameter(ushort ConnectNo, ushort axis, ushort index, ushort subindex, ref uint para_data);
[DllImport("LTSMC.dll")]
public static extern short nmcs_read_parameter_attributes(ushort ConnectNo, ushort axis, ushort index, ushort subindex, ref uint para_data);
[DllImport("LTSMC.dll")]
public static extern short nmcs_set_cmdcycletime(ushort ConnectNo, ushort PortNum, uint cmdtime);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_cmdcycletime(ushort ConnectNo, ushort PortNum, ref uint cmdtime);
[DllImport("LTSMC.dll")]
public static extern short nmcs_start_log(ushort ConnectNo, ushort chan, ushort node, ushort Ifenable);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_log(ushort ConnectNo, ushort chan, ushort node, uint[] data);
[DllImport("LTSMC.dll")]
public static extern short nmcs_config_atuo_log(ushort ConnectNo, ushort ifenable, ushort dir, ushort byte_index, ushort mask, ushort condition, uint counter);
[DllImport("LTSMC.dll")]
public static extern short nmcs_get_log_state(ushort ConnectNo, ushort chan, ref uint state);
[DllImport("LTSMC.dll")]
public static extern short nmcs_driver_reset(ushort ConnectNo, ushort axis);
}
}

36
Community/MyMessageBox.cs Normal file
View File

@ -0,0 +1,36 @@
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Community
{
/// <summary>
/// 自定义提示框
/// </summary>
public class MyMessageBox
{
#region MetroWindow相关参数
/// <summary>
/// 窗体对象
/// </summary>
public static MetroWindow MetroWin { get; set; }
static MetroDialogSettings settings = new MetroDialogSettings() { AffirmativeButtonText="确定", NegativeButtonText = "取消"};
#endregion
/// <summary>
/// 显示提醒窗
/// </summary>
/// <param name="title"></param>
/// <param name="message"></param>
/// <param name="style"></param>
public static MessageDialogResult Show(string message, string title="", MessageDialogStyle style = MessageDialogStyle.Affirmative)
{
return MetroWin.ShowModalMessageExternal(title, message, style, settings);
}
}
}

View File

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Community
{
/// <summary>
/// 数据变更UI触发器
/// </summary>
public class NotificationObject : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public void RaisePropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("Community")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Community")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("40bd9b86-2281-4e16-bfab-558cb18e873c")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

288
Community/SerialCom.cs Normal file
View File

@ -0,0 +1,288 @@
using System;
using System.Collections.Generic;
using System.IO.Ports;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
namespace Community
{
/// <summary>
/// 串口类
/// </summary>
public class SerialCom : NotificationObject
{
#region 串口对象
/// <summary>
/// 串口对象
/// </summary>
public SerialPort ComPort { get; set; }
#endregion
#region 串口号
private string portName;
/// <summary>
/// 串口号
/// </summary>
public string PortName
{
get { return portName; }
set
{
portName = value;
this.RaisePropertyChanged("PortName");
}
}
#endregion
#region 波特率
private int baudRate;
/// <summary>
/// 波特率
/// </summary>
public int BaudRate
{
get { return baudRate; }
set
{
baudRate = value;
this.RaisePropertyChanged("BaudRate");
}
}
#endregion
#region 校验位
private int parityNumber;
/// <summary>
/// 校验位
/// </summary>
public int ParityNumber
{
get { return parityNumber; }
set
{
parityNumber = value;
this.RaisePropertyChanged("ParityNumber");
}
}
#endregion
#region 数据位
private int dataBits;
/// <summary>
/// 数据位
/// </summary>
public int DataBits
{
get { return dataBits; }
set
{
dataBits = value;
this.RaisePropertyChanged("DataBits");
}
}
#endregion
#region 停止位
private int stopBitsNumber;
/// <summary>
/// 停止位
/// </summary>
public int StopBitsNumber
{
get { return stopBitsNumber; }
set
{
stopBitsNumber = value;
this.RaisePropertyChanged("StopBitsNumber");
}
}
#endregion
#region 可用串口名称集合
private List<string> comPortList;
/// <summary>
/// 可用串口名称集合
/// </summary>
public List<string> ComPortList
{
get { return comPortList; }
set
{
comPortList = value;
this.RaisePropertyChanged("ComPortList");
}
}
#endregion
#region 接收到的字符串
private string receiveStr;
/// <summary>
/// 接收到的字符串
/// </summary>
public string ReceiveStr
{
get { return receiveStr; }
set
{
receiveStr = value;
this.RaisePropertyChanged("ReceiveStr");
}
}
#endregion
#region 发送的字符串
private string sendStr;
/// <summary>
/// 发送的字符串
/// </summary>
public string SendStr
{
get { return sendStr; }
set
{
sendStr = value;
this.RaisePropertyChanged("SendStr");
}
}
#endregion
#region 错误信息
private string errorMag;
/// <summary>
/// 错误信息
/// </summary>
public string ErrorMag
{
get { return errorMag; }
set
{
errorMag = value;
this.RaisePropertyChanged("ErrorMag");
}
}
#endregion
public SerialCom()
{
GetPortList();
ReceiveStr = "没有接收到任何信息";
SendStr = "请输入要发送的内容";
//OpenSerialCom();
}
public SerialCom(string protName, int BaudRate, Parity p, int DataBits, StopBits sp)
{
try
{
ComPort = new SerialPort();
ComPort.PortName = protName; //ComPortList[0];//设置要打开的串口
ComPort.BaudRate = BaudRate;//设置当前波特率
ComPort.Parity = p;//设置当前校验位
ComPort.DataBits = DataBits;//设置当前数据位
ComPort.StopBits = sp;//设置当前停止位
ComPort.Open();//打开串口
ComPort.DataReceived += ComPort_DataReceived;
}
catch (Exception)
{
}
}
/// <summary>
/// 接收数据回调函数
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void ComPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
{
//byte[] recBuffer = new byte[ComPort.BytesToRead];//接收数据缓存大小
//ComPort.Read(recBuffer, 0, recBuffer.Length);//读取数据
//ReceiveStr = System.Text.Encoding.Default.GetString(recBuffer);//转码
ReceiveStr = ComPort.ReadTo("\r\n");
}
#region 获取可用串口集合
/// <summary>
/// 获取可用串口集合
/// </summary>
public void GetPortList()
{
ComPortList = new List<string>();
ComPortList = SerialPort.GetPortNames().ToList();
}
#endregion
#region 打开串口
/// <summary>
/// 打开串口
/// </summary>
/// <param name="ComNumber">串口号</param>
public bool OpenSerialCom(string ComNumber)
{
if (ComPortList.Count <= 0)
{
ErrorMag = "无可用串口";
return false;
}
else
{
if (!ComPortList.Contains(ComNumber))
{
ErrorMag = "指定的串口号不存在";
return false;
}
}
try
{
ComPort = new SerialPort();
ComPort.PortName = ComNumber; //ComPortList[0];//设置要打开的串口
ComPort.BaudRate = 19200;//设置当前波特率
ComPort.Parity = Parity.None;//设置当前校验位
ComPort.DataBits = 8;//设置当前数据位
ComPort.StopBits = StopBits.One;//设置当前停止位
ComPort.Open();//打开串口
return true;
}
catch//如果串口被其他占用,则无法打开
{
ErrorMag = "无法打开串口,请检测此串口是否有效或被其他占用!";
GetPortList();
return false;
}
}
#endregion
#region 发送
/// <summary>
/// 发送
/// </summary>
public void Send(string SendStr)
{
if (ComPort != null)
{
byte[] sendBuffer = System.Text.Encoding.Default.GetBytes(SendStr);//转码
ComPort.Write(sendBuffer, 0, sendBuffer.Length);
}
}
#endregion
}
}

231
Community/ShareHelp.cs Normal file
View File

@ -0,0 +1,231 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Script.Serialization;
namespace Community
{
/// <summary>
/// 公共帮助类
/// </summary>
public class ShareHelp
{
/// <summary>
/// 用户名
/// </summary>
public static string UserID = "";
public static string UserName = "";
/// <summary>
/// 是否是管理员
/// </summary>
public static bool TheManage = false;
/// <summary>
/// 设备是否处于运行中
/// </summary>
public static bool RunIng { get; set; }
#region 记录用户用户操作
static byte[] data { get; set; }
/// <summary>
/// 文件夹路径
/// </summary>
static string path { get; set; }
/// <summary>
/// 文件路径
/// </summary>
static string paths { get; set; }
/// <summary>
/// 打开的文件流对象
/// </summary>
static FileStream FS { get; set; }
/// <summary>
/// 记录用户用户操作
/// </summary>
/// <param name="info"></param>
public static void UserLog(string showMag)
{
try
{
object TraceObj = new object();
lock (TraceObj)
{
path = @"D:\\Log\UserLog\" + ShareHelp.UserID + "\\"; //文件夹路径
paths = @"D:\\Log\UserLog\" + ShareHelp.UserID + "\\" + DateTime.Now.ToString("D") + ".txt"; //文件路径 以年月日为名称
//创建文件夹
if (!Directory.Exists(path))
{
Directory.CreateDirectory(path);
}
//打开或创建文件
FS = File.Open(paths, FileMode.Append);
//获得字节数组
data = System.Text.Encoding.Default.GetBytes(DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss.fff") + "【" + showMag + "】\r\n");
//开始写入
FS.Write(data, 0, data.Length);
//清空缓冲区、关闭流
FS.Flush();
FS.Close();
}
}
catch
{
}
}
#endregion
#region Json序列化
/// <summary>
/// js 序列化器
/// </summary>
static JavaScriptSerializer jss = new JavaScriptSerializer();
#region 1、将对象转换成Json字符创
/// <summary>
/// 将对象转换成Json字符创(泛型)
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
public static string ObjToJson(object obj)
{
// return JsonConvert.SerializeObject(obj);
try
{
var json = jss.Serialize(obj);
//将时间格式转换为适合阅读习惯的格式,
json = System.Text.RegularExpressions.Regex.Replace(json, @"\\/Date\((\d+)\)\\/", match =>
{
DateTime dt = new DateTime(1970, 1, 1);
dt = dt.AddMilliseconds(long.Parse(match.Groups[1].Value));
dt = dt.ToLocalTime(); //本地时间
return dt.ToString(); ;
});
return json;
}
catch (Exception)
{
return string.Empty;
}
// return jss.Serialize(obj);
}
#endregion
#region 2、将Json还原成对象(泛型)
/// <summary>
/// 将Json还原成对象(泛型)
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="json"></param>
/// <returns></returns>
public static T JsonToObj<T>(string json)
{
try
{
var deserializedResult = jss.Deserialize<T>(json);
return deserializedResult;
}
catch (Exception)
{
return default(T);
}
}
#endregion
#endregion
#region 磁盘空间是否已满
/// <summary>
/// 获取指定驱动器的空间总大小(单位为B)
/// </summary>
/// <param name="str_HardDiskName">只需输入代表驱动器的字母即可 (大写)</param>
/// <returns></returns>
public static long GetHardDiskSpace(string str_HardDiskName)
{
long totalSize = new long();
str_HardDiskName = str_HardDiskName + ":\\";
System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
foreach (System.IO.DriveInfo drive in drives)
{
if (drive.Name == str_HardDiskName)
{
totalSize = drive.TotalSize / (1024 * 1024 * 1024);
}
}
return totalSize;
}
/// <summary>
/// 获取指定驱动器的剩余空间总大小(单位为B)
/// </summary>
/// <param name="str_HardDiskName">只需输入代表驱动器的字母即可 (大写)</param>
/// <returns></returns>
public static double GetHardDiskFreeSpace(string str_HardDiskName)
{
double freeSpace = new long();
str_HardDiskName = str_HardDiskName + ":\\";
System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives();
foreach (System.IO.DriveInfo drive in drives)
{
if (drive.Name == str_HardDiskName)
{
freeSpace = drive.TotalFreeSpace / (1024 * 1024 * 1024);
}
}
return freeSpace;
}
#endregion
#region 获取时间戳
/// <summary>
/// 获取时间戳
/// </summary>
/// <returns></returns>
public static long GetTimeStamp()
{
TimeSpan ts = DateTime.Now - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalSeconds);
}
#endregion
#region 深度复制对象
/// <summary>
/// 深度复制对象
/// </summary>
/// <typeparam name="T"></typeparam>
/// <param name="Coperobj"></param>
/// <returns></returns>
public static T FeiyuCoper<T>(T Coperobj)
{
T a = System.Activator.CreateInstance<T>();
try
{
string json = ObjToJson(Coperobj);
if (!string.IsNullOrEmpty(json))
{
a = JsonToObj<T>(json);
}
}
catch
{
}
return a;
}
#endregion
}
}

275
Community/SqlHelpers.cs Normal file
View File

@ -0,0 +1,275 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Community
{
/// <summary>
/// 数据库帮助类
/// </summary>
public class SqlHelpers
{
/// <summary>
/// Appconfig中用于连接数据库的字符串
/// </summary>
private static string connStr = ConfigurationManager.ConnectionStrings["MydbConnstr"].ConnectionString;
static SqlConnection conn = new SqlConnection(connStr);
/// <summary>
/// 数据库执行操作的方法,只返回受影响的行数
/// </summary>
/// <param name="sql"></param>
/// <param name="parameter"></param>
/// <returns></returns>
public static int ExecuteNonQuery(string sql, params SqlParameter[] parameter)
{
//using (SqlConnection conn = new SqlConnection(connStr))
//{
// conn.Open();
// using (SqlCommand cmd = new SqlCommand(sql, conn))
// {
// cmd.Parameters.AddRange(parameter);
// return cmd.ExecuteNonQuery();
// }
//}
if (ConnectOpen())
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
return cmd.ExecuteNonQuery();
}
}
else
{
return 0;
}
}
public static int ExecuteNonQuery(CommandType type, string sql, params SqlParameter[] parameter)
{
//using (SqlConnection conn = new SqlConnection(connStr))
//{
// conn.Open();
// using (SqlCommand cmd = new SqlCommand(sql, conn))
// {
// cmd.Parameters.AddRange(parameter);
// cmd.CommandType = type;
// return cmd.ExecuteNonQuery();
// }
//}
if (ConnectOpen())
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
cmd.CommandType = type;
return cmd.ExecuteNonQuery();
}
}
else
{
return 0;
}
}
/// <summary>
/// 查询获取单个结果集的方法
/// </summary>
/// <param name="sql"></param>
/// <param name="parameter"></param>
/// <returns></returns>
public static object ExecuteScalar(string sql, params SqlParameter[] parameter)
{
//using (SqlConnection conn = new SqlConnection(connStr))
//{
// conn.Open();
// using (SqlCommand cmd = new SqlCommand(sql, conn))
// {
// cmd.Parameters.AddRange(parameter);
// return cmd.ExecuteScalar();
// }
//}
if (ConnectOpen())
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
return cmd.ExecuteScalar();
}
}
else
{
return 0;
}
}
public static object ExecuteScalar(CommandType type, string sql, params SqlParameter[] parameter)
{
//using (SqlConnection conn = new SqlConnection(connStr))
//{
// conn.Open();
// using (SqlCommand cmd = new SqlCommand(sql, conn))
// {
// cmd.Parameters.AddRange(parameter);
// cmd.CommandType = type;
// return cmd.ExecuteScalar();
// }
//}
if (ConnectOpen())
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddRange(parameter);
cmd.CommandType = type;
return cmd.ExecuteScalar();
}
}
else
{
return 0;
}
}
/// <summary>
/// 查询获取结果集的方法
/// </summary>
/// <param name="sql"></param>
/// <param name="paramaeter"></param>
/// <returns></returns>
public static DataTable ExecuteDataTable(string sql, params SqlParameter[] paramaeter)
{
//using (SqlConnection conn = new SqlConnection(connStr))
//{
// conn.Open();
// using (SqlCommand cmd = new SqlCommand(sql, conn))
// {
// cmd.Parameters.AddRange(paramaeter);
// SqlDataAdapter adapter = new SqlDataAdapter(cmd);
// DataSet dataset = new DataSet();
// adapter.Fill(dataset);
// return dataset.Tables[0];
// }
//}
if (ConnectOpen())
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddRange(paramaeter);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
return dataset.Tables[0];
}
}
else
{
return new DataTable();
}
}
/// <summary>
/// 查询获取结果集集合的方法
/// </summary>
/// <param name="sql"></param>
/// <param name="paramaeter"></param>
/// <returns></returns>
public static DataTableCollection ExecuteDataTableList(string sql, params SqlParameter[] paramaeter)
{
//using (SqlConnection conn = new SqlConnection(connStr))
//{
// conn.Open();
// using (SqlCommand cmd = new SqlCommand(sql, conn))
// {
// cmd.Parameters.AddRange(paramaeter);
// SqlDataAdapter adapter = new SqlDataAdapter(cmd);
// DataSet dataset = new DataSet();
// adapter.Fill(dataset);
// return dataset.Tables;
// }
//}
if (ConnectOpen())
{
using (SqlCommand cmd = new SqlCommand(sql, conn))
{
cmd.Parameters.AddRange(paramaeter);
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet dataset = new DataSet();
adapter.Fill(dataset);
return dataset.Tables;
}
}
else
{
return new DataSet().Tables;
}
}
/// <summary>
/// 数据库连接测试
/// </summary>
public static bool ConnectOpen()
{
bool bl = false;
try
{
if (conn.State != ConnectionState.Open)
{
conn.Open();
bl = true;
}
else
{
bl = true;
}
}
catch (Exception)
{
}
return bl;
}
}
}

3558
Community/Zmcaux.cs Normal file

File diff suppressed because it is too large Load Diff

1218
Community/adt8949.cs Normal file

File diff suppressed because it is too large Load Diff

111
Community/adtIO3224.cs Normal file
View File

@ -0,0 +1,111 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
namespace Community
{
public class adtIO3224
{
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_initial();
/************************************************
功能:初始化运动控制卡
(1)返回值>0时,表示adt-IO3224卡的数量。如果为3,则下面的可用卡号可通过拨码开关设置;
(2)返回值=0时,说明没有安装adt-IO3224卡;
(3)返回值<0时,-1 表示没有安装端口驱动程序,
-2 表示PCI桥存在故障。
-3 表示拨码开关设置存在重复。
************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_get_lib_version(Int32 cardno);
/************************************************
功能:获取当前库版本号
返回值为库版本的版本号;-1:卡号错误
************************************************/
[DllImport("adtIO3224.dll")]
public static extern float adtIO3224_get_hardware_ver(Int32 cardno);
/**************功能:获取当前硬件版本**************
返回值为硬件版本号;-1:卡号错误
************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_get_card_index();
/************************************************
功能:获取当前所有可用卡的拨码开关号,通过位数表示
比如:只有1张卡,拨码开关设置为1,则返回值为1
有2张卡,按照靠近CPU的顺序,拨码开关依次设置为1,2,返回值为21;
有3张卡,按照靠近CPU的顺序,拨码开关设置为3,1,2,则返回值为213;
返回值:可用卡的拨码开关号;-1:卡号错误
************************************************/
//-------------------------------------------------//
// 开关量输入输出类 //
//-------------------------------------------------//
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_read_bit(Int32 cardno, Int32 number);
/*********************************************************
功能:读取单个输入点
参数:
cardno 卡号
number 输入点(0-32)
返回值 0:低电平 1:高电平 -1:错误
*********************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_write_bit(Int32 cardno, Int32 number, Int32 value);
/********************************************************
功能:写单个输出
参数:
cardno 卡号
number 输出点(0-24)
value 0: 低电平 1: 高电平
返回值 0:正确 1:错误
*********************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_get_out(Int32 cardno, Int32 number);
/**********************************
功能:获取输出状态
参数:
cardno 卡号
number 端口号(0-24)
返回值:获取端口的当前状态,0: 低电平 1: 高电平 -1表示参数错误
************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_read_in(Int32 cardno, out Int32 value);
/*********************************************************
功能:读取所有32个输入点
参数:
cardno 卡号
value 存储32个输入点状态值,通过二进制32位上的0,1表示:0表示低电平,1表示高电平
返回值 0:正确 1:错误
*********************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_read_out(Int32 cardno, out Int32 value);
/*********************************************************
功能:读取所有24个输出点
参数:
cardno 卡号
value 24个输入点状态值,通过二进制低24位的0,1表示:0表示输出为低电平,1表示输出为高电平
返回值 0:正确 1:错误
*********************************************************/
[DllImport("adtIO3224.dll")]
public static extern Int32 adtIO3224_write_out(Int32 cardno, out Int32 value);
/*********************************************************
功能:写所有24个输出点
参数:
cardno 卡号
value 24个输入点状态值,通过二进制低24位的0,1表示:0表示写低电平,1表示写高电平
返回值 0:正确 1:错误
*********************************************************/
}
}

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ControlzEx" version="4.3.2" targetFramework="net452" requireReinstallation="true" />
<package id="MahApps.Metro" version="2.2.0" targetFramework="net452" requireReinstallation="true" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.19" targetFramework="net452" />
</packages>

91
DAL/DAL.csproj Normal file
View File

@ -0,0 +1,91 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{189029A5-B035-4838-994B-F408EB9776F4}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>DAL</RootNamespace>
<AssemblyName>DAL</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
<PlatformTarget>x64</PlatformTarget>
</PropertyGroup>
<ItemGroup>
<Reference Include="ControlzEx, Version=4.0.0.0, Culture=neutral, PublicKeyToken=69f1c32f803d307e, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.4.3.2\lib\net45\ControlzEx.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MahApps.Metro, Version=2.0.0.0, Culture=neutral, PublicKeyToken=51482d6f650b2b3f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.2.2.0\lib\net452\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
<Reference Include="System" />
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Core" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Xaml" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xml" />
<Reference Include="WindowsBase" />
</ItemGroup>
<ItemGroup>
<Compile Include="MainWindowDAL.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="VisualDAL.cs" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Community\Community.csproj">
<Project>{40bd9b86-2281-4e16-bfab-558cb18e873c}</Project>
<Name>Community</Name>
</ProjectReference>
<ProjectReference Include="..\Model\Model.csproj">
<Project>{7ec8f22d-631c-4b92-8d55-4b0f32d9318d}</Project>
<Name>Model</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

1762
DAL/MainWindowDAL.cs Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("DAL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DAL")]
[assembly: AssemblyCopyright("Copyright © 2017")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("189029a5-b035-4838-994b-f408eb9776f4")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

822
DAL/VisualDAL.cs Normal file
View File

@ -0,0 +1,822 @@
using Community;
using Model;
using Model.Vision;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Data.OleDb;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DAL
{
/// <summary>
/// 视觉DAL
/// </summary>
public class VisualDAL
{
#region 1、相机参数相关
#region 1、读取相机参数
/// <summary>
/// 获取所有相机
/// </summary>
/// <returns></returns>
public List<FeiYuCamere> GetCameraList()
{
string sqlstr = "select * from Camera ";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr);
return TableToCameraList(table);
}
private List<FeiYuCamere> TableToCameraList(DataTable table)
{
List<FeiYuCamere> list = new List<FeiYuCamere>();
FeiYuCamere camere;
foreach (DataRow row in table.Rows)
{
int br = (int)row["CamBrand"];
if (br == 1)
{
camere = new BaslerCamera();
}
else
{
camere = new HikCamera();
}
camere.ID = (int)row["ID"];
camere.VisualName = row["VisualName"].ToString();
camere.MachineID = (int)row["MachineID"];
camere.CamType = (int)row["CamType"];
camere.Img_Height = (int)row["Img_Height"];
camere.Img_Width = (int)row["Img_Width"];
camere.CamName = row["CamName"].ToString();
camere.CamBrand = (int)row["CamBrand"];
camere.ExposureTime = Convert.ToInt64(row["ExposureTime"]);
camere.FPS = Convert.ToInt32(row["FPS"]);
camere.Gain = (int)row["Gain"];
camere.SaveImangeOK = Convert.ToBoolean(row["SaveImangeOK"]);
camere.SaveImangeNG = Convert.ToBoolean(row["SaveImangeNG"]);
camere.SaveImageOri = Convert.ToBoolean(row["SaveImageOri"]);
list.Add(camere);
}
return list;
}
/// <summary>
/// 获取相机对象
/// </summary>
/// <param name="machineID">机种ID</param>
/// <param name="CamType">相机类型</param>
/// <returns></returns>
public FeiYuCamere GetCamera(int machineID, int CamType)
{
string sqlstr = "select * from Camera where MachineID=@MachineID and CamType=@CamType";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@MachineID", machineID), new OleDbParameter("@CamType", CamType));
return CamereaDatataleToList(table, CamType);
}
private FeiYuCamere CamereaDatataleToList(DataTable table, int camtype)
{
FeiYuCamere cam = null;
if (table.Rows.Count > 0)
{
DataRow row = table.Rows[0];
if ((int)row["CamBrand"] == 1)
{
cam = new BaslerCamera() { CamType = camtype };
}
else
{
cam = new HikCamera() { CamType = camtype };
}
cam.ID = (int)row["ID"];
cam.MachineID = (int)row["MachineID"];
cam.CamType = (int)row["CamType"];
cam.Img_Height = (int)row["Img_Height"];
cam.Img_Width = (int)row["Img_Width"];
cam.CamName = row["CamName"].ToString();
cam.CamBrand = (int)row["CamBrand"];
cam.ExposureTime = Convert.ToInt64(row["ExposureTime"]);
cam.FPS = Convert.ToInt32(row["FPS"]);
cam.Gain = (int)row["Gain"];
cam.SaveImangeOK = Convert.ToBoolean(row["SaveImangeOK"]);
cam.SaveImangeNG = Convert.ToBoolean(row["SaveImangeNG"]);
cam.SaveImageOri = Convert.ToBoolean(row["SaveImageOri"]);
}
return cam;
}
#endregion
#region 2、新增相机参数
/// <summary>
/// 新增相机参数
/// </summary>
public int AddCamera(FeiYuCamere cam)
{
try
{
string sqlstr = "insert into Camera ([MachineID],[CamType],CamName,FPS,ExposureTime,Gain,Img_Width,Img_Height,SaveImangeOK,SaveImangeNG,SaveImageOri)values(@MachineID,@CamType,@CamName,@FPS,@ExposureTime,@Gain,@Img_Width,@Img_Height,@SaveImangeOK,@SaveImangeNG,@SaveImageOri)";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@MachineID", cam.MachineID),
new OleDbParameter("@CamType", cam.CamType),
new OleDbParameter("@CamName", cam.CamName),
new OleDbParameter("@FPS", cam.FPS),
new OleDbParameter("@ExposureTime", cam.ExposureTime),
new OleDbParameter("@Gain", cam.Gain),
new OleDbParameter("@Img_Width", cam.Img_Width),
new OleDbParameter("@Img_Height", cam.Img_Height),
new OleDbParameter("@SaveImangeOK", cam.SaveImangeOK),
new OleDbParameter("@SaveImangeNG", cam.SaveImangeNG),
new OleDbParameter("@SaveImageOri", cam.SaveImageOri));
}
catch (Exception)
{
return 0;
}
}
#endregion
#region 3、更新相机参数
/// <summary>
/// 更新相机参数
/// </summary>
/// <param name="cam"></param>
/// <returns></returns>
public int UpdateCamera(FeiYuCamere cam)
{
try
{
string sqlstr = "update Camera set [MachineID]=@MachineID,[CamType]=@CamType,CamName=@CamName,FPS=@FPS,ExposureTime=@ExposureTime,Gain=@Gain,Img_Width=@Img_Width,Img_Height=@Img_Height,SaveImangeOK=@SaveImangeOK,SaveImangeNG=@SaveImangeNG,SaveImageOri=@SaveImageOri where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@MachineID", cam.MachineID),
new OleDbParameter("@CamType", cam.CamType),
new OleDbParameter("@CamName", cam.CamName),
new OleDbParameter("@FPS", cam.FPS),
new OleDbParameter("@ExposureTime", cam.ExposureTime),
new OleDbParameter("@Gain", cam.Gain),
new OleDbParameter("@Img_Width", cam.Img_Width),
new OleDbParameter("@Img_Height", cam.Img_Height),
new OleDbParameter("@SaveImangeOK", cam.SaveImangeOK),
new OleDbParameter("@SaveImangeNG", cam.SaveImangeNG),
new OleDbParameter("@SaveImageOri", cam.SaveImageOri),
new OleDbParameter("@ID", cam.ID));
}
catch (Exception)
{
return 0;
}
}
#endregion
#endregion
#region 区域模型
#region 一、根据机种ID获取区域模型
/// <summary>
/// 根据项目ID及区域类型获取区域模型
/// </summary>
/// <param name="machineID">机种ID</param>
/// <param name="modelTye">模型区域类型</param>
/// <returns></returns>
public ObservableCollection<V_RectangleModel> GetAllRecangleModelList(int machineID, int modelTye)
{
string sqlstr = "select * from V_RectangleModel where VeiID=@VeiID and AreaType=@AreaType ORDER BY ID";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@MachineID", machineID),
new OleDbParameter("@AreaType", modelTye));
return TableToRecangleModelList(table);
}
/// <summary>
/// 根据工程项目ID区域模型集合
/// </summary>
/// <param name="veiID">工程项目功能ID</param>
/// <returns></returns>
public ObservableCollection<V_RectangleModel> GetAllRecangleModelList(int veiID)
{
string sqlstr = "select * from V_RectangleModel where VeiID=@VeiID ORDER BY ID";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@MachineID", veiID));
return TableToRecangleModelList(table);
}
/// <summary>
/// 据工程项目功能ID区域模型
/// </summary>
/// <param name="veiID">工程项目功能ID</param>
/// <param name="areaType">区域类型</param>
/// <returns></returns>
public V_RectangleModel GetRectangleModel(int veiID, int areaType)
{
string sqlstr = "select * from V_RectangleModel where VeiID=@VeiID and AreaType=@AreaType ORDER BY ID";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@MachineID", veiID),
new OleDbParameter("@AreaType", areaType));
if (table.Rows.Count <= 0)
{
return new V_RectangleModel() { VeiID = veiID, AreaType = areaType };
}
else
{
return TableToRecangleModelList(table)[0];
}
}
private ObservableCollection<V_RectangleModel> TableToRecangleModelList(DataTable table)
{
ObservableCollection<V_RectangleModel> list = new ObservableCollection<V_RectangleModel>();
if (table == null || table.Rows.Count <= 0)
{
return list;
}
foreach (DataRow row in table.Rows)
{
V_RectangleModel rm = new V_RectangleModel();
rm.ID = (int)(row["ID"]);
rm.VeiID = Convert.ToInt32(row["VeiID"]);
rm.AreaType = Convert.ToInt32(row["AreaType"]);
rm.Point_Column1 = Convert.ToDouble(row["Point_Column1"]);
rm.Point_Column2 = Convert.ToDouble(row["Point_Column2"]);
rm.Point_Row1 = Convert.ToDouble(row["Point_Row1"]);
rm.Point_Row2 = Convert.ToDouble(row["Point_Row2"]);
rm.PassagewayBrightness1 = Convert.ToInt32(row["PassagewayBrightness1"]);
rm.PassagewayBrightness2 = Convert.ToInt32(row["PassagewayBrightness2"]);
rm.PassagewayBrightness3 = Convert.ToInt32(row["PassagewayBrightness3"]);
rm.PassagewayBrightness4 = Convert.ToInt32(row["PassagewayBrightness4"]);
rm.MyROI = GetROI(rm.ID, 1);
rm.MyRoiList = GetROIList(rm.ID, 2);
list.Add(rm);
}
return list;
}
#endregion
#region 1、更新模型
/// <summary>
/// 更新模型
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int UpdateRectangleModel(V_RectangleModel model)
{
try
{
if (model.ID > 0)
{
string sqlstr = "update V_RectangleModel set Point_Row1=@Point_Row1,Point_Column1=@Point_Column1,Point_Row2=@Point_Row2,Point_Column2=@Point_Column2,PassagewayBrightness1=@PassagewayBrightness1,PassagewayBrightness2=@PassagewayBrightness2,PassagewayBrightness3=@PassagewayBrightness3,PassagewayBrightness4=@PassagewayBrightness4 where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@Point_Row1", model.Point_Row1),
new OleDbParameter("@Point_Column1", model.Point_Column1),
new OleDbParameter("@Point_Row2", model.Point_Row2),
new OleDbParameter("@Point_Column2", model.Point_Column2),
new OleDbParameter("@PassagewayBrightness1", model.PassagewayBrightness1),
new OleDbParameter("@PassagewayBrightness2", model.PassagewayBrightness2),
new OleDbParameter("@PassagewayBrightness3", model.PassagewayBrightness3),
new OleDbParameter("@PassagewayBrightness4", model.PassagewayBrightness4),
new OleDbParameter("@ID", model.ID));
}
else
{
return AddRectangleModel(model);
}
}
catch (Exception ex)
{
string str = ex.ToString();
return 0;
}
}
#endregion
#region 2、新增模型
/// <summary>
/// 新增模型
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public int AddRectangleModel(V_RectangleModel model)
{
try
{
string sqlstr = "insert into V_RectangleModel (VeiID,AreaType,Point_Row1,Point_Column1,Point_Row2,Point_Column2)values(@MachineID,@AreaType,@Point_Row1,@Point_Column1,@Point_Row2,@Point_Column2)";
int a = AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@VeiID", model.VeiID),
new OleDbParameter("@AreaType", model.AreaType),
new OleDbParameter("@Point_Row1", model.Point_Row1),
new OleDbParameter("@Point_Column1", model.Point_Column1),
new OleDbParameter("@Point_Row2", model.Point_Row2),
new OleDbParameter("@Point_Column2", model.Point_Column2));
if (a > 0)
{
model.ID = GetInsertID();
}
return a;
}
catch (Exception)
{
return 0;
}
}
#endregion
#region 3、删除产品模型
/// <summary>
/// 删除产品区域模型
/// </summary>
/// <param name="model"></param>
public int DelModelDAL(V_RectangleModel model)
{
try
{
DelROI(model.MyROI);
if (model.MyRoiList != null)
{
foreach (V_ROI roi in model.MyRoiList)
{
DelROI(roi);
}
}
}
catch (Exception)
{
}
string sqlstr = "delete from V_RectangleModel where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@ID", model.ID));
}
#endregion
#region 二、根据区域模型ID获取全部ROI
/// <summary>
/// 根据区域模型ID获取ROI集合
/// </summary>
/// <param name="modelID">区域模型ID</param>
/// <param name="ROIType">ROI类型</param>
/// <returns></returns>
public ObservableCollection<V_ROI> GetROIList(int modelID, int ROIType)
{
string sqlstr = "select * from V_ROI where ModelID=@ModelID and ROIType=@ROIType ORDER BY ID";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@ModelID", modelID),
new OleDbParameter("@ROIType", ROIType));
return DataTableRecangleToList(table);
}
/// <summary>
/// 根据产品区域模型ID获取全部ROI
/// </summary>
/// <param name="modelID"></param>
/// <param name="ROIType"></param>
/// <returns></returns>
public V_ROI GetROI(int modelID, int ROIType)
{
string sqlstr = "select * from V_ROI where ModelID=@ModelID and ROIType=@ROIType";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@ModelID", modelID),
new OleDbParameter("@ROIType", ROIType));
if (table.Rows.Count > 0)
{
return DataTableRecangleToList(table)[0];
}
else
{
return new V_ROI() { ModelID = modelID };
}
}
private ObservableCollection<V_ROI> DataTableRecangleToList(DataTable table)
{
ObservableCollection<V_ROI> list = new ObservableCollection<V_ROI>();
if (table == null || table.Rows.Count <= 0)
{
return list;
}
foreach (DataRow row in table.Rows)
{
V_ROI va = new V_ROI();
va.ID = (int)row["ID"];
va.ModelID = (int)row["ModelID"];
va.CodeTypeID = (int)(row["CodeTypeID"]);
va.CodeStr = Convert.ToString(row["CodeStr"]);
va.MultiCode = Convert.ToBoolean(row["MultiCode"]);
va.ROIType = (int)row["ROIType"];
va.hv_Column = Convert.ToDouble(row["hv_Column"]);
va.hv_Column1 = Convert.ToDouble(row["hv_Column1"]);
va.hv_Row = Convert.ToDouble(row["hv_Row"]);
va.hv_Row1 = Convert.ToDouble(row["hv_Row1"]);
va.hv_Phi = Convert.ToDouble(row["hv_Phi"]);
va.hv_length1 = Convert.ToDouble(row["hv_length1"]);
va.hv_length2 = Convert.ToDouble(row["hv_length2"]);
va.hv_Radius = Convert.ToDouble(row["hv_Radius"]);
va.RoiShape = (DrawRoiEmn)Enum.Parse(typeof(DrawRoiEmn), row["RoiShape"].ToString());//Convert.ToBoolean(row["InCircleROI"]);
va.RecognitionCoefficient = Math.Round(Convert.ToDouble(row["RecognitionCoefficient"]), 1);
va.ModelFeaturePiont.hv_RefRow = Convert.ToDouble(row["hv_RefRow"]);
va.ModelFeaturePiont.hv_RefColumn = Convert.ToDouble(row["hv_RefColumn"]);
va.HelpFileName = row["HelpFileName"].ToString();
va.Enable = Convert.ToBoolean(row["Enable"]);
va.Notes = row["Notes"].ToString();
va.MeasurePar = row["MeasurePar"].ToString();
va.ThresholdMin = (int)row["ThresholdMin"];
va.ThresholdMax = (int)row["ThresholdMax"];
va.ShapeA_Min = (int)row["ShapeA_Min"];
va.ShapeA_Max = (int)row["ShapeA_Max"];
va.ShapeB_Min = (int)row["ShapeB_Min"];
va.ShapeB_Max = (int)row["ShapeB_Max"];
va.ShapeC_Min = (int)row["ShapeC_Min"];
va.ShapeC_Max = (int)row["ShapeC_Max"];
va.ShapeD_Min = (int)row["ShapeD_Min"];
va.ShapeD_Max = (int)row["ShapeD_Max"];
list.Add(va);
}
return list;
}
#endregion
#region 1、更新ROI
/// <summary>
/// 更新ROI
/// </summary>
/// <param name="roi"></param>
public int UpdateROI(V_ROI roi)
{
try
{
if (roi.ID > 0)
{
string sqlstr = "update V_ROI set ModelID=@ModelID,CodeTypeID=@CodeTypeID,CodeStr=@CodeStr,MultiCode=@MultiCode,hv_Row=@hv_Row,hv_Row1=@hv_Row1,hv_Column=@hv_Column,hv_Column1=@hv_Column1,hv_Phi=@hv_Phi,hv_length1=@hv_length1,hv_length2=@hv_length2,hv_Radius=@hv_Radius,RoiShape=@RoiShape,RecognitionCoefficient=@RecognitionCoefficient,hv_RefRow=@hv_RefRow,hv_RefColumn=@hv_RefColumn,HelpFileName=@HelpFileName,Enable=@Enable,Notes=@Notes,MeasurePar=@MeasurePar,ThresholdMin=@ThresholdMin,ThresholdMax=@ThresholdMax,ShapeA_Min=@ShapeA_Min,ShapeA_Max=@ShapeA_Max,ShapeB_Min=@ShapeB_Min,ShapeB_Max=@ShapeB_Max,ShapeC_Min=@ShapeC_Min,ShapeC_Max=@ShapeC_Max,ShapeD_Min=@ShapeD_Min,ShapeD_Max=@ShapeD_Max where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@ModelID", roi.ModelID),
new OleDbParameter("@CodeTypeID", roi.CodeTypeID),
new OleDbParameter("@CodeStr", roi.CodeStr),
new OleDbParameter("@MultiCode", roi.MultiCode),
new OleDbParameter("@hv_Row", roi.hv_Row),
new OleDbParameter("@hv_Row1", roi.hv_Row1),
new OleDbParameter("@hv_Column", roi.hv_Column),
new OleDbParameter("@hv_Column1", roi.hv_Column1),
new OleDbParameter("@hv_Phi", roi.hv_Phi),
new OleDbParameter("@hv_length1", roi.hv_length1),
new OleDbParameter("@hv_length2", roi.hv_length2),
new OleDbParameter("@hv_Radius", roi.hv_Radius),
new OleDbParameter("@RoiShape", roi.RoiShape),
new OleDbParameter("@RecognitionCoefficient", roi.RecognitionCoefficient),
new OleDbParameter("@hv_RefRow", roi.ModelFeaturePiont.hv_RefRow),
new OleDbParameter("@hv_RefColumn", roi.ModelFeaturePiont.hv_RefColumn),
new OleDbParameter("@HelpFileName", roi.HelpFileName),
new OleDbParameter("@Enable", roi.Enable),
new OleDbParameter("@Notes", roi.Notes),
new OleDbParameter("@MeasurePar", roi.MeasurePar),
new OleDbParameter("@ThresholdMin", roi.ThresholdMin),
new OleDbParameter("@ThresholdMax", roi.ThresholdMax),
new OleDbParameter("@ShapeA_Min", roi.ShapeA_Min),
new OleDbParameter("@ShapeA_Max", roi.ShapeA_Max),
new OleDbParameter("@ShapeB_Min", roi.ShapeB_Min),
new OleDbParameter("@ShapeB_Max", roi.ShapeB_Max),
new OleDbParameter("@ShapeC_Min", roi.ShapeC_Min),
new OleDbParameter("@ShapeC_Max", roi.ShapeC_Max),
new OleDbParameter("@ShapeD_Min", roi.ShapeD_Min),
new OleDbParameter("@ShapeD_Max", roi.ShapeD_Max),
new OleDbParameter("@ID", roi.ID));
}
else
{
return AddRectangleROI(roi);
}
}
catch (Exception)
{
return 0;
}
}
#endregion
#region 2、新增矩形ROI
/// <summary>
/// 新增ROI
/// </summary>
/// <param name="ROI"></param>
/// <returns></returns>
public int AddRectangleROI(V_ROI ROI)
{
try
{
string sqlstr = "insert into V_ROI (ModelID,ROIType,CodeTypeID,CodeStr,MultiCode,hv_Row,hv_Row1,hv_Column,hv_Column1,hv_Phi,hv_length1,hv_length2,hv_Radius,RoiShape,RecognitionCoefficient,hv_RefRow,hv_RefColumn,HelpFileName,Enable,Notes,MeasurePar,ThresholdMin,ThresholdMax,ShapeA_Min,ShapeA_Max,ShapeB_Min,ShapeB_Max,ShapeC_Min,ShapeC_Max,ShapeD_Min,ShapeD_Max)values(@ModelID,@ROIType,@CodeTypeID,@CodeStr,@MultiCode,@hv_Row,@hv_Row1,@hv_Column,@hv_Column1,@hv_Phi,@hv_length1,@hv_length2,@hv_Radius,@RoiShape,@RecognitionCoefficient,@hv_RefRow,@hv_RefColumn,@HelpFileName,@Enable,@Notes,@MeasurePar,@ThresholdMin,@ThresholdMax,@ShapeA_Min,@ShapeA_Max,@ShapeB_Min,@ShapeB_Max,@ShapeC_Min,@ShapeC_Max,@ShapeD_Min,@ShapeD_Max)";
int a= AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@ModelID", ROI.ModelID),
new OleDbParameter("@ROIType", ROI.ROIType),
new OleDbParameter("@CodeTypeID", ROI.CodeTypeID),
new OleDbParameter("@CodeStr", ROI.CodeStr),
new OleDbParameter("@MultiCode", ROI.MultiCode),
new OleDbParameter("@hv_Row", ROI.hv_Row),
new OleDbParameter("@hv_Row1", ROI.hv_Row1),
new OleDbParameter("@hv_Column", ROI.hv_Column),
new OleDbParameter("@hv_Column1", ROI.hv_Column1),
new OleDbParameter("@hv_Phi", ROI.hv_Phi),
new OleDbParameter("@hv_length1", ROI.hv_length1),
new OleDbParameter("@hv_length2", ROI.hv_length2),
new OleDbParameter("@hv_Radius", ROI.hv_Radius),
new OleDbParameter("@RoiShape", ROI.RoiShape),
new OleDbParameter("@RecognitionCoefficient", ROI.RecognitionCoefficient),
new OleDbParameter("@hv_RefRow", ROI.ModelFeaturePiont.hv_RefRow),
new OleDbParameter("@hv_RefColumn", ROI.ModelFeaturePiont.hv_RefColumn),
new OleDbParameter("@HelpFileName", ROI.HelpFileName),
new OleDbParameter("@Enable", ROI.Enable),
new OleDbParameter("@Notes", ROI.Notes),
new OleDbParameter("@MeasurePar", ROI.MeasurePar),
new OleDbParameter("@ThresholdMin", ROI.ThresholdMin),
new OleDbParameter("@ThresholdMax", ROI.ThresholdMax),
new OleDbParameter("@ShapeA_Min", ROI.ShapeA_Min),
new OleDbParameter("@ShapeA_Max", ROI.ShapeA_Max),
new OleDbParameter("@ShapeB_Min", ROI.ShapeB_Min),
new OleDbParameter("@ShapeB_Max", ROI.ShapeB_Max),
new OleDbParameter("@ShapeC_Min", ROI.ShapeC_Min),
new OleDbParameter("@ShapeC_Max", ROI.ShapeC_Max),
new OleDbParameter("@ShapeD_Min", ROI.ShapeD_Min),
new OleDbParameter("@ShapeD_Max", ROI.ShapeD_Max));
if(a>0)
{
ROI.ID = GetInsertID();
}
return a;
}
catch (Exception)
{
return 0;
}
}
#endregion
#region 3、删除矩形ROI
/// <summary>
/// 删除矩形ROI
/// </summary>
/// <param name="roi"></param>
/// <returns></returns>
public int DelROI(V_ROI roi)
{
try
{
string sqlstr = "delete from V_ROI where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@ID", roi.ID));
}
catch (Exception)
{
return 0;
}
}
#endregion
#endregion
#region 视觉工程项目相关
#region 1、获取视觉工程项目集合
/// <summary>
/// 获取视觉工程项目集合
/// </summary>
/// <param name="machineID">机种ID</param>
/// <param name="CamID">相机ID</param>
public ObservableCollection<VisualEngineering> GetVisualEngineeringList(int machineID, int CamID)
{
string sqlstr = "select * from VisualEngineering where MachineID=@MachineID and CameraID=@CameraID";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@MachineID", machineID),
new OleDbParameter("@CameraID", CamID));
return VisualEngineeringTableToList(table);
}
private ObservableCollection<VisualEngineering> VisualEngineeringTableToList(DataTable table)
{
ObservableCollection<VisualEngineering> list = new ObservableCollection<VisualEngineering>();
if (table == null || table.Rows.Count <= 0)
{
return list;
}
VisualEngineering ve;
foreach (DataRow row in table.Rows)
{
ve = new VisualEngineering();
ve.CameraID = Convert.ToInt32(row["CameraID"]);
ve.EName = row["EName"].ToString();
ve.ID = Convert.ToInt32(row["ID"]);
ve.MachineID = Convert.ToInt32(row["MachineID"]);
ve.MechanicalPointID = Convert.ToInt32(row["MechanicalPointID"]);
ve.Notes = row["Notes"].ToString();
ve.NType = Convert.ToInt32(row["NType"]);
ve.Enable = Convert.ToBoolean(row["Enable"]);
ve.VisualEngineeringItemsList = GetVisualEngineeringItemsList(ve.ID);
list.Add(ve);
}
return list;
}
#endregion
#region 2、新增视觉工程项目
/// <summary>
/// 新增视觉工程项目
/// </summary>
/// <param name="ve"></param>
/// <returns></returns>
public int AddVisualEngineering(VisualEngineering ve)
{
string sqlstr = "insert into VisualEngineering(MachineID,CameraID,EName,Notes,NType,MechanicalPointID,Enable)values(@MachineID,@CameraID,@EName,@Notes,@NType,@MechanicalPointID,@Enable)";
int a= AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@MachineID", ve.MachineID),
new OleDbParameter("@CameraID", ve.CameraID),
new OleDbParameter("@EName", ve.EName),
new OleDbParameter("@Notes", ve.Notes),
new OleDbParameter("@NType", ve.NType),
new OleDbParameter("@MechanicalPointID", ve.MechanicalPointID),
new OleDbParameter("@Enable", ve.Enable));
if(a>0)
{
ve.ID = GetInsertID();
}
return a;
}
#endregion
#region 3、更新视觉工程项目
/// <summary>
/// 更新视觉工程项目
/// </summary>
/// <param name="ve"></param>
/// <returns></returns>
public int UpdateVisualEngineering(VisualEngineering ve)
{
string sqlstr = "update VisualEngineering set MachineID=@MachineID,CameraID=@CameraID,EName=@EName,Notes=@Notes,NType=@NType,MechanicalPointID=@MechanicalPointID,Enable=@Enable where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@MachineID", ve.MachineID),
new OleDbParameter("@CameraID", ve.CameraID),
new OleDbParameter("@EName", ve.EName),
new OleDbParameter("@Notes", ve.Notes),
new OleDbParameter("@NType", ve.NType),
new OleDbParameter("@MechanicalPointID", ve.MechanicalPointID),
new OleDbParameter("@Enable", ve.Enable),
new OleDbParameter("@ID", ve.ID));
}
#endregion
#region 4、删除视觉工程项目
/// <summary>
/// 删除视觉工程项目
/// </summary>
/// <param name="ve"></param>
/// <returns></returns>
public int DelVisualEngineering(VisualEngineering ve)
{
try
{
if (ve.VisualEngineeringItemsList != null && ve.VisualEngineeringItemsList.Count > 0)
{
foreach (VisualEngineeringItems vei in ve.VisualEngineeringItemsList)
{
DelVisualEngineeringItems(vei);
}
}
string sqlstr = "delete from VisualEngineering where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@ID", ve.ID));
}
catch (Exception)
{
return 0;
}
}
#endregion
#endregion
#region 视觉工程项目功能相关
#region 1、获取视觉工程项目功能集合
/// <summary>
/// 获取视觉工程项目功能集合
/// </summary>
/// <param name="visualEngineeringID">视觉工程项目ID</param>
public ObservableCollection<VisualEngineeringItems> GetVisualEngineeringItemsList(int visualEngineeringID)
{
string sqlstr = "select * from VisualEngineeringItems where VisualEngineeringID=@VisualEngineeringID";
DataTable table = AccHelpers.ExecuteDataTable(sqlstr, new OleDbParameter("@VisualEngineeringID", visualEngineeringID));
return VisualEngineeringItemsTableToLsit(table);
}
private ObservableCollection<VisualEngineeringItems> VisualEngineeringItemsTableToLsit(DataTable table)
{
ObservableCollection<VisualEngineeringItems> list = new ObservableCollection<VisualEngineeringItems>();
if (table == null || table.Rows.Count <= 0)
{
return list;
}
VisualEngineeringItems vei;
foreach (DataRow row in table.Rows)
{
vei = new VisualEngineeringItems();
vei.HandleType = Convert.ToInt32(row["HandleType"]);
vei.ID = Convert.ToInt32(row["ID"]);
vei.Notes = row["Notes"].ToString();
vei.VEIname = row["VEIname"].ToString();
vei.VisualEngineeringID = Convert.ToInt32(row["VisualEngineeringID"]);
vei.Enable = Convert.ToBoolean(row["Enable"]);
vei.MyRectangleModel = GetRectangleModel(vei.ID, 1);
vei.ImageCorrectionRM = GetRectangleModel(vei.ID, 2);
list.Add(vei);
}
return list;
}
#endregion
#region 2、新增视觉项目功能
/// <summary>
/// 新增视觉项目功能
/// </summary>
/// <param name="vei"></param>
public int AddVisualEngineeringItems(VisualEngineeringItems vei)
{
string sqlstr = "insert into VisualEngineeringItems (VisualEngineeringID,HandleType,VEIname,Notes,Enable)values(@VisualEngineeringID,@HandleType,@VEIname,@Notes,@Enable)";
int a= AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@VisualEngineeringID", vei.VisualEngineeringID),
new OleDbParameter("@HandleType", vei.HandleType),
new OleDbParameter("@VEIname", vei.VEIname),
new OleDbParameter("@Notes", vei.Notes),
new OleDbParameter("@Enable", vei.Enable));
if(a>0)
{
vei.ID = GetInsertID();
}
return a;
}
#endregion
#region 3、更新视觉项目功能
/// <summary>
/// 更新视觉项目功能
/// </summary>
/// <param name="vei"></param>
/// <returns></returns>
public int UpdateVisualEngineeringItems(VisualEngineeringItems vei)
{
string sqlstr = "update VisualEngineeringItems set VisualEngineeringID=@VisualEngineeringID,HandleType=@HandleType,VEIname=@VEIname,Notes=@Notes,Enable=@Enable where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@VisualEngineeringID", vei.VisualEngineeringID),
new OleDbParameter("@HandleType", vei.HandleType),
new OleDbParameter("@VEIname", vei.VEIname),
new OleDbParameter("@Notes", vei.Notes),
new OleDbParameter("@Enable", vei.Enable),
new OleDbParameter("@ID", vei.ID));
}
#endregion
#region 4、视觉删除项目功能
/// <summary>
/// 视觉删除项目功能
/// </summary>
/// <param name="vei"></param>
/// <returns></returns>
public int DelVisualEngineeringItems(VisualEngineeringItems vei)
{
try
{
DelModelDAL(vei.MyRectangleModel);
DelModelDAL(vei.ImageCorrectionRM);
string sqlstr = "delete from VisualEngineeringItems where ID=@ID";
return AccHelpers.ExecuteNonQuery(sqlstr, new OleDbParameter("@ID", vei.ID));
}
catch (Exception)
{
return 0;
}
}
#endregion
#endregion
#region 获取插入数据后的ID(此方法必须用于 插入数据执行成功之后才有效)
/// <summary>
/// 获取插入数据后的ID(此方法必须用于 插入数据执行成功之后才有效)
/// </summary>
/// <returns></returns>
public int GetInsertID()
{
string sqlstr = "SELECT @@IDENTITY AS 'Id'";
object obj = AccHelpers.ExecuteScalar(sqlstr);
int a = Convert.ToInt32(obj);
return a;
}
#endregion
}
}

6
DAL/packages.config Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ControlzEx" version="4.3.2" targetFramework="net452" requireReinstallation="true" />
<package id="MahApps.Metro" version="2.2.0" targetFramework="net452" requireReinstallation="true" />
<package id="Microsoft.Xaml.Behaviors.Wpf" version="1.1.19" targetFramework="net452" />
</packages>

52
FeiYu.sln Normal file
View File

@ -0,0 +1,52 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FeiYu", "FeiYu\FeiYu.csproj", "{6C4B0F0C-9A52-42FC-B9AF-C26E965C85BC}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Community", "Community\Community.csproj", "{40BD9B86-2281-4E16-BFAB-558CB18E873C}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Views", "Views\Views.csproj", "{8DB056A3-3190-4310-8D27-4DAA1A1C11B4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DAL", "DAL\DAL.csproj", "{189029A5-B035-4838-994B-F408EB9776F4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Model", "Model\Model.csproj", "{7EC8F22D-631C-4B92-8D55-4B0F32D9318D}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ViewModel", "ViewModel\ViewModel.csproj", "{0BBBCA73-E902-497E-B629-68C7C88365BA}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6C4B0F0C-9A52-42FC-B9AF-C26E965C85BC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6C4B0F0C-9A52-42FC-B9AF-C26E965C85BC}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6C4B0F0C-9A52-42FC-B9AF-C26E965C85BC}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6C4B0F0C-9A52-42FC-B9AF-C26E965C85BC}.Release|Any CPU.Build.0 = Release|Any CPU
{40BD9B86-2281-4E16-BFAB-558CB18E873C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{40BD9B86-2281-4E16-BFAB-558CB18E873C}.Debug|Any CPU.Build.0 = Debug|Any CPU
{40BD9B86-2281-4E16-BFAB-558CB18E873C}.Release|Any CPU.ActiveCfg = Release|Any CPU
{40BD9B86-2281-4E16-BFAB-558CB18E873C}.Release|Any CPU.Build.0 = Release|Any CPU
{8DB056A3-3190-4310-8D27-4DAA1A1C11B4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8DB056A3-3190-4310-8D27-4DAA1A1C11B4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8DB056A3-3190-4310-8D27-4DAA1A1C11B4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8DB056A3-3190-4310-8D27-4DAA1A1C11B4}.Release|Any CPU.Build.0 = Release|Any CPU
{189029A5-B035-4838-994B-F408EB9776F4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{189029A5-B035-4838-994B-F408EB9776F4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{189029A5-B035-4838-994B-F408EB9776F4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{189029A5-B035-4838-994B-F408EB9776F4}.Release|Any CPU.Build.0 = Release|Any CPU
{7EC8F22D-631C-4B92-8D55-4B0F32D9318D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{7EC8F22D-631C-4B92-8D55-4B0F32D9318D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{7EC8F22D-631C-4B92-8D55-4B0F32D9318D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{7EC8F22D-631C-4B92-8D55-4B0F32D9318D}.Release|Any CPU.Build.0 = Release|Any CPU
{0BBBCA73-E902-497E-B629-68C7C88365BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0BBBCA73-E902-497E-B629-68C7C88365BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0BBBCA73-E902-497E-B629-68C7C88365BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0BBBCA73-E902-497E-B629-68C7C88365BA}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

20
FeiYu/App.config Normal file
View File

@ -0,0 +1,20 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>
</startup>
<connectionStrings>
<add name="dbConnstr" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Data\DataBase.accdb"/>
<add name="dbConnstr1" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Data\DataBase1.accdb"/>
<add name="dbConnstr2" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Data\DataBase2.accdb"/>
<!--<add name="dbConnstr1" connectionString="Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\23.accdb;Jet OLEDB:Database Password=123456" />-->
<add name="ITAssets.Properties.Settings.ITAssetsConnectionString" connectionString="Data Source=10.110.8.34;Initial Catalog=ITAssets;User ID=sa;Password=omron@01" providerName="System.Data.SqlClient"/>
<!--通讯连接IP-->
<add name="CommunicationIP" connectionString="192.168.20.88"/>
<!--通讯连接端口号-->
<add name="CommunicationPort" connectionString="16818"/>
<add name="CommunicationPort1" connectionString="2000"/>
</connectionStrings>
</configuration>

21
FeiYu/App.xaml Normal file
View File

@ -0,0 +1,21 @@
<Application x:Class="FeiYu.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:FeiYu"
StartupUri="MainWindow.xaml">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Controls.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Fonts.xaml" />
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Styles/Themes/Light.Blue.xaml" />
<!--自定义样式类-->
<ResourceDictionary Source="Styles.xaml"/>
<!--加载语言(默认英文)-->
<!--<ResourceDictionary Source="./Language/zh-cn.xaml"/>-->
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>

34
FeiYu/App.xaml.cs Normal file
View File

@ -0,0 +1,34 @@
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Threading.Tasks;
using System.Windows;
namespace FeiYu
{
/// <summary>
/// App.xaml 的交互逻辑
/// </summary>
public partial class App : Application
{
//protected override void OnStartup(StartupEventArgs e)
//{
// // get the current app style (theme and accent) from the application
// // you can then use the current theme and custom accent instead set a new theme
// Tuple<AppTheme, Accent> appStyle = ThemeManager.DetectAppStyle(Application.Current);
// // now set the Green accent and dark theme
// ThemeManager.ChangeAppStyle(Application.Current,
// ThemeManager.GetAccent("Green"),
// ThemeManager.GetAppTheme("BaseDark")); // or appStyle.Item1
// base.OnStartup(e);
//}
}
}

BIN
FeiYu/Data/DataBase.accdb Normal file

Binary file not shown.

287
FeiYu/FeiYu.csproj Normal file
View File

@ -0,0 +1,287 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{6C4B0F0C-9A52-42FC-B9AF-C26E965C85BC}</ProjectGuid>
<OutputType>WinExe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>FeiYu</RootNamespace>
<AssemblyName>FeiYu</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<ProjectTypeGuids>{60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
<WarningLevel>4</WarningLevel>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<PublishUrl>publish\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
<TargetFrameworkProfile />
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>Resources\logo1.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="Basler.Pylon, Version=1.1.0.0, Culture=neutral, PublicKeyToken=e389355f398382ab, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\Basler.Pylon.dll</HintPath>
</Reference>
<Reference Include="ControlzEx, Version=4.0.0.0, Culture=neutral, PublicKeyToken=69f1c32f803d307e, processorArchitecture=MSIL">
<HintPath>..\packages\ControlzEx.4.3.2\lib\net45\ControlzEx.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="halcondotnet">
<HintPath>C:\Program Files\MVTec\HALCON-17.12-Progress\bin\dotnet35\halcondotnet.dll</HintPath>
</Reference>
<Reference Include="MahApps.Metro, Version=2.0.0.0, Culture=neutral, PublicKeyToken=51482d6f650b2b3f, processorArchitecture=MSIL">
<HintPath>..\packages\MahApps.Metro.2.2.0\lib\net452\MahApps.Metro.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="Microsoft.Xaml.Behaviors, Version=1.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">
<HintPath>..\packages\Microsoft.Xaml.Behaviors.Wpf.1.1.19\lib\net45\Microsoft.Xaml.Behaviors.dll</HintPath>
<Private>True</Private>
</Reference>
<Reference Include="MvCameraControl.Net, Version=3.4.0.1, Culture=neutral, PublicKeyToken=52fddfb3f94be800, processorArchitecture=AMD64">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\MvCameraControl.Net.dll</HintPath>
</Reference>
<Reference Include="System">
<HintPath>C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.8\System.dll</HintPath>
</Reference>
<Reference Include="System.ComponentModel.DataAnnotations" />
<Reference Include="System.Configuration" />
<Reference Include="System.Data" />
<Reference Include="System.Web" />
<Reference Include="System.Web.Extensions" />
<Reference Include="System.Windows.Interactivity, Version=4.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>bin\Debug\System.Windows.Interactivity.dll</HintPath>
</Reference>
<Reference Include="System.Xml" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Core" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="System.Net.Http" />
<Reference Include="System.Xaml">
<RequiredTargetFramework>4.0</RequiredTargetFramework>
</Reference>
<Reference Include="WindowsBase" />
<Reference Include="PresentationCore" />
<Reference Include="PresentationFramework" />
</ItemGroup>
<ItemGroup>
<ApplicationDefinition Include="App.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</ApplicationDefinition>
<Compile Include="PwdAlter.xaml.cs">
<DependentUpon>PwdAlter.xaml</DependentUpon>
</Compile>
<Compile Include="PwdInput.xaml.cs">
<DependentUpon>PwdInput.xaml</DependentUpon>
</Compile>
<Compile Include="SoftSelect.xaml.cs">
<DependentUpon>SoftSelect.xaml</DependentUpon>
</Compile>
<Page Include="MainWindow.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Compile Include="App.xaml.cs">
<DependentUpon>App.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Compile Include="MainWindow.xaml.cs">
<DependentUpon>MainWindow.xaml</DependentUpon>
<SubType>Code</SubType>
</Compile>
<Page Include="PwdAlter.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="PwdInput.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\Icons.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Resources\IconsNonShared.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="SoftSelect.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
<Page Include="Styles.xaml">
<Generator>MSBuild:Compile</Generator>
<SubType>Designer</SubType>
</Page>
</ItemGroup>
<ItemGroup>
<Compile Include="Properties\AssemblyInfo.cs">
<SubType>Code</SubType>
</Compile>
<Compile Include="Properties\Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="Properties\Settings.Designer.cs">
<AutoGen>True</AutoGen>
<DependentUpon>Settings.settings</DependentUpon>
<DesignTimeSharedInput>True</DesignTimeSharedInput>
</Compile>
<EmbeddedResource Include="Properties\Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
<None Include="packages.config" />
<None Include="Properties\Settings.settings">
<Generator>SettingsSingleFileGenerator</Generator>
<LastGenOutput>Settings.Designer.cs</LastGenOutput>
</None>
<AppDesigner Include="Properties\" />
<None Include="Resources\LoginTip\Thumbs.db" />
<Resource Include="Resources\Entypo.ttf" />
</ItemGroup>
<ItemGroup>
<None Include="App.config">
<SubType>Designer</SubType>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\Community\Community.csproj">
<Project>{40bd9b86-2281-4e16-bfab-558cb18e873c}</Project>
<Name>Community</Name>
</ProjectReference>
<ProjectReference Include="..\DAL\DAL.csproj">
<Project>{189029a5-b035-4838-994b-f408eb9776f4}</Project>
<Name>DAL</Name>
</ProjectReference>
<ProjectReference Include="..\Model\Model.csproj">
<Project>{7ec8f22d-631c-4b92-8d55-4b0f32d9318d}</Project>
<Name>Model</Name>
</ProjectReference>
<ProjectReference Include="..\ViewModel\ViewModel.csproj">
<Project>{0bbbca73-e902-497e-b629-68c7c88365ba}</Project>
<Name>ViewModel</Name>
</ProjectReference>
<ProjectReference Include="..\Views\Views.csproj">
<Project>{8db056a3-3190-4310-8d27-4daa1a1c11b4}</Project>
<Name>Views</Name>
</ProjectReference>
</ItemGroup>
<ItemGroup>
<Resource Include="Resources\1.jpg" />
<Resource Include="Resources\10.jpg" />
<Resource Include="Resources\11.jpg" />
<Resource Include="Resources\12.jpg" />
<Resource Include="Resources\13.jpg" />
<Resource Include="Resources\14.jpg" />
<Resource Include="Resources\15.jpg" />
<Resource Include="Resources\16.jpg" />
<Resource Include="Resources\17.jpg" />
<Resource Include="Resources\18.jpg" />
<Resource Include="Resources\19.jpg" />
<Resource Include="Resources\2.jpg" />
<Resource Include="Resources\20.jpg" />
<Resource Include="Resources\21.jpg" />
<Resource Include="Resources\22.jpg" />
<Resource Include="Resources\3.jpg" />
<Resource Include="Resources\4.jpg" />
<Resource Include="Resources\5.jpg" />
<Resource Include="Resources\6.jpg" />
<Resource Include="Resources\7.jpg" />
<Resource Include="Resources\8.jpg" />
<Resource Include="Resources\9.jpg" />
<Resource Include="Resources\arrow.png" />
<Resource Include="Resources\Home_03.jpg" />
<Resource Include="Resources\Home_04.jpg" />
<Resource Include="Resources\log.png" />
<Resource Include="Resources\logo1.ico" />
</ItemGroup>
<ItemGroup>
<Content Include="Data\DataBase.accdb" />
<Resource Include="Resources\23.jpg" />
<Resource Include="Resources\24.jpg" />
<Resource Include="Resources\25.jpg" />
<Resource Include="Resources\26.jpg" />
<Resource Include="Resources\27.jpg" />
<Resource Include="Resources\28.jpg" />
<Resource Include="Resources\29.jpg" />
<Resource Include="Resources\30.jpg" />
<Resource Include="Resources\31.jpg" />
<Resource Include="Resources\32.jpg" />
<Resource Include="Resources\liteno.bmp" />
<Resource Include="Resources\LoginTip\close0.png" />
<Resource Include="Resources\LoginTip\close1.png" />
<Resource Include="Resources\LoginTip\cloud.png" />
<Resource Include="Resources\LoginTip\loginbody.png" />
<Resource Include="Resources\LoginTip\logo1.ico" />
<Resource Include="Resources\LoginTip\mini0.png" />
<Resource Include="Resources\LoginTip\mini1.png" />
<Resource Include="Resources\LoginTip\sun2.png" />
<Resource Include="Resources\LoginTip\yezi2.png" />
<Resource Include="Resources\LoginTip\yezi3.png" />
<Resource Include="Resources\LoginTip\zhuce.png" />
<Resource Include="Resources\LoginTip\zhuce_hover.png" />
<Resource Include="Resources\LoginTip\zhuce_press.png" />
<SplashScreen Include="StartIng.jpg" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5.2">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5.2 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>

64
FeiYu/MainWindow.xaml Normal file
View File

@ -0,0 +1,64 @@
<mah:MetroWindow xmlns:Vision="clr-namespace:Views.Vision;assembly=Views" x:Class="FeiYu.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mah="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:MyNamespace="clr-namespace:Views;assembly=Views"
xmlns:Motion="clr-namespace:Views.Motion;assembly=Views"
xmlns:local="clr-namespace:FeiYu"
mc:Ignorable="d"
Title="{Binding SystemPar.MachineName}" Height="1080" Width="1920" WindowStartupLocation="CenterScreen" Icon="Resources/logo1.ico" WindowState="Maximized" Closing="MetroWindow_Closing">
<mah:MetroWindow.Background>
<!--<ImageBrush ImageSource="Resources/3.jpg"/>-->
<ImageBrush ImageSource="{Binding SystemPar.SystemBackgroundPath}"/>
</mah:MetroWindow.Background>
<!--FontFamily="方正宋一繁体"-->
<mah:MetroWindow.RightWindowCommands>
<mah:WindowCommands>
<CheckBox Content="空跑模式" IsChecked="{Binding CurrentMachine.RunningMode}"></CheckBox>
<!--<CheckBox Content="联机空跑" IsChecked="{Binding RunningModePlas}"></CheckBox>-->
<!--<ComboBox Grid.Row="4" Grid.Column="5" VerticalContentAlignment="Center" Margin="1" Text="请选择串口" ItemsSource="{Binding LightCOM.ComPortList}" SelectedItem="{Binding SerialProt}"/>-->
<Button Content="切换主题" Click="SubjectSwitch" ></Button>
<Button Content="切换背景" Click="BackgroundSwitch" ></Button>
<Menu Background="{x:Null}">
<MenuItem Header="帮助" FontFamily="楷体" Background="{x:Null}" Foreground="White">
<MenuItem Name="menSystemSet" Header="{Binding PermissionButtonName}" Click="menSystemSet_Click" Background="AliceBlue" Foreground="Black"/>
<MenuItem Name="menPwdAlter" Header="修改密码" Click="menPwdAlter_Click" Background="AliceBlue" Visibility="{Binding AllVis}" Foreground="Black"/>
<MenuItem Header="生产数据清零" Background="AliceBlue" Foreground="Black" Visibility="{Binding AllVis}" Command="{Binding CountClearedCommand}"/>
<!--<CheckBox Content="不进行MES验证" IsChecked="{Binding MesCheck}" FontFamily="楷体"></CheckBox>
<CheckBox Content="不上传数据" IsChecked="{Binding NoUpData}" FontFamily="楷体"></CheckBox>-->
<ComboBox Background="#4CFFFFFF" ItemsSource="{Binding EnableMachineList}" DisplayMemberPath="MachineName" SelectedValuePath="ID" SelectedValue="{Binding CurrentMachineID}" VerticalAlignment="Center" HorizontalContentAlignment="Center" Height="26" ></ComboBox>
</MenuItem>
</Menu>
</mah:WindowCommands>
</mah:MetroWindow.RightWindowCommands>
<Grid>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="70*"></ColumnDefinition>
<!--<ColumnDefinition Width="1"></ColumnDefinition>-->
<ColumnDefinition Width="{Binding GridWidth}"></ColumnDefinition>
</Grid.ColumnDefinitions>
<TabControl Background="Transparent" ItemsSource="{Binding TabItemList}" SelectedItem="{Binding SelectTabItem}"></TabControl>
<!--<GridSplitter Grid.Column="1" Background="Transparent"></GridSplitter>-->
<Border Grid.Column="2">
<MyNamespace:ControlPanel />
</Border>
</Grid>
<!--<Grid Height="42" VerticalAlignment="Top">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Border Grid.Column="1" Height="42" Background="{Binding ShowStatu.StatusBackground}">
<TextBlock Text="{Binding ShowStatu.StatuInfo}" Tag="{Binding ShowStatu.StatuInfo}" FontSize="25" FontWeight="Bold" Foreground="{Binding ShowStatu.StatusForeground}" VerticalAlignment="Center" />
</Border>
</Grid>-->
</Grid>
</mah:MetroWindow>

151
FeiYu/MainWindow.xaml.cs Normal file
View File

@ -0,0 +1,151 @@

using ControlzEx.Theming;
using MahApps.Metro.Controls;
using MahApps.Metro.Controls.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using ViewModel;
using Views;
using Community;
using Model;
namespace FeiYu
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : MetroWindow
{
/// <summary>
/// 主逻辑对象
/// </summary>
MainWindowVM MVM { get; set; }
public MainWindow()
{
InitializeComponent();
MyMessageBox.MetroWin = this;
MVM = new MainWindowVM(this);
this.DataContext = MVM;
ThemeManager.Current.ChangeTheme(this, BackgroundThemeList[0] + "." + ThemeList[MVM.SystemPar.SystemTheme]);
}
/// <summary>
/// 切换系统设置模式
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menSystemSet_Click(object sender, RoutedEventArgs e)
{
if (MVM.AllVis == Visibility.Collapsed)
{
PwdInput pwdInput = new PwdInput();
pwdInput.DataContext = this.DataContext;
pwdInput.ShowDialog();
}
else
{
MVM.AllVis = Visibility.Collapsed;
MVM.SelectTabItem = MVM.TabItemList[0];
}
}
PwdAlter pwdAlter { get; set; }
/// <summary>
/// 密码修改
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void menPwdAlter_Click(object sender, RoutedEventArgs e)
{
pwdAlter = new PwdAlter();
pwdAlter.DataContext = this.DataContext;
pwdAlter.ShowDialog();
}
#region 切换主题
//主题色
List<string> ThemeList = new List<string>() { "Red", "Green", "Blue", "Purple", "Orange", "Lime", "Emerald", "Teal", "Cyan", "Cobalt", "Indigo", "Violet", "Pink", "Magenta", "Crimson", "Amber", "Yellow", "Brown", "Olive", "Steel", "Mauve", "Taupe", "Sienna" };
//背景色
List<string> BackgroundThemeList = new List<string>() { "Light", "Dark" };
/// <summary>
/// 切换主题
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void SubjectSwitch(object sender, RoutedEventArgs e)
{
if (MVM.SystemPar.SystemTheme == ThemeList.Count - 1)
{
MVM.SystemPar.SystemTheme = 0;
}
ThemeManager.Current.ChangeTheme(this, BackgroundThemeList[0] + "." + ThemeList[MVM.SystemPar.SystemTheme]);
MVM.SystemPar.SystemTheme++;
}
int systemBackgroundNumber = 0;
/// <summary>
/// 切换背景
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void BackgroundSwitch(object sender, RoutedEventArgs e)
{
systemBackgroundNumber++;
MVM.SystemPar.SystemBackgroundPath = @"Resources/" + systemBackgroundNumber + ".jpg";
if (systemBackgroundNumber >= 32)
{
systemBackgroundNumber = 0;
}
}
#endregion
private void MetroWindow_Closing(object sender, System.ComponentModel.CancelEventArgs e)
{
MVM.Close(0);
if (MVM.CloseRes == MessageDialogResult.Negative)
{
e.Cancel = true;
}
}
bool el = true;
/// <summary>
/// 切换语言
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void Button_Click(object sender, RoutedEventArgs e)
{
if (el)
{
Application.Current.Resources.MergedDictionaries[4].Source = new Uri(@"./Language/zh-cn.xaml", UriKind.RelativeOrAbsolute);
}
else
{
Application.Current.Resources.MergedDictionaries[4].Source = new Uri(@"./Language/en-us.xaml", UriKind.RelativeOrAbsolute);
}
el = !el;
}
}
}

View File

@ -0,0 +1,55 @@
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Windows;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("FeiYu")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FeiYu")]
[assembly: AssemblyCopyright("Copyright © 2020")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
//将 ComVisible 设置为 false 将使此程序集中的类型
//对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
//若要开始生成可本地化的应用程序,请
//<PropertyGroup> 中的 .csproj 文件中
//例如,如果您在源文件中使用的是美国英语,
//使用的是美国英语,请将 <UICulture> 设置为 en-US。 然后取消
//对以下 NeutralResourceLanguage 特性的注释。 更新
//以下行中的“en-US”以匹配项目文件中的 UICulture 设置。
//[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
[assembly: ThemeInfo(
ResourceDictionaryLocation.None, //主题特定资源词典所处位置
//(当资源未在页面
//或应用程序资源字典中找到时使用)
ResourceDictionaryLocation.SourceAssembly //常规资源词典所处位置
//(当资源未在页面
//、应用程序或任何主题专用资源字典中找到时使用)
)]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

63
FeiYu/Properties/Resources.Designer.cs generated Normal file
View File

@ -0,0 +1,63 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace FeiYu.Properties {
using System;
/// <summary>
/// 一个强类型的资源类,用于查找本地化的字符串等。
/// </summary>
// 此类是由 StronglyTypedResourceBuilder
// 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
// 若要添加或移除成员,请编辑 .ResX 文件,然后重新运行 ResGen
// (以 /str 作为命令选项),或重新生成 VS 项目。
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "17.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// 返回此类使用的缓存的 ResourceManager 实例。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("FeiYu.Properties.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// 重写当前线程的 CurrentUICulture 属性,对
/// 使用此强类型资源类的所有资源查找执行重写。
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
}
}

View File

@ -0,0 +1,117 @@
<?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.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: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" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
</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" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
</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>

26
FeiYu/Properties/Settings.Designer.cs generated Normal file
View File

@ -0,0 +1,26 @@
//------------------------------------------------------------------------------
// <auto-generated>
// 此代码由工具生成。
// 运行时版本:4.0.30319.42000
//
// 对此文件的更改可能会导致不正确的行为,并且如果
// 重新生成代码,这些更改将会丢失。
// </auto-generated>
//------------------------------------------------------------------------------
namespace FeiYu.Properties {
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.14.0.0")]
internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
public static Settings Default {
get {
return defaultInstance;
}
}
}
}

View File

@ -0,0 +1,7 @@
<?xml version='1.0' encoding='utf-8'?>
<SettingsFile xmlns="uri:settings" CurrentProfile="(Default)">
<Profiles>
<Profile Name="(Default)" />
</Profiles>
<Settings />
</SettingsFile>

32
FeiYu/PwdAlter.xaml Normal file
View File

@ -0,0 +1,32 @@
<Window x:Class="FeiYu.PwdAlter"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FeiYu"
mc:Ignorable="d"
Title="PwdAlter" Height="220" Width="600" WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize" Background="Transparent" WindowStartupLocation="CenterScreen">
<Grid Background="AliceBlue">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Label Content="密码修改" Grid.ColumnSpan="2" FontSize="30" FontWeight="Bold" Background="#CC119EDA" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></Label>
<Label Content="请输入原始密码" Grid.Row="1" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" FontWeight="Bold"></Label>
<Label Content="新密码" Grid.Row="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" FontWeight="Bold"></Label>
<Label Content="再次输入" Grid.Row="3" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" FontSize="20" FontWeight="Bold"></Label>
<PasswordBox Name="pbOutPwd" Margin="2" Grid.Row="1" Grid.Column="1" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></PasswordBox>
<PasswordBox Name="pbNewPwd1" Margin="2" Grid.Row="2" Grid.Column="1" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></PasswordBox>
<PasswordBox Name="pbNewPwd2" Margin="2" Grid.Row="3" Grid.Column="1" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></PasswordBox>
<Button Name="btnClose" Content="取消" Grid.Row="4" Margin="2" Click="btnClose_Click" IsCancel="True" FontFamily="楷体" FontSize="25" FontWeight="Bold"></Button>
<Button Name="btnOK" Content="确定" Grid.Row="4" Grid.Column="1" Margin="2" Click="btnOK_Click" IsDefault="True" FontFamily="楷体" FontSize="25" FontWeight="Bold"></Button>
</Grid>
</Window>

56
FeiYu/PwdAlter.xaml.cs Normal file
View File

@ -0,0 +1,56 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ViewModel;
namespace FeiYu
{
/// <summary>
/// PwdAlter.xaml 的交互逻辑
/// </summary>
public partial class PwdAlter : Window
{
public PwdAlter()
{
InitializeComponent();
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
MainWindowVM MW = this.DataContext as MainWindowVM;
string pwd = SoftwareValidation.MD5(pbOutPwd.Password.Trim());
if (pwd != MW.SystemPar.SystemPwd)
{
MessageBox.Show("原始密码错误");
return;
}
if (pbNewPwd1.Password.Trim() != pbNewPwd2.Password.Trim())
{
MessageBox.Show("两次密码输入不一致");
return;
}
string newPwd = SoftwareValidation.MD5(pbNewPwd1.Password.Trim());
MW.SystemPar.SystemPwd = newPwd;
MW.dal.UpdateSystemPWD(MW.SystemPar);
MessageBox.Show("密码更改成功,请牢记新密码");
this.Close();
}
}
}

24
FeiYu/PwdInput.xaml Normal file
View File

@ -0,0 +1,24 @@
<Window x:Class="FeiYu.PwdInput"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FeiYu"
mc:Ignorable="d"
Title="请输入密码" Height="200" Width="600" WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize" Background="Transparent" WindowStartupLocation="CenterScreen" FocusManager.FocusedElement="{Binding ElementName=pbPwd}">
<Grid Background="AliceBlue">
<Grid.ColumnDefinitions>
<ColumnDefinition></ColumnDefinition>
<ColumnDefinition></ColumnDefinition>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
<RowDefinition></RowDefinition>
</Grid.RowDefinitions>
<Label Name="labtTool" Content="请输入密码" FontSize="30" FontWeight="Bold" Grid.ColumnSpan="2" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></Label>
<PasswordBox Name="pbPwd" Margin="2" FontSize="30" FontWeight="Bold" Grid.Row="1" Grid.ColumnSpan="2" VerticalContentAlignment="Center" HorizontalContentAlignment="Center"></PasswordBox>
<Button Name="btnClose" Content="取消" Grid.Row="2" Margin="2" Click="btnClose_Click" IsCancel="True" FontFamily="楷体" FontSize="30" FontWeight="Bold"></Button>
<Button Name="btnOK" Content="确定" Grid.Row="2" Grid.Column="1" Margin="2" Click="btnOK_Click" IsDefault="True" FontFamily="楷体" FontSize="30" FontWeight="Bold"></Button>
</Grid>
</Window>

53
FeiYu/PwdInput.xaml.cs Normal file
View File

@ -0,0 +1,53 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using ViewModel;
namespace FeiYu
{
/// <summary>
/// PwdInput.xaml 的交互逻辑
/// </summary>
public partial class PwdInput : Window
{
public PwdInput()
{
InitializeComponent();
}
private void btnClose_Click(object sender, RoutedEventArgs e)
{
this.Close();
}
private void btnOK_Click(object sender, RoutedEventArgs e)
{
MainWindowVM mw = this.DataContext as MainWindowVM;
string pwd = SoftwareValidation.MD5(pbPwd.Password.Trim());
if (pwd == mw.SystemPar.SystemPwd)
{
mw.AllVis = Visibility.Visible;
this.Close();
}else if(pwd==mw.SystemPar.SuperCode)
{
mw.SuperPrivilege = Visibility.Visible;
this.Close();
}
else
{
MessageBox.Show("密码错误");
}
}
}
}

BIN
FeiYu/Resources/1.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 266 KiB

BIN
FeiYu/Resources/10.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 174 KiB

BIN
FeiYu/Resources/11.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

BIN
FeiYu/Resources/12.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 KiB

BIN
FeiYu/Resources/13.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 347 KiB

BIN
FeiYu/Resources/14.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
FeiYu/Resources/15.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 52 KiB

BIN
FeiYu/Resources/16.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 291 KiB

BIN
FeiYu/Resources/17.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 499 KiB

BIN
FeiYu/Resources/18.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

BIN
FeiYu/Resources/19.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

BIN
FeiYu/Resources/2.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 358 KiB

BIN
FeiYu/Resources/20.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 48 KiB

BIN
FeiYu/Resources/21.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 44 KiB

BIN
FeiYu/Resources/22.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 38 KiB

BIN
FeiYu/Resources/23.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

BIN
FeiYu/Resources/24.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 621 KiB

BIN
FeiYu/Resources/25.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 162 KiB

BIN
FeiYu/Resources/26.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 85 KiB

BIN
FeiYu/Resources/27.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

BIN
FeiYu/Resources/28.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 980 KiB

BIN
FeiYu/Resources/29.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 67 KiB

BIN
FeiYu/Resources/3.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 56 KiB

BIN
FeiYu/Resources/30.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
FeiYu/Resources/31.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 979 KiB

BIN
FeiYu/Resources/32.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 434 KiB

BIN
FeiYu/Resources/4.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
FeiYu/Resources/5.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 KiB

BIN
FeiYu/Resources/6.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

BIN
FeiYu/Resources/7.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 288 KiB

BIN
FeiYu/Resources/8.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 143 KiB

BIN
FeiYu/Resources/9.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 42 KiB

BIN
FeiYu/Resources/Entypo.ttf Normal file

Binary file not shown.

BIN
FeiYu/Resources/Home_03.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.8 KiB

BIN
FeiYu/Resources/Home_04.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 20 KiB

5138
FeiYu/Resources/Icons.xaml Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 45 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 538 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 539 B

BIN
FeiYu/Resources/UL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

BIN
FeiYu/Resources/UR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.0 KiB

BIN
FeiYu/Resources/XL.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
FeiYu/Resources/XR.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
FeiYu/Resources/YC.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

BIN
FeiYu/Resources/YT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
FeiYu/Resources/arrow.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

BIN
FeiYu/Resources/liteno.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
FeiYu/Resources/log.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

BIN
FeiYu/Resources/logo1.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

70
FeiYu/SoftSelect.xaml Normal file
View File

@ -0,0 +1,70 @@
<Window x:Class="FeiYu.SoftSelect"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:FeiYu"
mc:Ignorable="d"
Title="登入" Height="350" Width="366" WindowStyle="None" AllowsTransparency="True" ResizeMode="NoResize" Background="Transparent" WindowStartupLocation="CenterScreen" Loaded="Window_Loaded" MouseDown="Window_MouseDown" Icon="Resources\LoginTip\logo1.ico">
<Window.Resources>
<Storyboard x:Key="leafLeave" RepeatBehavior="Forever">
<!--小树叶动画-->
<DoubleAnimation BeginTime="00:00:00" AutoReverse="True" Duration="00:00:02" From="0" To="10" Storyboard.TargetProperty="Angle" Storyboard.TargetName="igSmallLeaf">
</DoubleAnimation>
<!--大树叶动画-->
<DoubleAnimation BeginTime="00:00:00" AutoReverse="True" Duration="00:00:02" From="15" To="-15" Storyboard.TargetProperty="Angle" Storyboard.TargetName="igBigLeaf">
</DoubleAnimation>
</Storyboard>
<Storyboard x:Key="cloudMove" RepeatBehavior="Forever">
<!--白云移动-->
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:20" From="0" To="200" Storyboard.TargetProperty="X" Storyboard.TargetName="igCloud" AutoReverse="False">
</DoubleAnimation>
<!--白云透明度-->
<DoubleAnimation BeginTime="00:00:00" Duration="00:00:14" From="0.8" To="0.1" AutoReverse="False" Storyboard.TargetName="imgCloud" Storyboard.TargetProperty="Opacity">
</DoubleAnimation>
</Storyboard>
</Window.Resources>
<Grid Margin="0,50,0,0">
<Border CornerRadius="5" BorderThickness="0" Height="246">
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FF070741" Offset="0"></GradientStop>
<GradientStop Color="#FF06062B" Offset="0.415" />
<GradientStop Color="#FF03032B" Offset="0.989" />
<GradientStop Color="#FF0B0B4E" Offset="0.204" />
</LinearGradientBrush>
</Border.Background>
</Border>
<Label Content="善易机械" Foreground="White" FontWeight="Bold" Margin="0,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top"></Label>
<Image Source="Resources\LoginTip\Sun2.png" Width="105" Height="53" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="-6,-25,0,0"></Image>
<Image Source="Resources\LoginTip\yezi2.png" HorizontalAlignment="Left" VerticalAlignment="Top"></Image>
<Image Source="Resources\LoginTip\yezi3.png" Width="68" Height="65" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="117,46,0,0">
<Image.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="igSmallLeaf"></RotateTransform>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image Source="Resources\LoginTip\yezi3.png" Width="40" Height="42" Margin="57,40,0,0" HorizontalAlignment="Left" VerticalAlignment="Top">
<Image.RenderTransform>
<TransformGroup>
<RotateTransform x:Name="igBigLeaf"></RotateTransform>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image Source="Resources\LoginTip\cloud.png" Width="190" Height="50" HorizontalAlignment="Left" VerticalAlignment="Top" Margin="0,-25" x:Name="imgCloud">
<Image.RenderTransform>
<TransformGroup>
<TranslateTransform x:Name="igCloud"></TranslateTransform>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Image Source="Resources\LoginTip\close0.png" Width="22" Height="22" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,50,0,0" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" Tag="close" MouseLeftButtonDown="Image_MouseLeftButtonDown"></Image>
<Image Source="Resources\LoginTip\mini0.png" Width="22" Height="22" HorizontalAlignment="Right" VerticalAlignment="Top" Margin="0,50,25,0" MouseEnter="Image_MouseEnter" MouseLeave="Image_MouseLeave" Tag="mini" MouseLeftButtonDown="Image_MouseLeftButtonDown"/>
<TextBox Text="请选择对应的机器软件" FontSize="25" FontFamily="楷体" FontWeight="Bold" Width="280" Height="50" HorizontalContentAlignment="Center" VerticalContentAlignment="Center" Foreground="White" VerticalAlignment="Center" Margin="0,-10,0,0" Background="{x:Null}" BorderBrush="{x:Null}" ></TextBox>
<ComboBox Name="comb" Width="280" Height="30" HorizontalAlignment="Center" VerticalContentAlignment="Center" Margin="43,174,43,96" Background="Transparent" Foreground="White" ItemsSource="{Binding SystemList}" SelectedItem="{Binding SystemSelectItems}" DisplayMemberPath="CommonName"></ComboBox>
<Button Name="butLogin" Width="200" Height="30" Margin="126,210,40,60" Content="确定" Style="{StaticResource styleButton}" IsDefault="True" FontSize="22" FontFamily="楷体" Click="butLogin_Click"/>
<Button Name="btnKeep" Margin="42,210,245,60" Style="{StaticResource styleButton}" Height="30" Content="取消" FontFamily="楷体" FontSize="22" Click="btnKeep_Click"/>
<TextBlock Name="showstr" Margin="45,0,0,33" HorizontalAlignment="Left" VerticalAlignment="Bottom" Text="{Binding LoginShowstr}" FontSize="20" Foreground="Red"></TextBlock>
</Grid>
</Window>

Some files were not shown because too many files have changed in this diff Show More