Commit a955f1fd authored by 徐生海's avatar 徐生海

Initial commit

parent a1ab8d35
Pipeline #172 failed with stages
## ide
# 忽略操作系统生成的文件
DS_Store
# 忽略日志文件
*.log
**/.vs
**/.idea
work.md
__pycache__/
*.py[cod]
$__pycache__$
/logs/
/Resource/
/dist/
/build/
# 忽略环境变量文件
env
# 忽略依赖文件夹
node_modules/
\ No newline at end of file
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace LeiCaMicroscopeAPI
{
public class Class1
{
}
}
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" 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>{BC258950-8D1B-473A-8DAF-7AB127CA8F7A}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>LeiCaMicroscopeAPI</RootNamespace>
<AssemblyName>LeiCaMicroscopeAPI</AssemblyName>
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</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>
</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>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<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" />
</ItemGroup>
<ItemGroup>
<Compile Include="Class1.cs" />
<Compile Include="YQLContexts\LeiCaContext.cs" />
<Compile Include="YQLContexts\SerialContext.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="YQLControllers\MicController.cs" />
<Compile Include="YQLInterfaces\IMicController.cs" />
<Compile Include="YQLInterfaces\IYQLContext.cs" />
<Compile Include="YQLInterfaces\IMicroscope.cs" />
<Compile Include="YQLInterfaces\ISerialPort.cs" />
<Compile Include="YQLInterfaces\YQLInterface.cs" />
<Compile Include="YQLReaders\APBLController.cs" />
<Compile Include="YQLReaders\DocuPortController.cs" />
<Compile Include="YQLReaders\EventController.cs" />
<Compile Include="YQLReaders\LampController.cs" />
<Compile Include="YQLControllers\LeiCaMicReader.cs" />
<Compile Include="YQLReaders\LFBLController.cs" />
<Compile Include="YQLReaders\MasterController.cs" />
<Compile Include="YQLReaders\ObjectiveController.cs" />
<Compile Include="YQLReaders\SerialPortReader.cs" />
<Compile Include="YQLReaders\SpotLightController.cs" />
<Compile Include="YQLReaders\ZDriverController.cs" />
<Compile Include="YQLUtils\AppTimeLoop.cs" />
<Compile Include="YQLUtils\MicID.cs" />
<Compile Include="YQLUtils\MicUtil.cs" />
<Compile Include="YQLUtils\MicSettings.cs" />
<Compile Include="YQLUtils\SerialPortUtil.cs" />
<Compile Include="YQLUtils\Settings.cs" />
<Compile Include="YQLUtils\YQLUtil.cs" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("LeiCaMicroscopeAPI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("LeiCaMicroscopeAPI")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("bc258950-8d1b-473a-8daf-7ab127ca8f7a")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YQLInterfaces
{
public class LeiCaContext : IYQLContext
{
public LeiCaContext(string portname = "COM5", int baudrate = 9600)
{
initialization("徕卡显微镜上下文");
PortName = portname;
BaudRate = baudrate;
}
public override void initValue()
{
PortName = "COM6" ;
BaudRate = 9600 ;
DataBits = 8 ;
StopBits = 1 ;
Parity = 0 ;
ReadTimeout = 100 ;
SendTimeout = 1000 ;
}
public void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0)
{
PortName = portname ;
BaudRate = baudrate ;
DataBits = databits ;
StopBits = stopbits ;
Parity = parity ;
}
public string PortName { get; set; }
public int BaudRate { get; set; }
public int DataBits { get; set; }
public int StopBits { get; set; }
public int Parity { get; set; }
public int ReadTimeout { get; set; }
public int SendTimeout { get; set; }
public bool hasPortName { get{ return hasProperty("PortName" , typeof(string)); }}
public bool hasBaudRate { get{ return hasProperty("BaudRate" , typeof(string)); }}
public bool hasDataBits { get{ return hasProperty("DataBits" , typeof(string)); }}
public bool hasStopBits { get{ return hasProperty("StopBits" , typeof(string)); }}
public bool hasParity { get{ return hasProperty("Parity" , typeof(string)); }}
public bool hasReadTimeout { get{ return hasProperty("ReadTimeout" , typeof(string)); }}
public bool hasSendTimeout { get{ return hasProperty("SendTimeout" , typeof(string)); }}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YQLInterfaces
{
public class SerialContext: IYQLContext
{
public SerialContext(string portname = "COM5", int baudrate=9600)
{
initialization("串口上下文");
PortName = portname;
BaudRate = baudrate;
}
public override void initValue()
{
PortName = "COM5" ;
BaudRate = 9600 ;
DataBits = 8 ;
StopBits = 1 ;
Parity = 0 ;
ReadTimeout = 100 ;
SendTimeout = 1000 ;
}
public void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0)
{
PortName = portname ;
BaudRate = baudrate ;
DataBits = databits ;
StopBits = stopbits ;
Parity = parity ;
}
public string PortName { get; set; }
public int BaudRate { get; set; }
public int DataBits { get; set; }
public int StopBits { get; set; }
public int Parity { get; set; }
public int ReadTimeout { get; set; }
public int SendTimeout { get; set; }
public bool hasPortName { get{ return hasProperty("PortName" , typeof(string)); }}
public bool hasBaudRate { get{ return hasProperty("BaudRate" , typeof(string)); }}
public bool hasDataBits { get{ return hasProperty("DataBits" , typeof(string)); }}
public bool hasStopBits { get{ return hasProperty("StopBits" , typeof(string)); }}
public bool hasParity { get{ return hasProperty("Parity" , typeof(string)); }}
public bool hasReadTimeout { get{ return hasProperty("ReadTimeout" , typeof(string)); }}
public bool hasSendTimeout { get{ return hasProperty("SendTimeout" , typeof(string)); }}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class LeiCaMicReader : YQLInterface, IMicroscope
{
private LeiCaMicReader(string portname = "COM6", int baudrate=9600)
{
initialization("SerialPortReader");
setParameter(portname, baudrate);
}
~LeiCaMicReader()
{
deinitialize();
}
public void Dispose()
{
deinitialize();
}
public override void initValue()
{
initParameter ();
initManager ();
}
public override void deleValue()
{
deleManager ();
deleParameter ();
}
public IMicroscope Instance() { return GetInstance(); }
private static IMicroscope uniqueInstance;
// 定义一个标识确保线程同步
private static readonly object locker = new object();
/// <summary>
/// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
/// </summary>
/// <returns></returns>
public static IMicroscope GetInstance()
{
// 当第一个线程运行到这里时,此时会对locker对象 "加锁",
// 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
// lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
// 双重锁定只需要一句判断就可以了
if (uniqueInstance == null)
{
lock (locker)
{
// 如果类的实例不存在则创建,否则直接返回
if (uniqueInstance == null)
{
uniqueInstance = new LeiCaMicReader();
}
}
}
return uniqueInstance;
}
/*===========================================================================*/
protected SerialPort Manager = null;
protected LeiCaContext Parameter = null;
protected static readonly object IOLocker = new object();
public bool hasManager { get {return Manager != null ;} }
public bool hasParameter { get {return Parameter != null ;} }
public bool IsValid { get {return hasManager && hasParameter ;} }
public bool IsAvailable { get {return IsValid && IsOpen ;} }
public bool IsOpen { get {return IsValid && Manager.IsOpen ;} }
public int Open () {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (IsOpen)
Close();
if (!hasManager)
initManager();
if (!hasManager)
return isWarning;
Manager.PortName = Parameter.PortName ;
Manager.BaudRate = Parameter.BaudRate ;
Manager.DataBits = Parameter.DataBits ;
Manager.StopBits = (StopBits)Parameter.StopBits ;
Manager.Parity = (Parity)Parameter.Parity ;
Manager.ReadTimeout = Parameter.ReadTimeout ;
Manager.WriteTimeout = Parameter.SendTimeout ;
Manager.Open();
isWarning = Manager.IsOpen ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public int Close () {
int isWarning = Settings.RECODE_FAILURE;
try
{
if(hasManager)
{
Manager.Close();
Manager.Dispose();
}
isWarning = !hasManager || !Manager.IsOpen ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public int ReOpen () {
Close();
return Open();
}
public void initManager () {
try
{
initParameter();
if(!hasManager)
{
Manager = new SerialPort();
}
}
catch (Exception E) {
YQLUtil.Print_Exception(E);
Manager = null;
}
}
public void deleManager () {
try
{
if(hasManager)
{
Manager.Close();
Manager.Dispose();
}
Manager = null;
GC.Collect();
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
}
public void initParameter () {
try
{
if (!hasParameter || !Parameter.hasPortName || !Parameter.hasBaudRate)
Parameter = new LeiCaContext();
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
}
public void deleParameter () {
Parameter = null;
GC.Collect();
}
public void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0)
{
initParameter();
if(hasParameter)
Parameter.setParameter(portname, baudrate, databits, stopbits, parity);
}
public string ReadString (string frameTail, int timeout = 100)
{
var result = Settings.DEFAULT_STR;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return result;
}
public byte[] ReadBinary (string frameTail, int timeout = 100)
{
var result = Settings.DEFAULT_BYTE_ARRAY;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return result;
}
public int SendString (string buffer)
{
var isWarning = Settings.RECODE_FAILURE;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendString(Manager, buffer);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public int SendBinary (byte[] buffer)
{
var isWarning = Settings.RECODE_FAILURE;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendBinary(Manager, buffer);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public string WaitDone (string buffer, string frameTail, int timeout = 100, int waittime = 0)
{
var result = Settings.DEFAULT_STR;
//lock (IOLocker)
//{
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendString(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
if(waittime <= 0)
{
}
else
AppTimeLoop.ProcessEvents(waittime);
result = SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
//}
return result;
}
public byte[] WaitDone (byte[] buffer, string frameTail, int timeout = 100, int waittime = 0)
{
var result = Settings.DEFAULT_BYTE_ARRAY;
//lock (IOLocker)
//{
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendBinary(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
if (waittime <= 0)
{
}
else
AppTimeLoop.ProcessEvents(waittime);
result = SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
//}
return result;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class MicController: YQLInterface, IMicController
{
/*=====================================================================================================================*/
public int setDocuPortEvents (IMicroscope Manager ) { return EventController. setDocuPortEvents (Manager );} //
public int setMasterEvents (IMicroscope Manager ) { return EventController. setMasterEvents (Manager );} // 设置显微镜事件
public int setZDriveEvents (IMicroscope Manager ) { return EventController. setZDriveEvents (Manager );} // 设置Z轴事件
public int setObjectiveEvents (IMicroscope Manager ) { return EventController. setObjectiveEvents (Manager );} // 设置物镜事件
public int setLampEvents (IMicroscope Manager ) { return EventController. setLampEvents (Manager );} // 设置光源事件
public int setSpotLightEvents (IMicroscope Manager ) { return EventController. setSpotLightEvents (Manager );} // 设置外摆式聚光镜事件
public int setLFBLEvents (IMicroscope Manager ) { return EventController. setLFBLEvents (Manager );} // 设置孔径光阑事件
public int setAPBLEvents (IMicroscope Manager ) { return EventController. setAPBLEvents (Manager );} // 设置视场光阑事件
public int ChangedDocuPortEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedDocuPortEvents (Manager, events );}
public int ChangedMasterEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedMasterEvents (Manager, events );}
public int ChangedZDriveEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedZDriveEvents (Manager, events );}
public int ChangedObjectiveEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedObjectiveEvents (Manager, events );}
public int ChangedLampEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedLampEvents (Manager, events );}
public int ChangedSpotLightEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedSpotLightEvents (Manager, events );}
public int ChangedLFBLEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedLFBLEvents (Manager, events );}
public int ChangedAPBLEvents (IMicroscope Manager, int[] events ) { return EventController. ChangedAPBLEvents (Manager, events );}
/*=====================================================================================================================*/
public int setMasterReset (IMicroscope Manager ) { return MasterController.setMasterReset (Manager );} // 重置显微镜
public int setMasterDefault (IMicroscope Manager ) { return MasterController.setMasterDefault (Manager );} // 重置显微镜为默认值
public int setMasterConfigMode (IMicroscope Manager , bool enable ) { return MasterController.setMasterConfigMode (Manager,enable );} // 设置显微镜配置模式
public int setMasterWaitTimes (IMicroscope Manager , int waittimes ) { return MasterController.setMasterWaitTimes (Manager,waittimes );} // 设置显微镜等待时间
public int setManualOptionStatus (IMicroscope Manager , bool enable ) { return MasterController.setManualOptionStatus (Manager,enable );} // 设置显微镜手动操作
public (int, int) getMicroscopeInitStatus (IMicroscope Manager ) { return MasterController.getMicroscopeInitStatus (Manager );} // 获取显微镜初始化状态
public (int, int) getMasterFirmwareStatus (IMicroscope Manager ) { return MasterController.getMasterFirmwareStatus (Manager );} // 获取显微镜固件加载状态
public (int, int) getMasterConfigMode (IMicroscope Manager ) { return MasterController.getMasterConfigMode (Manager );} // 获取显微镜配置模式
public (int, int) getManualOptionStatus (IMicroscope Manager ) { return MasterController.getManualOptionStatus (Manager );} // 获取显微镜手动开关状态
/*=====================================================================================================================*/
public int setZDriverManualOptionStatus (IMicroscope Manager , bool enable ) { return ZDriverController.setZDriverManualOptionStatus (Manager , enable );}
public int setZDriverReset (IMicroscope Manager ) { return ZDriverController.setZDriverReset (Manager );}
public int setZDriverInit (IMicroscope Manager ) { return ZDriverController.setZDriverInit (Manager );}
public int setZDriverBreak (IMicroscope Manager ) { return ZDriverController.setZDriverBreak (Manager );}
public int setZDriverAbsPosition (IMicroscope Manager , int value ) { return ZDriverController.setZDriverAbsPosition (Manager , value );}
public int setZDriverRelPosition (IMicroscope Manager , int value ) { return ZDriverController.setZDriverRelPosition (Manager , value );}
public int setZDriverConstPosition (IMicroscope Manager , int value ) { return ZDriverController.setZDriverConstPosition (Manager , value );}
public int setZDriverLowerLimit (IMicroscope Manager , int value ) { return ZDriverController.setZDriverLowerLimit (Manager , value );}
public int setZDriverFocusLimit (IMicroscope Manager , int value ) { return ZDriverController.setZDriverFocusLimit (Manager , value );}
public int setZDriverUpperLimit (IMicroscope Manager , int value ) { return ZDriverController.setZDriverUpperLimit (Manager , value );}
public int setZDriverAcceleration (IMicroscope Manager , int value ) { return ZDriverController.setZDriverAcceleration (Manager , value );}
public int setZDriverSpeed (IMicroscope Manager , int value ) { return ZDriverController.setZDriverSpeed (Manager , value );}
public int ZDriverMoveToFocusLimit (IMicroscope Manager ) { return ZDriverController.ZDriverMoveToFocusLimit (Manager );}
public int ZDriverMoveToLowerLimit (IMicroscope Manager ) { return ZDriverController.ZDriverMoveToLowerLimit (Manager );}
public int ZDriverPositionAsFocus (IMicroscope Manager ) { return ZDriverController.ZDriverPositionAsFocus (Manager );}
public int ZDriverPositionAsLower (IMicroscope Manager ) { return ZDriverController.ZDriverPositionAsLower (Manager );}
public int ZDriverInitRange (IMicroscope Manager ) { return ZDriverController.ZDriverInitRange (Manager );}
public int setZDriverMoveMode (IMicroscope Manager , bool enable ) { return ZDriverController.setZDriverMoveMode (Manager , enable );}
public int setZDriverFocusLimitEnable (IMicroscope Manager , bool enable ) { return ZDriverController.setZDriverFocusLimitEnable (Manager , enable );}
public int setZDriverInitMode (IMicroscope Manager , string value ) { return ZDriverController.setZDriverInitMode (Manager , value );}
public (int, int, int, int, int,int ) getZDriverStatus (IMicroscope Manager ) { return ZDriverController.getZDriverStatus (Manager );}
public (int, int ) getZDriverManualOptionStatus (IMicroscope Manager ) { return ZDriverController.getZDriverManualOptionStatus (Manager );}
public (int, int ) getZDriverFirmwareStatus (IMicroscope Manager ) { return ZDriverController.getZDriverFirmwareStatus (Manager );}
public (int, int ) getZDriverAbsPosition (IMicroscope Manager ) { return ZDriverController.getZDriverAbsPosition (Manager );}
public (int, int ) getZDriverLowerLimit (IMicroscope Manager ) { return ZDriverController.getZDriverLowerLimit (Manager );}
public (int, int ) getZDriverFocusLimit (IMicroscope Manager ) { return ZDriverController.getZDriverFocusLimit (Manager );}
public (int, int ) getZDriverAcceleration (IMicroscope Manager ) { return ZDriverController.getZDriverAcceleration (Manager );}
public (int, int ) getZDriverSpeed (IMicroscope Manager ) { return ZDriverController.getZDriverSpeed (Manager );}
public (int, float ) getZDriverConvertFactor (IMicroscope Manager ) { return ZDriverController.getZDriverConvertFactor (Manager );}
public (int, int ) getZDriverMinAcceleration (IMicroscope Manager ) { return ZDriverController.getZDriverMinAcceleration (Manager );}
public (int, int ) getZDriverMaxAcceleration (IMicroscope Manager ) { return ZDriverController.getZDriverMaxAcceleration (Manager );}
public (int, int ) getZDriverMoveMode (IMicroscope Manager ) { return ZDriverController.getZDriverMoveMode (Manager );}
public (int, int ) getZDriverFocusLimitEnable (IMicroscope Manager ) { return ZDriverController.getZDriverFocusLimitEnable (Manager );}
public (int, int ) getZDriverMinSpeed (IMicroscope Manager ) { return ZDriverController.getZDriverMinSpeed (Manager );}
public (int, int ) getZDriverMaxSpeed (IMicroscope Manager ) { return ZDriverController.getZDriverMaxSpeed (Manager );}
public (int, int ) getZDriverUpperLimit (IMicroscope Manager ) { return ZDriverController.getZDriverUpperLimit (Manager );}
public (int, string ) getZDriverInitMode (IMicroscope Manager ) { return ZDriverController.getZDriverInitMode (Manager );}
/*========================================================================================================================*/
public int setObjectiveManualOperation (IMicroscope Manager, bool value ){ return ObjectiveController.setObjectiveManualOperation (Manager, value );}
public int setObjectiveAbsPosition (IMicroscope Manager, int value ){ return ObjectiveController.setObjectiveAbsPosition (Manager, value );}
public int setObjectiveRelPosition (IMicroscope Manager, int value ){ return ObjectiveController.setObjectiveRelPosition (Manager, value );}
public int setObjectiveOperationMode (IMicroscope Manager, int value ){ return ObjectiveController.setObjectiveOperationMode (Manager, value );}
public int setObjectiveDRYMode (IMicroscope Manager, string value ){ return ObjectiveController.setObjectiveDRYMode (Manager, value );}
public int setObjectiveMethodParameter (IMicroscope Manager, int value, string[] data ){ return ObjectiveController.setObjectiveMethodParameter (Manager, value, data );}
public int setObjectivePathoMode (IMicroscope Manager, int value ){ return ObjectiveController.setObjectivePathoMode (Manager, value );}
public int setObjectiveDIP (IMicroscope Manager ){ return ObjectiveController.setObjectiveDIP (Manager );}
public (int, int, int, int, int) getObjectiveStatus (IMicroscope Manager ){ return ObjectiveController.getObjectiveStatus (Manager );}
public (int, int) getObjectiveManualOperationStatus (IMicroscope Manager ){ return ObjectiveController.getObjectiveManualOperationStatus (Manager );}
public (int, int) getObjectiveAbsPosition (IMicroscope Manager ){ return ObjectiveController.getObjectiveAbsPosition (Manager );}
public (int, int) getObjectiveOperationStatus (IMicroscope Manager ){ return ObjectiveController.getObjectiveOperationStatus (Manager );}
public (int, string) getObjectiveDryMode (IMicroscope Manager ){ return ObjectiveController.getObjectiveDryMode (Manager );}
public (int, string) getObjectiveMethodParameter (IMicroscope Manager , int level, int parameter ){ return ObjectiveController.getObjectiveMethodParameter (Manager , level, parameter );}
public (int, int) getObjectiveMinPosition (IMicroscope Manager ){ return ObjectiveController.getObjectiveMinPosition (Manager );}
public (int, int) getObjectiveMaxPosition (IMicroscope Manager ){ return ObjectiveController.getObjectiveMaxPosition (Manager );}
public (int, int) getObjectivePathoMode (IMicroscope Manager ){ return ObjectiveController.getObjectivePathoMode (Manager );}
/*=====================================================================================================================*/
public int setLampManualOperation (IMicroscope Manager , bool enable ){ return LampController.setLampManualOperation (Manager , enable );} // 设置灯的手动操作是否打开或关闭
public int setLampAbsPosition (IMicroscope Manager , int value ){ return LampController.setLampAbsPosition (Manager , value );} // 将功能单元定位到定义的绝对值
public int setLampRelPosition (IMicroscope Manager , int value ){ return LampController.setLampRelPosition (Manager , value );} // 相对于当前位置定位功能单元
public int setLampTLILMode (IMicroscope Manager , bool enable ){ return LampController.setLampTLILMode (Manager , enable );} // 在 TL 和 IL 灯之间切换 enable TL
public int setLampStepPosition (IMicroscope Manager , bool enable ){ return LampController.setLampStepPosition (Manager , enable );} // 步进模式 enable: True 1 False -1
public int setLampStepMode (IMicroscope Manager , bool enable ){ return LampController.setLampStepMode (Manager , enable );} // 设置步进模式灯
public int setLampOnOff (IMicroscope Manager , bool enable ){ return LampController.setLampOnOff (Manager , enable );} // 设置快门灯
public int setLampMode (IMicroscope Manager , int enable ){ return LampController.setLampMode (Manager , enable );} // 设置灯泡模式
public (int, int, int) getLampSTATUS (IMicroscope Manager ){ return LampController.getLampSTATUS (Manager );} // 读取灯的当前状态
public (int, int, int) getLampAbsPosition (IMicroscope Manager ){ return LampController.getLampAbsPosition (Manager );} // 输出功能单元的当前位置
public (int, int, int) getLampMinPosition (IMicroscope Manager ){ return LampController.getLampMinPosition (Manager );} // 返回最小可能的灯参数
public (int, int, int) getLampMaxPosition (IMicroscope Manager ){ return LampController.getLampMaxPosition (Manager );} // 返回最高的可能灯泡参数
public (int, int, int) getLampOnOff (IMicroscope Manager ){ return LampController.getLampOnOff (Manager );} // 获取快门灯
public (int, int) getLampStepMode (IMicroscope Manager ){ return LampController.getLampStepMode (Manager );} // 获取步进模式灯
public (int, int) getLampManualOperation (IMicroscope Manager ){ return LampController.getLampManualOperation (Manager );} // 读取灯的手动操作是否打开或关闭
public (int, int) getLampMode (IMicroscope Manager ){ return LampController.getLampMode (Manager );} // 获取灯泡模式
/*=================================================================================================================*/
public int setSpotLightManualOperation (IMicroscope Manager , bool enable ) { return SpotLightController.setSpotLightManualOperation (Manager , enable );} // 设置摆动聚光镜手动操作
public int setSpotLight (IMicroscope Manager , bool enable ) { return SpotLightController.setSpotLight (Manager , enable );} // 设置摆动聚光镜状态
public int setSpotLightMagLevel (IMicroscope Manager , int objective, string StringNA ) { return SpotLightController.setSpotLightMagLevel (Manager , objective, StringNA );} // 设置摆动聚光镜定义放大倍数
public int setSpotLightMode (IMicroscope Manager , bool enable ) { return SpotLightController.setSpotLightMode (Manager , enable );} // 设置摆动聚光镜定义放大倍数
public int setSpotLightObjectivePosition (IMicroscope Manager , int objective, bool enable ) { return SpotLightController.setSpotLightObjectivePosition(Manager , objective, enable );} // 设置摆动聚光镜定义放大倍数
public (int, int) getSpotLightStatus (IMicroscope Manager ) { return SpotLightController.getSpotLightStatus (Manager );} // 获取摆动聚光镜状态
public (int, int) getSpotLightManualOperation (IMicroscope Manager ) { return SpotLightController.getSpotLightManualOperation (Manager );} // 读取摆动聚光镜手动操作
public (int, int) getSpotLight (IMicroscope Manager ) { return SpotLightController.getSpotLight (Manager );} // 获取摆动聚光镜状态
public (int, string) getSpotLightMagLevel (IMicroscope Manager ) { return SpotLightController.getSpotLightMagLevel (Manager );} // 获取摆动聚光镜定义放大倍数
public (int, int) getSpotLightMode (IMicroscope Manager ) { return SpotLightController.getSpotLightMode (Manager );} // 获取摆动聚光镜定义放大倍数
public (int, int) getSpotLightObjectivePosition (IMicroscope Manager , int objective ) { return SpotLightController.getSpotLightObjectivePosition(Manager , objective );} // 获取摆动聚光镜定义放大倍数
/*=================================================================================================================*/
public int setLFBLManualOperation (IMicroscope Manager , bool enable ) { return LFBLController.setLFBLManualOperation ( Manager , enable );}
public int setLFBLInit (IMicroscope Manager , bool enable ) { return LFBLController.setLFBLInit ( Manager , enable );}
public int setLFBLAbsPosition (IMicroscope Manager , int value ) { return LFBLController.setLFBLAbsPosition ( Manager , value );}
public int setLFBLRelPosition (IMicroscope Manager , int value ) { return LFBLController.setLFBLRelPosition ( Manager , value );}
public int LFBLToMaxPosition (IMicroscope Manager ) { return LFBLController.LFBLToMaxPosition ( Manager );}
public (int, int) getLFBLStatus (IMicroscope Manager ) { return LFBLController.getLFBLStatus ( Manager );}
public (int, int) getLFBLManualOperation (IMicroscope Manager ) { return LFBLController.getLFBLManualOperation ( Manager );}
public (int, int) getLFBLAbsPosition (IMicroscope Manager ) { return LFBLController.getLFBLAbsPosition ( Manager );}
public (int, int) getLFBLMaxPosition (IMicroscope Manager ) { return LFBLController.getLFBLMaxPosition ( Manager );}
public (int, int) getLFBLMinPosition (IMicroscope Manager ) { return LFBLController.getLFBLMinPosition ( Manager );}
/*=================================================================================================================*/
public int setAPBLManualOperation (IMicroscope Manager , bool enable ){ return APBLController.setAPBLManualOperation (Manager , enable );}
public int setAPBLInit (IMicroscope Manager , bool enable ){ return APBLController.setAPBLInit (Manager , enable );}
public int setAPBLAbsPosition (IMicroscope Manager , int value ){ return APBLController.setAPBLAbsPosition (Manager , value );}
public int setAPBLRelPosition (IMicroscope Manager , int value ){ return APBLController.setAPBLRelPosition (Manager , value );}
public int APBLToMaxPosition (IMicroscope Manager ){ return APBLController.APBLToMaxPosition (Manager );}
public (int, int) getAPBLStatus (IMicroscope Manager ){ return APBLController.getAPBLStatus (Manager );}
public (int, int) getAPBLManualOperation (IMicroscope Manager ){ return APBLController.getAPBLManualOperation (Manager );}
public (int, int) getAPBLAbsPosition (IMicroscope Manager ){ return APBLController.getAPBLAbsPosition (Manager );}
public (int, int) getAPBLMaxPosition (IMicroscope Manager ){ return APBLController.getAPBLMaxPosition (Manager );}
public (int, int) getAPBLMinPosition (IMicroscope Manager ){ return APBLController.getAPBLMinPosition (Manager );}
/*========================================================================================================================*/
public int setDocuPortManualOperation (IMicroscope Manager , bool enable ){ return DocuPortController.setDocuPortManualOperation (Manager , enable);}
public int setDocuPortAbsPosition (IMicroscope Manager , bool enable ){ return DocuPortController.setDocuPortAbsPosition (Manager , enable);}
public int setDocuPortConvertPort (IMicroscope Manager ){ return DocuPortController.setDocuPortConvertPort (Manager );}
public (int, int) getDocuPortStatus (IMicroscope Manager ){ return DocuPortController.getDocuPortStatus (Manager );}
public (int, int) getDocuPortManualOperation (IMicroscope Manager ){ return DocuPortController.getDocuPortManualOperation (Manager );}
public (int, int) getDocuPortAbsPosition (IMicroscope Manager ){ return DocuPortController.getDocuPortAbsPosition (Manager );}
public (int, int) getDocuPortMaxPosition (IMicroscope Manager ){ return DocuPortController.getDocuPortMaxPosition (Manager );}
public (int, int) getDocuPortMinPosition (IMicroscope Manager ){ return DocuPortController.getDocuPortMinPosition (Manager );}
public IMicroscope Microscope() { return LeiCaMicReader.GetInstance(); }
private MicController()
{
initialization("SerialPortReader");
}
~MicController()
{
deinitialize();
}
public void Dispose()
{
deinitialize();
}
private static MicController uniqueInstance;
// 定义一个标识确保线程同步
private static readonly object locker = new object();
/// <summary>
/// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
/// </summary>
/// <returns></returns>
public static MicController GetInstance()
{
// 当第一个线程运行到这里时,此时会对locker对象 "加锁",
// 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
// lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
// 双重锁定只需要一句判断就可以了
if (uniqueInstance == null)
{
lock (locker)
{
// 如果类的实例不存在则创建,否则直接返回
if (uniqueInstance == null)
{
uniqueInstance = new MicController();
}
}
}
return uniqueInstance;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ILeiCaMicroscope
{
public interface IMicController: IDisposable
{
IMicroscope Microscope();
/*=====================================================================================================================*/
int setDocuPortEvents (IMicroscope Manager ); //
int setMasterEvents (IMicroscope Manager ); // 设置显微镜事件
int setZDriveEvents (IMicroscope Manager ); // 设置Z轴事件
int setObjectiveEvents (IMicroscope Manager ); // 设置物镜事件
int setLampEvents (IMicroscope Manager ); // 设置光源事件
int setSpotLightEvents (IMicroscope Manager ); // 设置外摆式聚光镜事件
int setLFBLEvents (IMicroscope Manager ); // 设置孔径光阑事件
int setAPBLEvents (IMicroscope Manager ); // 设置视场光阑事件
int ChangedDocuPortEvents (IMicroscope Manager, int[] events);
int ChangedMasterEvents (IMicroscope Manager, int[] events);
int ChangedZDriveEvents (IMicroscope Manager, int[] events);
int ChangedObjectiveEvents (IMicroscope Manager, int[] events);
int ChangedLampEvents (IMicroscope Manager, int[] events);
int ChangedSpotLightEvents (IMicroscope Manager, int[] events);
int ChangedLFBLEvents (IMicroscope Manager, int[] events);
int ChangedAPBLEvents (IMicroscope Manager, int[] events);
/*=====================================================================================================================*/
int setMasterReset (IMicroscope Manager ); // 重置显微镜
int setMasterDefault (IMicroscope Manager ); // 重置显微镜为默认值
int setMasterConfigMode (IMicroscope Manager , bool enable ); // 设置显微镜配置模式
int setMasterWaitTimes (IMicroscope Manager , int waittimes ); // 设置显微镜等待时间
int setManualOptionStatus (IMicroscope Manager , bool enable ); // 设置显微镜手动操作
(int, int) getMicroscopeInitStatus (IMicroscope Manager ); // 获取显微镜初始化状态
(int, int) getMasterFirmwareStatus (IMicroscope Manager ); // 获取显微镜固件加载状态
(int, int) getMasterConfigMode (IMicroscope Manager ); // 获取显微镜配置模式
(int, int) getManualOptionStatus (IMicroscope Manager ); // 获取显微镜手动开关状态
/*=====================================================================================================================*/
int setZDriverManualOptionStatus (IMicroscope Manager , bool enable );
int setZDriverReset (IMicroscope Manager );
int setZDriverInit (IMicroscope Manager );
int setZDriverBreak (IMicroscope Manager );
int setZDriverAbsPosition (IMicroscope Manager , int value );
int setZDriverRelPosition (IMicroscope Manager , int value );
int setZDriverConstPosition (IMicroscope Manager , int value );
int setZDriverLowerLimit (IMicroscope Manager , int value );
int setZDriverFocusLimit (IMicroscope Manager , int value );
int setZDriverUpperLimit (IMicroscope Manager , int value );
int setZDriverAcceleration (IMicroscope Manager , int value );
int setZDriverSpeed (IMicroscope Manager , int value );
int ZDriverMoveToFocusLimit (IMicroscope Manager );
int ZDriverMoveToLowerLimit (IMicroscope Manager );
int ZDriverPositionAsFocus (IMicroscope Manager );
int ZDriverPositionAsLower (IMicroscope Manager );
int ZDriverInitRange (IMicroscope Manager );
int setZDriverMoveMode (IMicroscope Manager , bool enable );
int setZDriverFocusLimitEnable (IMicroscope Manager , bool enable );
int setZDriverInitMode (IMicroscope Manager , string value );
(int, int, int, int, int,int ) getZDriverStatus (IMicroscope Manager );
(int, int ) getZDriverManualOptionStatus (IMicroscope Manager );
(int, int ) getZDriverFirmwareStatus (IMicroscope Manager );
(int, int ) getZDriverAbsPosition (IMicroscope Manager );
(int, int ) getZDriverLowerLimit (IMicroscope Manager );
(int, int ) getZDriverFocusLimit (IMicroscope Manager );
(int, int ) getZDriverAcceleration (IMicroscope Manager );
(int, int ) getZDriverSpeed (IMicroscope Manager );
(int, float ) getZDriverConvertFactor (IMicroscope Manager );
(int, int ) getZDriverMinAcceleration (IMicroscope Manager );
(int, int ) getZDriverMaxAcceleration (IMicroscope Manager );
(int, int ) getZDriverMoveMode (IMicroscope Manager );
(int, int ) getZDriverFocusLimitEnable (IMicroscope Manager );
(int, int ) getZDriverMinSpeed (IMicroscope Manager );
(int, int ) getZDriverMaxSpeed (IMicroscope Manager );
(int, int ) getZDriverUpperLimit (IMicroscope Manager );
(int, string ) getZDriverInitMode (IMicroscope Manager );
/*========================================================================================================================*/
int setObjectiveManualOperation (IMicroscope Manager, bool value );
int setObjectiveAbsPosition (IMicroscope Manager, int value );
int setObjectiveRelPosition (IMicroscope Manager, int value );
int setObjectiveOperationMode (IMicroscope Manager, int value );
int setObjectiveDRYMode (IMicroscope Manager, string value );
int setObjectiveMethodParameter (IMicroscope Manager, int value, string[] data );
int setObjectivePathoMode (IMicroscope Manager, int value );
int setObjectiveDIP (IMicroscope Manager );
(int, int, int, int, int) getObjectiveStatus (IMicroscope Manager );
(int, int) getObjectiveManualOperationStatus (IMicroscope Manager );
(int, int) getObjectiveAbsPosition (IMicroscope Manager );
(int, int) getObjectiveOperationStatus (IMicroscope Manager );
(int, string) getObjectiveDryMode (IMicroscope Manager );
(int, string) getObjectiveMethodParameter (IMicroscope Manager , int level, int parameter );
(int, int) getObjectiveMinPosition (IMicroscope Manager );
(int, int) getObjectiveMaxPosition (IMicroscope Manager );
(int, int) getObjectivePathoMode (IMicroscope Manager );
/*=====================================================================================================================*/
int setLampManualOperation (IMicroscope Manager , bool enable ); // 设置灯的手动操作是否打开或关闭
int setLampAbsPosition (IMicroscope Manager , int value ); // 将功能单元定位到定义的绝对值
int setLampRelPosition (IMicroscope Manager , int value ); // 相对于当前位置定位功能单元
int setLampTLILMode (IMicroscope Manager , bool enable ); // 在 TL 和 IL 灯之间切换 enable TL
int setLampStepPosition (IMicroscope Manager , bool enable ); // 步进模式 enable: True 1 False -1
int setLampStepMode (IMicroscope Manager , bool enable ); // 设置步进模式灯
int setLampOnOff (IMicroscope Manager , bool enable ); // 设置快门灯
int setLampMode (IMicroscope Manager , int enable ); // 设置灯泡模式
(int, int, int) getLampSTATUS (IMicroscope Manager ); // 读取灯的当前状态
(int, int, int) getLampAbsPosition (IMicroscope Manager ); // 输出功能单元的当前位置
(int, int, int) getLampMinPosition (IMicroscope Manager ); // 返回最小可能的灯参数
(int, int, int) getLampMaxPosition (IMicroscope Manager ); // 返回最高的可能灯泡参数
(int, int, int) getLampOnOff (IMicroscope Manager ); // 获取快门灯
(int, int) getLampStepMode (IMicroscope Manager ); // 获取步进模式灯
(int, int) getLampManualOperation (IMicroscope Manager ); // 读取灯的手动操作是否打开或关闭
(int, int) getLampMode (IMicroscope Manager ); // 获取灯泡模式
/*=================================================================================================================*/
int setSpotLightManualOperation (IMicroscope Manager , bool enable ); // 设置摆动聚光镜手动操作
int setSpotLight (IMicroscope Manager , bool enable ); // 设置摆动聚光镜状态
int setSpotLightMagLevel (IMicroscope Manager , int objective, string StringNA ); // 设置摆动聚光镜定义放大倍数
int setSpotLightMode (IMicroscope Manager , bool enable ); // 设置摆动聚光镜定义放大倍数
int setSpotLightObjectivePosition (IMicroscope Manager , int objective, bool enable ); // 设置摆动聚光镜定义放大倍数
(int, int) getSpotLightStatus (IMicroscope Manager ); // 获取摆动聚光镜状态
(int, int) getSpotLightManualOperation (IMicroscope Manager ); // 读取摆动聚光镜手动操作
(int, int) getSpotLight (IMicroscope Manager ); // 获取摆动聚光镜状态
(int, string) getSpotLightMagLevel (IMicroscope Manager ); // 获取摆动聚光镜定义放大倍数
(int, int) getSpotLightMode (IMicroscope Manager ); // 获取摆动聚光镜定义放大倍数
(int, int) getSpotLightObjectivePosition (IMicroscope Manager , int objective ); // 获取摆动聚光镜定义放大倍数
/*=================================================================================================================*/
int setLFBLManualOperation (IMicroscope Manager , bool enable );
int setLFBLInit (IMicroscope Manager , bool enable );
int setLFBLAbsPosition (IMicroscope Manager , int value );
int setLFBLRelPosition (IMicroscope Manager , int value );
int LFBLToMaxPosition (IMicroscope Manager );
(int, int) getLFBLStatus (IMicroscope Manager );
(int, int) getLFBLManualOperation (IMicroscope Manager );
(int, int) getLFBLAbsPosition (IMicroscope Manager );
(int, int) getLFBLMaxPosition (IMicroscope Manager );
(int, int) getLFBLMinPosition (IMicroscope Manager );
/*=================================================================================================================*/
int setAPBLManualOperation (IMicroscope Manager , bool enable );
int setAPBLInit (IMicroscope Manager , bool enable );
int setAPBLAbsPosition (IMicroscope Manager , int value );
int setAPBLRelPosition (IMicroscope Manager , int value );
int APBLToMaxPosition (IMicroscope Manager );
(int, int) getAPBLStatus (IMicroscope Manager );
(int, int) getAPBLManualOperation (IMicroscope Manager );
(int, int) getAPBLAbsPosition (IMicroscope Manager );
(int, int) getAPBLMaxPosition (IMicroscope Manager );
(int, int) getAPBLMinPosition (IMicroscope Manager );
/*========================================================================================================================*/
int setDocuPortManualOperation (IMicroscope Manager , bool enable );
int setDocuPortAbsPosition (IMicroscope Manager , bool enable );
int setDocuPortConvertPort (IMicroscope Manager );
(int, int) getDocuPortStatus (IMicroscope Manager );
(int, int) getDocuPortManualOperation (IMicroscope Manager );
(int, int) getDocuPortAbsPosition (IMicroscope Manager );
(int, int) getDocuPortMaxPosition (IMicroscope Manager );
(int, int) getDocuPortMinPosition (IMicroscope Manager );
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public interface IMicroscope : IDisposable
{
IMicroscope Instance();
bool hasManager { get; }
bool hasParameter { get; }
bool IsValid { get; }
bool IsAvailable { get; }
bool IsOpen { get; }
int Open ();
int Close ();
int ReOpen ();
void initManager ();
void deleManager ();
void initParameter ();
void deleParameter ();
void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0);
string ReadString (string frameTail, int timeout = 100);
byte[] ReadBinary (string frameTail, int timeout = 100);
int SendString (string buffer);
int SendBinary (byte[] buffer);
string WaitDone (string buffer, string frameTail, int timeout = 100, int waittime = 2);
byte[] WaitDone (byte[] buffer, string frameTail, int timeout = 100, int waittime = 2);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YQLInterfaces
{
public interface ISerialPort: IDisposable
{
ISerialPort Instance();
bool hasManager { get; }
bool hasParameter { get; }
bool IsValid { get; }
bool IsAvailable { get; }
bool IsOpen { get; }
int Open ();
int Close ();
int ReOpen ();
void initManager ();
void deleManager ();
void initParameter ();
void deleParameter ();
void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0);
string ReadString (string frameTail, int timeout = 100);
byte[] ReadBinary (string frameTail, int timeout = 100);
int SendString (string buffer);
int SendBinary (byte[] buffer);
string WaitDone (string buffer, string frameTail, int timeout = 100, int waittime = 50);
byte[] WaitDone (byte[] buffer, string frameTail, int timeout = 100, int waittime = 50);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YQLInterfaces
{
public class IYQLContext : YQLInterface
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace YQLInterfaces
{
public class YQLInterface
{
public string Information { get; set; }
public static bool has_Field(object src, string name, Type TYPE)
{
try
{
if (src == null) return false;
var propertyInfo = src.GetType().GetProperty(name);
if (propertyInfo != null && propertyInfo.GetValue(src, null) != null)
return propertyInfo.GetValue(src, null).GetType() == TYPE;
}
catch (Exception) { }
return false;
}
public static T GetField<T>(object src, string name)
{
try
{
if (src == null) return default(T);
var propertyInfo = src.GetType().GetProperty(name);
return (T)propertyInfo.GetValue(src, null);
}
catch (Exception) { }
return default(T);
}
public static void SetField<T>(object src, string name, T value)
{
try
{
if (src == null) return;
var propertyInfo = src.GetType().GetProperty(name);
propertyInfo.SetValue(src, value, null);
}
catch (Exception) { }
return;
}
public virtual bool hasProperty(string name, Type TYPE)
{
try
{
var propertyInfo = GetType().GetProperty(name);
if (propertyInfo != null && propertyInfo.GetValue(this, null) != null)
return propertyInfo.GetValue(this, null).GetType() == TYPE;
}
catch (Exception) { }
return false;
}
public virtual T getProperty<T>(string name)
{
try
{
var propertyInfo = GetType().GetProperty(name);
return (T)propertyInfo.GetValue(this, null);
}
catch (Exception) { }
return default(T);
}
public virtual void setProperty<T>(string name, T value)
{
try
{
var propertyInfo = GetType().GetProperty(name);
propertyInfo.SetValue(this, value, null);
}
catch (Exception) { }
return;
}
public virtual void initialization(string information)
{
Information = information;
initialize();
}
public virtual void initialize()
{
initData();
initValue();
initProperty();
initConnect();
}
public virtual void deinitialize()
{
deleConnect();
deleProperty();
deleValue();
deleData();
}
public virtual void initData() { }
public virtual void initValue() { }
public virtual void initProperty() { }
public virtual void initConnect() { }
public virtual void deleData() { }
public virtual void deleValue() { }
public virtual void deleProperty() { }
public virtual void deleConnect() { }
public void From(object source)
{
if (source == null)
return;
if (object.ReferenceEquals(this, source))
return;
Type type = source.GetType();
foreach (PropertyInfo property in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
if (!property.CanWrite) continue;
if (!hasProperty(property.Name, property.PropertyType)) continue;
object value = property.GetValue(source);
if (value == null || property.PropertyType.IsValueType || property.PropertyType == typeof(string))
{
property.SetValue(this, value);
}
else
{
property.SetValue(this, DeepCopy(value));
}
}
}
public object Copy()
{
Type type = GetType();
object target = DeepCopy(this);
return target;
}
public static object DeepCopy(object source)
{
if (source == null) return null;
Type type = source.GetType();
object target = Activator.CreateInstance(type);
// 遍历所有属性
foreach (PropertyInfo property in type.GetProperties(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
if (!property.CanWrite) continue;
object value = property.GetValue(source);
if (value == null || property.PropertyType.IsValueType || property.PropertyType == typeof(string))
{
property.SetValue(target, value);
}
else
{
property.SetValue(target, DeepCopy(value));
}
}
// 遍历所有字段
foreach (FieldInfo field in type.GetFields(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance))
{
object value = field.GetValue(source);
if (value == null || field.FieldType.IsValueType || field.FieldType == typeof(string))
{
field.SetValue(target, value);
}
else
{
field.SetValue(target, DeepCopy(value));
}
}
return target;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class APBLController
{
/*=================================================================================================================*/
public static int setAPBLManualOperation (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_APBL_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_APBL_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setAPBLInit (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_APBL_INIT, enable ? 0 : 1};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_APBL_INIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setAPBLAbsPosition (IMicroscope Manager , int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_APBL_ABS_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_APBL_ABS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setAPBLRelPosition (IMicroscope Manager , int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_APBL_REL_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_APBL_REL_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int APBLToMaxPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.APBL_TO_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.APBL_TO_MAX_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static (int, int) getAPBLStatus (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_APBL_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_APBL_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getAPBLManualOperation (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_APBL_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_APBL_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getAPBLAbsPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_APBL_ABS_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_APBL_ABS_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getAPBLMaxPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_APBL_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_APBL_MAX_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getAPBLMinPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_APBL_MIN_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_APBL_MIN_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class DocuPortController
{
/*========================================================================================================================*/
public static int setDocuPortManualOperation (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_DOCUPORT_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_DOCUPORT_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setDocuPortAbsPosition (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_DOCUPORT_ABS_POSITION, enable ? 2 : 1};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_DOCUPORT_ABS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setDocuPortConvertPort (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_DOCUPORT_CONVERT_PORT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_DOCUPORT_CONVERT_PORT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static (int, int) getDocuPortStatus (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_DOCUPORT_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_DOCUPORT_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getDocuPortManualOperation (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_DOCUPORT_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_DOCUPORT_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getDocuPortAbsPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_DOCUPORT_ABS_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_DOCUPORT_ABS_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getDocuPortMaxPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_DOCUPORT_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_DOCUPORT_MAX_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getDocuPortMinPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if(Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_DOCUPORT_MIN_POSITION };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_DOCUPORT_MIN_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class EventController
{
public static int setDocuPortEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_DOCUPORT_EVENT, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_DOCUPORT_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setMasterEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_EVENT, 0, 0, 0, 0, 0, 0, 0, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriveEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_EVENT, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_EVENT, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setLampEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_EVENTS, 0, 0, 0, 0, 0, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_EVENTS);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setSpotLightEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT_EVENT, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setLFBLEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LFBL_EVENT, 0, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LFBL_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setAPBLEvents (IMicroscope Manager){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_APBL_EVENT, 0, 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_APBL_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedDocuPortEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 1)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_DOCUPORT_EVENT};
for(int count = 0; count < 1; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_DOCUPORT_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedMasterEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 8)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_EVENT};
for (int count = 0; count < 8; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedZDriveEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 9)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_EVENT};
for (int count = 0; count < 9; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedObjectiveEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 10)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_EVENT};
for (int count = 0; count < 10; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedLampEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 6)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_EVENTS};
for (int count = 0; count < 6; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_EVENTS);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedSpotLightEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 1)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT_EVENT};
for (int count = 0; count < 1; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedLFBLEvents (IMicroscope Manager, int[] events)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 2)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LFBL_EVENT};
for (int count = 0; count < 2; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LFBL_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ChangedAPBLEvents (IMicroscope Manager, int[] events){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (events == null || events.Length < 2)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_APBL_EVENT};
for (int count = 0; count < 2; count++)
Parameter.Add(events[count]);
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_APBL_EVENT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class LFBLController
{
/*=================================================================================================================*/
public static int setLFBLManualOperation (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LFBL_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LFBL_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setLFBLInit (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LFBL_INIT, enable ? 0 : 1};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LFBL_INIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setLFBLAbsPosition (IMicroscope Manager , int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_LFBL_ABS_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LFBL_ABS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setLFBLRelPosition (IMicroscope Manager , int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_LFBL_REL_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LFBL_REL_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int LFBLToMaxPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.LFBL_TO_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.LFBL_TO_MAX_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static (int, int) getLFBLStatus (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LFBL_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LFBL_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getLFBLManualOperation (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LFBL_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LFBL_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getLFBLAbsPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LFBL_ABS_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LFBL_ABS_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getLFBLMaxPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LFBL_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LFBL_MAX_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getLFBLMinPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LFBL_MIN_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LFBL_MIN_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class LampController
{
/*=====================================================================================================================*/
public static int setLampManualOperation (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置灯的手动操作是否打开或关闭
public static int setLampAbsPosition (IMicroscope Manager , int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_ABS_POSITION, value >= 0 && value <= 255 ? value : Math.Abs(value) % 255};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_ABS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 将功能单元定位到定义的绝对值
public static int setLampRelPosition (IMicroscope Manager , int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_REL_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_REL_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 相对于当前位置定位功能单元
public static int setLampTLILMode (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_TL_IL_MODE, enable ? 0 : 1};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_TL_IL_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 在 TL 和 IL 灯之间切换 enable TL
public static int setLampStepPosition (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_STEP_POSITION, enable ? 1 : -1};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_STEP_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 步进模式 enable: True 1 False -1
public static int setLampStepMode (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_STEP_MODE, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_STEP_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置步进模式灯
public static int setLampOnOff (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_ONOFF, 0, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_ONOFF);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置快门灯
public static int setLampMode (IMicroscope Manager , int enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_LAMP_MODE, enable == 2 ? 2 : enable == 1 ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_LAMP_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置灯泡模式
public static (int, int, int) getLampSTATUS (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int CloseStatus = Settings.DEFAULT_INT ;
int Step_Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, CloseStatus, Step_Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 2)
{
isWarning = Settings.RECODE_SUCCEED;
CloseStatus = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
Step_Status = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, CloseStatus, Step_Status);
} // 读取灯的当前状态
public static (int, int, int) getLampAbsPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int TL_Status = Settings.DEFAULT_INT ;
int RL_Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, TL_Status, RL_Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_ABS_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_ABS_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 2)
{
isWarning = Settings.RECODE_SUCCEED;
TL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
RL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, TL_Status, RL_Status);
} // 输出功能单元的当前位置
public static (int, int, int) getLampMinPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int TL_Status = Settings.DEFAULT_INT ;
int RL_Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, TL_Status, RL_Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_MIN_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_MIN_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 2)
{
isWarning = Settings.RECODE_SUCCEED;
TL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
RL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, TL_Status, RL_Status);
} // 返回最小可能的灯参数
public static (int, int, int) getLampMaxPosition (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int TL_Status = Settings.DEFAULT_INT ;
int RL_Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, TL_Status, RL_Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_MAX_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 2)
{
isWarning = Settings.RECODE_SUCCEED;
TL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
RL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, TL_Status, RL_Status);
} // 返回最高的可能灯泡参数
public static (int, int, int) getLampOnOff (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int TL_Status = Settings.DEFAULT_INT ;
int RL_Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, TL_Status, RL_Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_ONOFF};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_ONOFF);
if (index >= 0 && ResultBuffer.Count > index + 2)
{
isWarning = Settings.RECODE_SUCCEED;
TL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
RL_Status = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, TL_Status, RL_Status);
} // 获取快门灯
public static (int, int) getLampStepMode (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_STEP_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_STEP_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取步进模式灯
public static (int, int) getLampManualOperation (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 读取灯的手动操作是否打开或关闭
public static (int, int) getLampMode (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if(Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_LAMP_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_LAMP_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取灯泡模式
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class MasterController
{
public static int setMasterReset (IMicroscope Manager )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_RESET};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_RESET);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}// 重置显微镜
public static int setMasterDefault (IMicroscope Manager ){
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_DEFAULT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_DEFAULT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 重置显微镜为默认值
public static int setMasterConfigMode (IMicroscope Manager , bool enable )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_CONFIG_MODE, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_CONFIG_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}// 设置显微镜配置模式
public static int setMasterWaitTimes (IMicroscope Manager , int waittimes )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_WAIT_TIMES, waittimes <= 0 ? 0 : waittimes};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_WAIT_TIMES);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置显微镜等待时间
public static int setManualOptionStatus (IMicroscope Manager , bool enable )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_MASTER_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_MASTER_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置显微镜手动操作
public static (int, int) getMicroscopeInitStatus (IMicroscope Manager )
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_MASTER_INIT_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_MASTER_INIT_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取显微镜初始化状态
public static (int, int) getMasterFirmwareStatus (IMicroscope Manager )
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_MASTER_FIRMWARE_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_MASTER_FIRMWARE_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取显微镜固件加载状态
public static (int, int) getMasterConfigMode (IMicroscope Manager )
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_MASTER_CONFIG_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_MASTER_CONFIG_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取显微镜配置模式
public static (int, int) getManualOptionStatus (IMicroscope Manager )
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_MASTER_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_MASTER_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { System.Console.WriteLine($"{MicUtil.ConvertToUtf8(E.Message)}"); }
return (isWarning, Status);
} // 获取显微镜手动开关状态
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class ObjectiveController
{
/*========================================================================================================================*/
public static int setObjectiveManualOperation (IMicroscope Manager, bool value )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_MANUAL_OPERATION, value ? 1 : 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveAbsPosition (IMicroscope Manager, int value )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_ABS_POSITION, value >= 1 && value <= 7 ? value : value % 7 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_ABS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveRelPosition (IMicroscope Manager, int value )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_REL_POSITION, value };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_REL_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveOperationMode (IMicroscope Manager, int value )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_OPERATION_MODE, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_OPERATION_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveDRYMode (IMicroscope Manager, string value )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_DRY_MODE };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, String.Format(MicSettings.MicParameterFrame, value));
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_DRY_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveMethodParameter (IMicroscope Manager, int value, string[] data)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_METHOD_PARAMETER , value};
string Tail = String.Format(MicSettings.MicParameterFrame, String.Join(" ", data));
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, Tail);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_METHOD_PARAMETER);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectivePathoMode (IMicroscope Manager, int value )
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_PATHO_MODE, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_PATHO_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setObjectiveDIP (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_OBJECTIVE_DIP};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_OBJECTIVE_DIP);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static (int, int, int, int, int) getObjectiveStatus (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Item1 = Settings.DEFAULT_INT ;
int Item2 = Settings.DEFAULT_INT ;
int Item3 = Settings.DEFAULT_INT ;
int Item4 = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Item1, Item2, Item3, Item4);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 4)
{
isWarning = Settings.RECODE_SUCCEED;
Item1 = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
Item2 = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
Item3 = MicUtil.ConvertToInt(ResultBuffer[index + 3]);
Item4 = MicUtil.ConvertToInt(ResultBuffer[index + 4]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Item1, Item2, Item3, Item4);
}
public static (int, int) getObjectiveManualOperationStatus (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getObjectiveAbsPosition (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_ABS_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_ABS_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getObjectiveOperationStatus (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_OPERATION_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_OPERATION_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, string) getObjectiveDryMode (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
string Status = Settings.DEFAULT_STR ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
string[] ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_DRY_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.ConvertStringList(ReadBuffer, MicSettings.MicFrameSpace);
index = MicUtil.StringListIndexOf(ResultBuffer, MicID.GET_OBJECTIVE_DRY_MODE.ToString());
if (index >= 0 && ResultBuffer.Length > index + 1)
{
Status = ResultBuffer[1] ;
isWarning = Settings.RECODE_SUCCEED ;
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, string) getObjectiveMethodParameter (IMicroscope Manager, int level, int parameter )
{
int isWarning = Settings.RECODE_FAILURE ;
int Objective = Settings.DEFAULT_INT ;
int Source = Settings.DEFAULT_INT ;
string Status = Settings.DEFAULT_STR ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
string[] ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_METHOD_PARAMETER, level, parameter};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.ConvertStringList(ReadBuffer, MicSettings.MicFrameSpace);
index = MicUtil.StringListIndexOf(ResultBuffer, MicID.GET_OBJECTIVE_METHOD_PARAMETER.ToString());
if (index >= 0 && ResultBuffer.Length > index + 3)
{
Objective = MicUtil.ConvertToInt(ResultBuffer[1]) ;
Source = MicUtil.ConvertToInt(ResultBuffer[2]) ;
Status = ResultBuffer[3] ;
Status = Status.Replace(MicSettings.MicFrameTails, "");
isWarning = Objective == level && Source == parameter ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getObjectiveMinPosition (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_MIN_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_MIN_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getObjectiveMaxPosition (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_MAX_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_MAX_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int) getObjectivePathoMode (IMicroscope Manager)
{
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_OBJECTIVE_PATHO_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_OBJECTIVE_PATHO_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
using YQLUtils;
namespace YQLInterfaces
{
public class SerialPortReader: YQLInterface, ISerialPort
{
public ISerialPort Instance() { return new SerialPortReader(); }
public bool hasManager { get { return Manager != null; } }
public bool hasParameter { get { return Parameter != null; } }
public bool IsValid { get { return hasManager && hasParameter; } }
public bool IsAvailable { get { return IsValid && Manager.IsOpen; } }
public bool IsOpen { get { return IsValid && Manager.IsOpen; } }
public int Open () {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (IsOpen)
Close();
if (!hasManager)
initManager();
if (!hasManager)
return isWarning;
Manager.PortName = Parameter.PortName ;
Manager.BaudRate = Parameter.BaudRate ;
Manager.DataBits = Parameter.DataBits ;
Manager.StopBits = (StopBits)Parameter.StopBits ;
Manager.Parity = (Parity)Parameter.Parity ;
Manager.ReadTimeout = Parameter.ReadTimeout ;
Manager.WriteTimeout = Parameter.SendTimeout ;
Manager.Open();
isWarning = Manager.IsOpen ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public int Close () {
int isWarning = Settings.RECODE_FAILURE;
try
{
if(hasManager)
{
Manager.Close();
Manager.Dispose();
}
isWarning = !hasManager || !Manager.IsOpen ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public int ReOpen () {
Close();
return Open();
}
public void initManager () {
try
{
initParameter();
if(!hasManager)
{
Manager = new SerialPort();
}
}
catch (Exception E) {
YQLUtil.Print_Exception(E);
Manager = null;
}
}
public void deleManager () {
try
{
if(hasManager)
{
Manager.Close();
Manager.Dispose();
}
Manager = null;
GC.Collect();
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
}
public void initParameter () {
try
{
if (!hasParameter || !Parameter.hasPortName || !Parameter.hasBaudRate)
Parameter = new SerialContext();
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
}
public void deleParameter () {
Parameter = null;
GC.Collect();
}
public void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0)
{
initParameter();
setParameter(portname, baudrate, databits, stopbits, parity);
}
public string ReadString (string frameTail, int timeout = 100)
{
var result = Settings.DEFAULT_STR;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return result;
}
public byte[] ReadBinary (string frameTail, int timeout = 100)
{
var result = Settings.DEFAULT_BYTE_ARRAY;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return result;
}
public int SendString (string buffer)
{
var isWarning = Settings.RECODE_FAILURE;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendString(Manager, buffer);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public int SendBinary (byte[] buffer)
{
var isWarning = Settings.RECODE_FAILURE;
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendBinary(Manager, buffer);
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public string WaitDone (string buffer, string frameTail, int timeout = 100, int waittime = 50)
{
var result = Settings.DEFAULT_STR;
lock (IOLocker)
{
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendString(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
AppTimeLoop.ProcessEvents(waittime);
result = SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
}
return result;
}
public byte[] WaitDone (byte[] buffer, string frameTail, int timeout = 100, int waittime = 50)
{
var result = Settings.DEFAULT_BYTE_ARRAY;
lock (IOLocker)
{
try
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendBinary(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
AppTimeLoop.ProcessEvents(waittime);
result = SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
}
return result;
}
private SerialPort Manager = null;
private SerialContext Parameter = null;
protected static readonly object IOLocker = new object();
public SerialPortReader()
{
initialization("SerialPortReader");
}
public override void initValue()
{
initParameter();
initManager ();
}
public override void deleValue()
{
deleParameter();
deleManager ();
}
~SerialPortReader() { deinitialize(); }
public void Dispose()
{
deinitialize();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class SpotLightController
{
/*=================================================================================================================*/
public static int setSpotLightManualOperation (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置摆动聚光镜手动操作
public static int setSpotLight (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置摆动聚光镜状态
public static int setSpotLightMagLevel (IMicroscope Manager , int objective, string StringNA ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT_MAG_LEVEL, objective};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, String.Format(MicSettings.MicParameterFrame, StringNA));
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT_MAG_LEVEL);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置摆动聚光镜定义放大倍数
public static int setSpotLightMode (IMicroscope Manager , bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT_MODE, enable ? 0 : 1};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置摆动聚光镜定义放大倍数
public static int setSpotLightObjectivePosition (IMicroscope Manager , int objective, bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_SPOTLIGHT_OBJECTIVE_POSITION, objective, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_SPOTLIGHT_OBJECTIVE_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
} // 设置摆动聚光镜定义放大倍数
public static (int, int) getSpotLightStatus (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_SPOTLIGHT_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_SPOTLIGHT_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取摆动聚光镜状态
public static (int, int) getSpotLightManualOperation (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_SPOTLIGHT_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_SPOTLIGHT_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 读取摆动聚光镜手动操作
public static (int, int) getSpotLight (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_SPOTLIGHT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_SPOTLIGHT);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取摆动聚光镜状态
public static (int, string) getSpotLightMagLevel (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
string Status = Settings.DEFAULT_STR ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
string[] ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_SPOTLIGHT_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.ConvertStringList(ReadBuffer, MicSettings.MicFrameSpace);
index = MicUtil.StringListIndexOf(ResultBuffer, MicID.GET_SPOTLIGHT_MODE.ToString());
if (index >= 0 && ResultBuffer.Length > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = ResultBuffer[index + 1];
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取摆动聚光镜定义放大倍数
public static (int, int) getSpotLightMode (IMicroscope Manager ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_SPOTLIGHT_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_SPOTLIGHT_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取摆动聚光镜定义放大倍数
public static (int, int) getSpotLightObjectivePosition (IMicroscope Manager , int objective ) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null)
return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_SPOTLIGHT_OBJECTIVE_POSITION, objective};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_SPOTLIGHT_OBJECTIVE_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
} // 获取摆动聚光镜定义放大倍数
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YQLUtils;
using YQLInterfaces;
namespace ILeiCaMicroscope
{
public class ZDriverController
{
/*=====================================================================================================================*/
/*=====================================================================================================================*/
public static int setZDriverManualOptionStatus (IMicroscope Manager,bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_MANUAL_OPERATION, enable ? 1 : 0};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_MANUAL_OPERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverReset (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_RESET};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_RESET);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverInit (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_INIT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_INIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverBreak (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_BREAK};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_BREAK);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverAbsPosition (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_ABS_POSITION, value <= 0 ? 0 : value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_ABS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverRelPosition (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_REL_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_REL_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverConstPosition (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_CONST_POSITION, value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_CONST_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverLowerLimit (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_LOWER_LIMIT, value < 0 ? -1 : value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_LOWER_LIMIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverFocusLimit (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_FOCUS_LIMIT, value <= 0 ? 0 : value};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_FOCUS_LIMIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverUpperLimit (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_UPPER_LIMIT, value <= 0 ? -1 : value };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_UPPER_LIMIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverAcceleration (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_ACCELERATION, value <= 0 ? 0 : value };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_ACCELERATION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverSpeed (IMicroscope Manager, int value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_SPEED, value <= 0 ? 0 : value };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_SPEED);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ZDriverMoveToFocusLimit (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.Z_DRIVER_MOVE_TO_FOCUS_LIMIT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.Z_DRIVER_MOVE_TO_FOCUS_LIMIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ZDriverMoveToLowerLimit (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.Z_DRIVER_MOVE_TO_LOWER_LIMIT };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.Z_DRIVER_MOVE_TO_LOWER_LIMIT);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ZDriverPositionAsFocus (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_FOCUS_POSITION };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_FOCUS_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ZDriverPositionAsLower (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_LOWER_POSITION };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_LOWER_POSITION);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int ZDriverInitRange (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_INIT_RANGE };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_INIT_RANGE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverMoveMode (IMicroscope Manager, bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_MOVE_MODE, enable ? 1 : 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_MOVE_MODE);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverFocusLimitEnable (IMicroscope Manager, bool enable ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_FOCUS_LIMIT_ENABLED, enable ? 1 : 0 };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_FOCUS_LIMIT_ENABLED);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static int setZDriverInitMode (IMicroscope Manager, string value ) {
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null) return isWarning;
string ReadBuffer;
int index;
List<int> ResultBuffer;
List<int> Parameter = new List<int>() { MicID.SET_Z_DRIVER_INIT_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, String.Format(MicSettings.MicParameterFrame, value));
if (!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicMaxFrameTimeOut, MicSettings.MicFrameWaitTimes);
if (!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.SET_Z_DRIVER_FOCUS_LIMIT_ENABLED);
isWarning = index >= 0 && ResultBuffer.Count > index ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return isWarning;
}
public static (int, int, int, int, int,int ) getZDriverStatus (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Moving = Settings.DEFAULT_INT ;
int Lower = Settings.DEFAULT_INT ;
int Upper = Settings.DEFAULT_INT ;
int LowLimit = Settings.DEFAULT_INT ;
int Focus = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Moving, Lower, Upper, LowLimit, Focus);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 5)
{
isWarning = Settings.RECODE_SUCCEED;
Moving = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
Lower = MicUtil.ConvertToInt(ResultBuffer[index + 2]);
Upper = MicUtil.ConvertToInt(ResultBuffer[index + 3]);
LowLimit = MicUtil.ConvertToInt(ResultBuffer[index + 4]);
Focus = MicUtil.ConvertToInt(ResultBuffer[index + 5]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Moving, Lower, Upper, LowLimit, Focus);
}
public static (int, int ) getZDriverManualOptionStatus (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_MANUAL_OPERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_MANUAL_OPERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverFirmwareStatus (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_FIRMWARE_STATUS};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_FIRMWARE_STATUS);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverAbsPosition (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_ABS_POSITION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_ABS_POSITION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverLowerLimit (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_LOWER_LIMIT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_LOWER_LIMIT);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverFocusLimit (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_FOCUS_LIMIT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_FOCUS_LIMIT);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverAcceleration (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_ACCELERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_ACCELERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverSpeed (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_SPEED};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_SPEED);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, float ) getZDriverConvertFactor (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
float Status = Settings.DEFAULT_FLOAT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_CONVERT_FACTOR};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_CONVERT_FACTOR);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToFloat(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverMinAcceleration (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_MIN_ACCELERATION};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_MIN_ACCELERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverMaxAcceleration (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_MAX_ACCELERATION };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_MAX_ACCELERATION);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverMoveMode (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_MOVE_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_MOVE_MODE);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverFocusLimitEnable (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_FOCUS_LIMIT_ENABLED};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_FOCUS_LIMIT_ENABLED);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverMinSpeed (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_MIN_SPEED};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_MIN_SPEED);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverMaxSpeed (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_MAX_SPEED };
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_MAX_SPEED);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, int ) getZDriverUpperLimit (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
int Status = Settings.DEFAULT_INT ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
List<int> ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_UPPER_LIMIT};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.Parser(ReadBuffer, MicSettings.MicFrameSpace);
index = ResultBuffer.IndexOf(MicID.GET_Z_DRIVER_UPPER_LIMIT);
if (index >= 0 && ResultBuffer.Count > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = MicUtil.ConvertToInt(ResultBuffer[index + 1]);
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
public static (int, string ) getZDriverInitMode (IMicroscope Manager) {
int isWarning = Settings.RECODE_FAILURE ;
string Status = Settings.DEFAULT_STR ;
try
{
if (Manager == null) return (isWarning, Status);
string ReadBuffer ;
int index ;
string[] ResultBuffer ;
List<int> Parameter = new List<int>() { MicID.GET_Z_DRIVER_INIT_MODE};
string SendBuffer = MicUtil.ConvertToString(Parameter, MicSettings.MicFrameSpace, MicSettings.MicFrameTails);
if(!String.IsNullOrEmpty(SendBuffer))
{
ReadBuffer = Manager.WaitDone(SendBuffer, MicSettings.MicFrameTails, MicSettings.MicFrameTimeOut, MicSettings.MicFrameWaitTimes);
if(!String.IsNullOrEmpty(ReadBuffer))
{
ResultBuffer = MicUtil.ConvertStringList(ReadBuffer, MicSettings.MicFrameSpace);
index = MicUtil.StringListIndexOf(ResultBuffer, MicID.GET_Z_DRIVER_INIT_MODE.ToString());
if (index >= 0 && ResultBuffer.Length > index + 1)
{
isWarning = Settings.RECODE_SUCCEED;
Status = ResultBuffer[index + 1];
}
}
}
}
catch (Exception E) { YQLUtil.Print_Exception(E); }
return (isWarning, Status);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace YQLUtils
{
public class AppTimeLoop
{
public static void ProcessEvents(int interVal)
{
int waittime = 2;
DateTime startTime = DateTime.Now;
while(true)
{
DateTime endTime = DateTime.Now;
if ((int)(endTime - startTime).TotalMilliseconds >= interVal)
break;
Thread.Sleep(waittime);
}
}
public static void delay(int interVal)
{
if (interVal == 0)
return;
Thread.Sleep(Math.Abs(interVal));
}
public static void msleep(int interVal)
{
if (interVal == 0)
return;
Thread.Sleep(Math.Abs(interVal));
}
public static void sleep(int interVal)
{
if (interVal == 0)
return;
Thread.Sleep(Math.Abs(interVal * 1000));
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ILeiCaMicroscope
{
public class MicID
{
// 显微镜事件
public static int SET_DOCUPORT_EVENT = 60003 ; // 设置目镜端口事件
public static int SET_MASTER_EVENT = 70003 ; // 设置显微镜事件
public static int SET_Z_DRIVER_EVENT = 71003 ; // 设置Z轴事件
public static int SET_OBJECTIVE_EVENT = 76003 ; // 设置物镜事件
public static int SET_LAMP_EVENTS = 77003 ; // 设置光源事件
public static int SET_SPOTLIGHT_EVENT = 81003 ; // 设置回外摆式聚光镜事件
public static int SET_LFBL_EVENT = 83003 ; // 设置孔径光阑事件
public static int SET_APBL_EVENT = 84003 ; // 设置光源事件
// 显微镜控制指令
public static int SET_MASTER_MANUAL_OPERATION = 70005 ; // 打开或关闭整个支架的所有电子操作元件的手动操作
public static int GET_MASTER_MANUAL_OPERATION = 70006 ; // 返回手动操作是否打开或关闭
public static int SET_MASTER_RESET = 70007 ; // 重置整个支架 主处理器生成软件复位
public static int GET_MASTER_FIRMWARE_STATUS = 70008 ; // 固件状态 0 固件正在从引导扇区运行 1 固件正在从程序内存运行
public static int SET_MASTER_DEFAULT = 70018 ; // 显微镜重置为出厂默认设置
public static int GET_MASTER_CONFIG_MODE = 70074 ; // 获取配置模式 0 配置模式关闭 1 配置模式打开
public static int SET_MASTER_CONFIG_MODE = 70075 ; // 设置配置模式 0 配置模式关闭 1 配置模式打开
public static int GET_MASTER_INIT_STATUS = 70080 ; // 获取初始化状态
public static int SET_MASTER_WAIT_TIMES = 70082 ; // 设置等待时间
// Z轴控制指令
public static int GET_Z_DRIVER_STATUS = 71004; // 参数1:已到达下限硬件开关!参数2:已到达上限硬件开关!参数3:已到达下限阈值!参数 4:焦点位置已到达
public static int SET_Z_DRIVER_MANUAL_OPERATION = 71005 ;// 打开或关闭Z轴的手动操作
public static int GET_Z_DRIVER_MANUAL_OPERATION = 71006 ;// 返回手动操作是否打开或关闭
public static int SET_Z_DRIVER_RESET = 71007 ;// 复位单元 参数重置为默认值
public static int GET_Z_DRIVER_FIRMWARE_STATUS = 71008 ;// 固件状态 0 固件正在从引导扇区运行 1 固件正在从程序内存运行
public static int SET_Z_DRIVER_INIT = 71020 ;// 初始化 Z-DRIVE Z-DRIVE 移动到下方硬件端开关并重置零点
public static int SET_Z_DRIVER_BREAK = 71021 ;// 中止 Z-DRIVE 的当前定位
public static int SET_Z_DRIVER_ABS_POSITION = 71022 ; // 将功能单元定位到以微步(计数)为单位的给定绝对值
public static int GET_Z_DRIVER_ABS_POSITION = 71023 ; // 以微步(计数)为单位读取功能单元的当前位置
public static int SET_Z_DRIVER_REL_POSITION = 71024 ; // 将功能单元定位到以微步(计数)为单位的给定相对位置值
public static int SET_Z_DRIVER_CONST_POSITION = 71025 ; // 以恒定速度移动功能单元
public static int SET_Z_DRIVER_LOWER_LIMIT = 71026 ; // 将下限阈值设置为给定的 Z 轴位置
public static int SET_Z_DRIVER_FOCUS_LIMIT = 71027 ; // 将焦点位置设置为指定的 Z 轴位置
public static int GET_Z_DRIVER_LOWER_LIMIT = 71028 ; // 读取当前下限的Z值
public static int GET_Z_DRIVER_FOCUS_LIMIT = 71029 ; // 读取当前焦点位置。
public static int SET_Z_DRIVER_ACCELERATION = 71030 ; // 设置新的加速度参数
public static int GET_Z_DRIVER_ACCELERATION = 71031 ; // 读取加速度参数
public static int SET_Z_DRIVER_SPEED = 71032 ; // 定义Z轴运动的最大速度
public static int GET_Z_DRIVER_SPEED = 71033 ; // 读取当前Z轴运动速度
public static int Z_DRIVER_MOVE_TO_FOCUS_LIMIT = 71034 ; // 将 Z 轴驱动器移动到当前焦点位置
public static int Z_DRIVER_MOVE_TO_LOWER_LIMIT = 71035 ; // 将 Z 轴驱动移至当前下限
public static int SET_Z_DRIVER_LOWER_POSITION = 71037 ; // 将当前 Z 轴位置定义为下限阈值
public static int SET_Z_DRIVER_FOCUS_POSITION = 71038 ; // 将当前 Z 轴位置定义为下限阈值
public static int GET_Z_DRIVER_CONVERT_FACTOR = 71042 ; // 获取转换因子
public static int SET_Z_DRIVER_INIT_RANGE = 71044 ; // 初始化范围Z
public static int GET_Z_DRIVER_MIN_ACCELERATION = 71048 ; // 读取加速度参数
public static int GET_Z_DRIVER_MAX_ACCELERATION = 71049 ; // 读取加速度参数
public static int SET_Z_DRIVER_MOVE_MODE = 71050 ; // 将当前Z 驱动运动模式0 = 细步 1 = 粗步 2 = 切换
public static int GET_Z_DRIVER_MOVE_MODE = 71051 ; // 将当前Z 驱动运动模式0 = 细步 1 = 粗步 2 = 切换
public static int SET_Z_DRIVER_FOCUS_LIMIT_ENABLED = 71053 ; // 激活焦点限制活动模式
public static int GET_Z_DRIVER_FOCUS_LIMIT_ENABLED = 71054 ; // 激活焦点限制活动模式
public static int SET_Z_DRIVER_UPPER_LIMIT = 71055 ; // 上限阈值设置为给定的 Z 位置
public static int GET_Z_DRIVER_UPPER_LIMIT = 71056 ; // 读取上限阈值的当前 Z 值
public static int GET_Z_DRIVER_MIN_SPEED = 71058 ; // 读取速度参数
public static int GET_Z_DRIVER_MAX_SPEED = 71059 ; // 读取速度参数
public static int SET_Z_DRIVER_INIT_MODE = 71065 ; // 设置开机时 Z 轴的初始化模式 - = 没有初始化Z轴 N = 低于 4 毫米或低于软件阈值(默认)Z = 低于软件阈值 如果未设置阈值,则调整零位。
public static int GET_Z_DRIVER_INIT_MODE = 71066 ; // 获取Z轴初始化状态
public static int GET_OBJECTIVE_STATUS = 76004 ; // 获取物镜状态
public static int SET_OBJECTIVE_MANUAL_OPERATION = 76005 ; // 打开或关闭Z轴的手动操作
public static int GET_OBJECTIVE_MANUAL_OPERATION = 76006 ; // 返回手动操作是否打开或关闭
public static int SET_OBJECTIVE_ABS_POSITION = 76022 ; // 设置物镜位置
public static int GET_OBJECTIVE_ABS_POSITION = 76023 ; // 获取物镜位置
public static int SET_OBJECTIVE_REL_POSITION = 76024 ; // 物镜相对移动
public static int SET_OBJECTIVE_OPERATION_MODE = 76025 ; // 设置物镜操作模式
public static int GET_OBJECTIVE_OPERATION_MODE = 76026 ; // 获取物镜操作模式
public static int SET_OBJECTIVE_DRY_MODE = 76027 ; // 设置物镜DRY模式
public static int GET_OBJECTIVE_DRY_MODE = 76028 ; // 获取物镜DRY模式
public static int SET_OBJECTIVE_METHOD_PARAMETER = 76032 ; // 设置物镜方法参数
public static int GET_OBJECTIVE_METHOD_PARAMETER = 76033 ; // 获取物镜方法参数
public static int GET_OBJECTIVE_MIN_POSITION = 76038 ; // 获取最小物镜位置
public static int GET_OBJECTIVE_MAX_POSITION = 76039 ; // 获取最大物镜位置
public static int SET_OBJECTIVE_DIP = 76040 ; // 获取DIP
public static int SET_OBJECTIVE_PATHO_MODE = 76046 ; // 设置物镜病理模式
public static int GET_OBJECTIVE_PATHO_MODE = 76047 ; // 获取物镜病理模式
/*=================================================================================================================*/
public static int GET_LAMP_STATUS = 77004 ; // 读取灯的当前状态
public static int SET_LAMP_MANUAL_OPERATION = 77005 ; // 设置灯的手动操作是否打开或关闭
public static int GET_LAMP_MANUAL_OPERATION = 77006 ; // 读取灯的手动操作是否打开或关闭
public static int SET_LAMP_ABS_POSITION = 77020 ; // 将功能单元定位到定义的绝对值
public static int GET_LAMP_ABS_POSITION = 77021 ; // 输出功能单元的当前位置
public static int SET_LAMP_REL_POSITION = 77022 ; // 相对于当前位置定位功能单元
public static int GET_LAMP_MIN_POSITION = 77023 ; // 返回最小可能的灯参数
public static int GET_LAMP_MAX_POSITION = 77024 ; // 返回最高的可能灯泡参数
public static int SET_LAMP_TL_IL_MODE = 77025 ; // 在 TL 和 IL 灯之间切换
public static int SET_LAMP_STEP_POSITION = 77029 ; // 步进模式
public static int SET_LAMP_STEP_MODE = 77030 ; // 设置步进模式灯
public static int GET_LAMP_STEP_MODE = 77031 ; // 获取步进模式灯
public static int SET_LAMP_ONOFF = 77032 ; // 设置快门灯
public static int GET_LAMP_ONOFF = 77033 ; // 获取快门灯
public static int SET_LAMP_MODE = 77038 ; // 设置灯泡模式
public static int GET_LAMP_MODE = 77039 ; // 获取灯泡模式
/*=================================================================================================================*/
public static int SET_SPOTLIGHT_MANUAL_OPERATION = 81005 ; // 设置摆动聚光镜手动操作
public static int SET_SPOTLIGHT = 81022 ; // 设置摆动聚光镜状态
public static int SET_SPOTLIGHT_MAG_LEVEL = 81026 ; // 设置摆动聚光镜定义放大倍数
public static int SET_SPOTLIGHT_MODE = 81028 ; // 设置摆动聚光镜定义放大倍数
public static int SET_SPOTLIGHT_OBJECTIVE_POSITION = 81030 ; // 设置摆动聚光镜定义放大倍数
public static int GET_SPOTLIGHT_STATUS = 81004 ; // 获取摆动聚光镜状态
public static int GET_SPOTLIGHT_MANUAL_OPERATION = 81006 ; // 读取摆动聚光镜手动操作
public static int GET_SPOTLIGHT = 81023 ; // 获取摆动聚光镜状态
public static int GET_SPOTLIGHT_MAG_LEVEL = 81027 ; // 获取摆动聚光镜定义放大倍数
public static int GET_SPOTLIGHT_MODE = 81029 ; // 获取摆动聚光镜定义放大倍数
public static int GET_SPOTLIGHT_OBJECTIVE_POSITION = 81031 ; // 获取摆动聚光镜定义放大倍数
/*=================================================================================================================*/
public static int GET_LFBL_STATUS = 83003 ;
public static int SET_LFBL_MANUAL_OPERATION = 83005 ;
public static int GET_LFBL_MANUAL_OPERATION = 83006 ;
public static int SET_LFBL_INIT = 83020 ;
public static int SET_LFBL_ABS_POSITION = 83022 ;
public static int GET_LFBL_ABS_POSITION = 83023 ;
public static int SET_LFBL_REL_POSITION = 83024 ;
public static int GET_LFBL_MAX_POSITION = 83027 ;
public static int GET_LFBL_MIN_POSITION = 83028 ;
public static int LFBL_TO_MAX_POSITION = 83029 ;
/*=================================================================================================================*/
public static int GET_APBL_STATUS = 84003 ;
public static int SET_APBL_MANUAL_OPERATION = 84005 ;
public static int GET_APBL_MANUAL_OPERATION = 84006 ;
public static int SET_APBL_INIT = 84020 ;
public static int SET_APBL_ABS_POSITION = 84022 ;
public static int GET_APBL_ABS_POSITION = 84023 ;
public static int SET_APBL_REL_POSITION = 84024 ;
public static int GET_APBL_MAX_POSITION = 84027 ;
public static int GET_APBL_MIN_POSITION = 84028 ;
public static int APBL_TO_MAX_POSITION = 83029 ;
/*=================================================================================================================*/
public static int SET_DOCUPORT_MANUAL_OPERATION = 60005 ;
public static int SET_DOCUPORT_ABS_POSITION = 60022 ;
public static int SET_DOCUPORT_CONVERT_PORT = 60031 ;
public static int GET_DOCUPORT_STATUS = 60003 ;
public static int GET_DOCUPORT_MANUAL_OPERATION = 60006 ;
public static int GET_DOCUPORT_ABS_POSITION = 60023 ;
public static int GET_DOCUPORT_MIN_POSITION = 60025 ;
public static int GET_DOCUPORT_MAX_POSITION = 60026 ;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ILeiCaMicroscope
{
public class MicSettings
{
public static string MicFrameSpace = " " ;
public static string MicFrameTails = "\r" ;
public static string MicParameterFrame = " %s\r" ;
public static int MicFrameTimeOut = 500 ;
public static int MicMaxFrameTimeOut = 60000 ;
public static int MicFrameWaitTimes = 0 ;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ILeiCaMicroscope
{
class MicUtil
{
public static string ConvertToString(List<int> buffer, string space = " ", string tail = "\r")
{
try
{
if(buffer.Count <= 0)
return default(string);
StringBuilder StringBuffer = new StringBuilder();
foreach (int data in buffer)
{
StringBuffer.Append(data.ToString());
StringBuffer.Append(space);
}
StringBuffer.Remove(StringBuffer.Length - space.Length, space.Length);
StringBuffer.Append(tail);
return StringBuffer.ToString();
}
catch (Exception) { }
return default(string);
}
public static string MicroscopeCommand(int ID, string parameter)
{
try
{
string buffer = ID.ToString() + " " + parameter + "\r";
return buffer;
}catch(Exception)
{
return null;
}
}
public static string ConvertToUtf8(string buffer)
{
try
{
if (buffer == null)
return default(string);
UTF8Encoding utf8 = new UTF8Encoding();
return utf8.GetString(utf8.GetBytes(buffer));
}
catch (Exception)
{
}
return default(string);
}
public static int ConvertToInt(object buffer)
{
try
{
if (buffer == null)
return default(int);
if (buffer.GetType() == typeof(int))
return (int)buffer;
return Convert.ToInt32(buffer);
}
catch (Exception)
{
return default(int);
}
}
public static float ConvertToFloat(object buffer)
{
try
{
if (buffer == null)
return default(float);
if (buffer.GetType() == typeof(float))
return (int)buffer;
return Convert.ToSingle(buffer);
}
catch (Exception)
{
return default(float);
}
}
public static int ConvertObjective(string buffer)
{
try
{
if (string.IsNullOrEmpty(buffer))
return default(int);
return Convert.ToInt32(buffer);
}catch(Exception){
return default(int) ;
}
}
public static List<int> Parser(string buffer, string space = " ")
{
List<int> Array = new List<int>();
try
{
if (string.IsNullOrEmpty(buffer))
return Array;
String[] Buffer = buffer.Split(space.ToCharArray());
foreach(string data in Buffer)
{
Array.Add(MicUtil.ConvertObjective(data));
}
}
catch (Exception)
{ }
return Array;
}
public static String[] ConvertStringList(string buffer, string space = " ")
{
try
{
if (string.IsNullOrEmpty(buffer))
return default(String[]);
String[] Buffer = buffer.Split(space.ToCharArray());
return Buffer;
}
catch (Exception)
{ }
return default(String[]);
}
public static int StringListIndexOf(string[] buffer, string target)
{
int index = -1;
int count = 0;
foreach(string data in buffer)
{
if(data.ToLower().Equals(target.ToLower()))
{
index = count;
break;
}
count += 1;
}
return index;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
namespace YQLUtils
{
using YQLInterfaces;
public class SerialPortUtil
{
public static int Open(SerialPort Manager, SerialContext Parameter)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null || Parameter == null)
return isWarning;
if (Manager.IsOpen)
SerialPortUtil.Close(Manager);
Manager.PortName = Parameter.PortName ;
Manager.BaudRate = Parameter.BaudRate ;
Manager.DataBits = Parameter.DataBits ;
Manager.StopBits = (StopBits)Parameter.StopBits ;
Manager.Parity = (Parity) Parameter.Parity ;
Manager.ReadTimeout = Parameter.ReadTimeout ;
Manager.WriteTimeout = Parameter.SendTimeout ;
Manager.Open ( );
isWarning = Manager.IsOpen ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
catch (Exception) { }
return isWarning;
}
public static int Open(SerialPort Manager, LeiCaContext Parameter)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null || Parameter == null)
return isWarning;
if (Manager.IsOpen)
SerialPortUtil.Close(Manager);
Manager.PortName = Parameter.PortName ;
Manager.BaudRate = Parameter.BaudRate ;
Manager.DataBits = Parameter.DataBits ;
Manager.StopBits = (StopBits)Parameter.StopBits ;
Manager.Parity = (Parity) Parameter.Parity ;
Manager.ReadTimeout = Parameter.ReadTimeout ;
Manager.WriteTimeout = Parameter.SendTimeout ;
Manager.Open ( );
isWarning = Manager.IsOpen ? Settings.RECODE_SUCCEED : Settings.RECODE_FAILURE;
}
catch (Exception) { }
return isWarning;
}
public static int Close(SerialPort Manager)
{
int isWarning = Settings.RECODE_SUCCEED;
try
{
if (Manager == null)
return isWarning;
if (Manager.IsOpen)
{
Manager.Close();
}
}
catch (Exception) { }
return isWarning;
}
public static int SendString(SerialPort Manager, string buffer)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (buffer.Length == 0)
return isWarning;
Manager.Write(buffer);
isWarning = Settings.RECODE_SUCCEED;
}
catch (Exception) { }
return isWarning;
}
public static int SendBinary(SerialPort Manager, byte[] buffer)
{
int isWarning = Settings.RECODE_FAILURE;
try
{
if (Manager == null)
return isWarning;
if (buffer.Length == 0)
return isWarning;
Manager.Write(buffer, 0, buffer.Length);
isWarning = Settings.RECODE_SUCCEED;
}
catch (Exception) { }
return isWarning;
}
public static string ReadString(SerialPort Manager, string frameTail = null, int timeout=1000)
{
StringBuilder Buffer = new StringBuilder();
try
{
if (Manager == null)
return Buffer.ToString();
DateTime starttime = DateTime.Now ;
int readLength = 0 ;
int timeOffset ;
bool IsTail = (frameTail != null) && (frameTail.Length > 0);
bool atEnd = false;
while (true)
{
readLength = Manager.BytesToRead;
if (readLength > 0)
{
Buffer.Append(Manager.ReadExisting());
}
if (IsTail)
atEnd = Buffer.ToString().IndexOf(frameTail, 0) >= 0;
else
atEnd = Buffer.Length > 0;
if (atEnd)
break;
timeOffset = (int)(DateTime.Now - starttime).TotalMilliseconds;
if (timeOffset >= timeout)
break;
//AppTimeLoop.ProcessEvents(waittimes);
}
}
catch (Exception) { }
return Buffer.ToString();
}
public static byte[] ReadBinary(SerialPort Manager, string frameTail = null, int timeout = 1000)
{
List<byte> Buffer = new List<byte>();
try
{
if (Manager == null)
return Buffer.ToArray();
//int waittimes = 10 ;
DateTime starttime = DateTime.Now ;
int readLength = 0 ;
int timeOffset ;
bool IsTail = (frameTail != null) && (frameTail.Length > 0);
byte[] tailByteArray = IsTail ? Encoding.UTF8.GetBytes(frameTail) : null;
bool atEnd = false;
long index = -1;
while (true)
{
readLength = Manager.BytesToRead;
if (readLength > 0)
{
byte[] readbuffer = new byte[readLength];
int received_length = Manager.Read(readbuffer, 0, readbuffer.Length);
if(received_length > 0)
Buffer.AddRange(readbuffer);
}
if (IsTail)
{
try
{
index = IndexesOf(Buffer.ToArray(), 0, tailByteArray).First<long>();
}
catch (Exception) {
index = -1;
}
atEnd = index >= 0;
}
else
atEnd = Buffer.ToArray().Length > 0;
if (atEnd)
break;
timeOffset = (int)(DateTime.Now - starttime).TotalMilliseconds;
if (timeOffset >= timeout)
break;
//AppTimeLoop.ProcessEvents(waittimes);
}
}
catch (Exception) { }
return Buffer.ToArray();
}
public static IEnumerable<long> IndexesOf(byte[] source, int start, byte[] pattern)
{
if (source == null)
{
throw new ArgumentNullException(nameof(source));
}
if (pattern == null)
{
throw new ArgumentNullException(nameof(pattern));
}
long valueLength = source.LongLength;
long patternLength = pattern.LongLength;
if ((valueLength == 0) || (patternLength == 0) || (patternLength > valueLength))
{
yield break;
}
var badCharacters = new long[256];
for (var i = 0; i < 256; i++)
{
badCharacters[i] = patternLength;
}
var lastPatternByte = patternLength - 1;
for (long i = 0; i < lastPatternByte; i++)
{
badCharacters[pattern[i]] = lastPatternByte - i;
}
long index = start;
while (index <= valueLength - patternLength)
{
for (var i = lastPatternByte; source[index + i] == pattern[i]; i--)
{
if (i == 0)
{
yield return index;
break;
}
}
index += badCharacters[source[index + lastPatternByte]];
}
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace YQLUtils
{
public class Settings
{
public static int RECODE_SUCCEED = 1 ;
public static int RECODE_FAILURE = 0 ;
public static int RECODE_WARNING = 2 ;
public static int CODE_SUCCESS = 200 ;
public static int CODE_FAILURE = 500 ;
public static int CODE_WARNING = 201 ;
public static int AXIS_STATUS_REGISTER_0 = 0 ;
public static int AXIS_STATUS_REGISTER_1 = 1 ;
public static int AXIS_STATUS_REGISTER_2 = 2 ;
public static int AXIS_STATUS_REGISTER_3 = 3 ;
public static int AXIS_STATUS_REGISTER_4 = 4 ;
public static int READONLY_AXIS_STATUS_REGISTER_0 = 0 ;
public static int READONLY_AXIS_STATUS_REGISTER_1 = 1 ;
public static int READONLY_AXIS_STATUS_REGISTER_2 = 2 ;
public static int READONLY_AXIS_STATUS_REGISTER_3 = 3 ;
public static int READONLY_AXIS_STATUS_REGISTER_4 = 4 ;
public static int READONLY_AXIS_STATUS_REGISTER_5 = 5 ;
public static byte[] START_DECODE = { 0x16, 0x54, 0x0D };
public static byte[] STOP_DECODE = { 0x16, 0x55, 0x0D };
public static byte[] CONSOLE_MODE = { 0x16, 0x4D, 0x0D, 0x30, 0x34, 0x30, 0x31, 0x44, 0x30, 0x35, 0x2E };
public static byte[] GET_VERSION = { 0x16, 0x4D, 0x0D, 0x25, 0x25, 0x25, 0x56, 0x45, 0x52, 0x2E };
public static byte[] DECODE_TAIL = { 0x0D, 0x0A};
public static byte[] DECODE_FRAME_TAIL = { 0x06 };
public const string DEFAULT_STR = default(string );
public const bool DEFAULT_BOOL = default(bool );
public const short DEFAULT_SHORT = default(short );
public const ushort DEFAULT_USHORT = default(ushort );
public const int DEFAULT_INT = default(int );
public const uint DEFAULT_UINT = default(uint );
public const long DEFAULT_LONG = default(long );
public const ulong DEFAULT_ULONG = default(ulong );
public const float DEFAULT_FLOAT = default(float );
public const bool [] DEFAULT_BOOL_ARRAY = default(bool [] );
public const short [] DEFAULT_SHORT_ARRAY = default(short [] );
public const ushort [] DEFAULT_USHORT_ARRAY = default(ushort[] );
public const int [] DEFAULT_INT_ARRAY = default(int [] );
public const uint [] DEFAULT_UINT_ARRAY = default(uint [] );
public const long [] DEFAULT_LONG_ARRAY = default(long [] );
public const ulong [] DEFAULT_ULONG_ARRAY = default(ulong [] );
public const float [] DEFAULT_FLOAT_ARRAY = default(float [] );
public const byte [] DEFAULT_BIT = default(byte [] );
public const byte [] DEFAULT_BYTE_ARRAY = default(byte [] );
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
namespace YQLUtils
{
public class YQLUtil
{
public static string get_Exception(Exception E)
{
StringBuilder buffer = new StringBuilder();
if (E != null)
{
var stackTrace = new StackTrace(E, true);
foreach (var frame in stackTrace.GetFrames())
buffer.Append($"FileName: {frame.GetFileName()} MethodName: {frame.GetMethod().Name} Line: {frame.GetFileLineNumber()}\n\r");
}
if (buffer.Length <= 0)
buffer.Append("\n\r");
return buffer.ToString();
}
public static void Print_Exception(Exception E)
{
Console.Write($"{YQLUtil.get_Exception(E)}");
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment