Commit 3156f1bc authored by 徐生海's avatar 徐生海

Initial commit

parent 70f745f4
Pipeline #168 canceled 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 AppInterfaces
{
public class LeiCaContext : ContextInterface
{
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 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; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppInterfaces
{
public class SerialContext: ContextInterface
{
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 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; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AppInterfaces;
using AppUtils;
namespace ILeiCaMicroscope
{
public class LMicroscopeController
{
public static LMicroscopeInterface Instance()
{
return new ScanCodeReader();
}
public static int Open (LMicroscopeInterface manager)
{
try
{
return manager.Open();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static int Close (LMicroscopeInterface manager)
{
try
{
return manager.Close();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static int ReOpen (LMicroscopeInterface manager)
{
try
{
return manager.ReOpen();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static void initManager (LMicroscopeInterface manager)
{
try
{
manager.initManager();
}
catch (Exception) { }
return ;
}
public static void initParameter (LMicroscopeInterface manager)
{
try
{
manager.initParameter();
}
catch (Exception) { }
return;
}
public static string ReadString (LMicroscopeInterface manager, string frameTail, int timeout = 100)
{
try
{
return manager.ReadString(frameTail, timeout);
}
catch (Exception) { }
return default(string);
}
public static byte[] ReadBinary (LMicroscopeInterface manager, string frameTail, int timeout = 100)
{
try
{
return manager.ReadBinary(frameTail, timeout);
}
catch (Exception) { }
return default(byte[]);
}
public static int SendString (LMicroscopeInterface manager, string buffer)
{
try
{
return manager.Open();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static int SendBinary (LMicroscopeInterface manager, byte[] buffer)
{
try
{
return manager.Open();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static string WaitDone (LMicroscopeInterface manager, string buffer, string frameTail, int timeout = 100, int waittime = 50)
{
try
{
return manager.WaitDone(buffer, frameTail, timeout, waittime);
}
catch (Exception) { }
return default(string);
}
public static byte[] WaitDone (LMicroscopeInterface manager, byte[] buffer, string frameTail, int timeout = 100, int waittime = 50)
{
try
{
return manager.WaitDone(buffer, frameTail, timeout, waittime);
}
catch (Exception) { }
return default(byte[]);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AppInterfaces;
using AppUtils;
namespace IScanCode
{
public class ScanCodeController
{
public static IScanCodeInterface Instance()
{
return ScanCodeReader.GetInstance();
}
public static int Open (IScanCodeInterface manager)
{
try
{
return manager.Open();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static int Close (IScanCodeInterface manager)
{
try
{
return manager.Close();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static int ReOpen (IScanCodeInterface manager)
{
try
{
return manager.ReOpen();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static void initManager (IScanCodeInterface manager)
{
try
{
manager.initManager();
}
catch (Exception) { }
return ;
}
public static void initParameter (IScanCodeInterface manager)
{
try
{
manager.initParameter();
}
catch (Exception) { }
return;
}
public static string ReadString (IScanCodeInterface manager, string frameTail, int timeout = 100)
{
try
{
return manager.ReadString(frameTail, timeout);
}
catch (Exception) { }
return default(string);
}
public static byte[] ReadBinary (IScanCodeInterface manager, string frameTail, int timeout = 100)
{
try
{
return manager.ReadBinary(frameTail, timeout);
}
catch (Exception) { }
return default(byte[]);
}
public static int SendString (IScanCodeInterface manager, string buffer)
{
try
{
return manager.Open();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static int SendBinary (IScanCodeInterface manager, byte[] buffer)
{
try
{
return manager.Open();
}
catch (Exception) { }
return Settings.RECODE_FAILURE;
}
public static string WaitDone (IScanCodeInterface manager, string buffer, string frameTail, int timeout = 100, int waittime = 50)
{
try
{
return manager.WaitDone(buffer, frameTail, timeout, waittime);
}
catch (Exception) { }
return default(string);
}
public static byte[] WaitDone (IScanCodeInterface manager, byte[] buffer, string frameTail, int timeout = 100, int waittime = 50)
{
try
{
return manager.WaitDone(buffer, frameTail, timeout, waittime);
}
catch (Exception) { }
return default(byte[]);
}
public static string ScanCode (IScanCodeInterface manager, int timeout = 1000, int waittime = 50 )
{
try
{
return manager.ScanCode(timeout, waittime);
}
catch (Exception) { }
return default(string);
}
public static void StopScanCode (IScanCodeInterface manager, int timeout = 1000, int waittime = 50 )
{
try
{
manager.StopScanCode(timeout, waittime);
}
catch (Exception) { }
return ;
}
public static string SetHostMode (IScanCodeInterface manager, int timeout = 1000, int waittime = 50 )
{
try
{
return manager.SetHostMode(timeout, waittime);
}
catch (Exception) { }
return default(string);
}
public static string GetVersion (IScanCodeInterface manager, int timeout = 1000, int waittime = 50 )
{
try
{
return manager.GetVersion(timeout, waittime);
}
catch (Exception) { }
return default(string);
}
public static void ClearBuffer (IScanCodeInterface manager)
{
try
{
manager.ClearBuffer();
}
catch (Exception) { }
return ;
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppInterfaces
{
public class SerialPortController
{
private static readonly object IOLocker = new object();
public static int Open (SerialPortInterface manager){
try
{
return manager.Open();
}
catch (Exception) { }
return 0;
}
public static int Close (SerialPortInterface manager){
try
{
return manager.Close();
}
catch (Exception) { }
return 0;
}
public static int ReOpen (SerialPortInterface manager)
{
try
{
return manager.ReOpen();
}
catch (Exception) { }
return 0;
}
public static string ReadString (SerialPortInterface manager, string frameTail, int timeout = 100)
{
try
{
return manager.ReadString(frameTail, timeout);
}
catch (Exception) { }
return default(string);
}
public static byte[] ReadBinary (SerialPortInterface manager, string frameTail, int timeout = 100)
{
try
{
return manager.ReadBinary(frameTail, timeout);
}
catch (Exception) { }
return default(byte[]);
}
public static int SendString (SerialPortInterface manager, string buffer)
{
try
{
return manager.SendString(buffer);
}
catch (Exception) { }
return default(int);
}
public static int SendBinary (SerialPortInterface manager, byte[] buffer)
{
try
{
return manager.SendBinary(buffer);
}
catch (Exception) { }
return default(int);
}
public static string WaitDone (SerialPortInterface manager, string buffer, string frameTail, int timeout = 100, int waittime = 50)
{
lock(IOLocker)
{
try
{
return manager.WaitDone(buffer, frameTail, timeout, waittime);
}
catch (Exception) { }
}
return default(string);
}
public static byte[] WaitDone (SerialPortInterface manager, byte[] buffer, string frameTail, int timeout = 100, int waittime = 50)
{
lock (IOLocker)
{
try
{
return manager.WaitDone(buffer, frameTail, timeout, waittime);
}
catch (Exception) { }
}
return default(byte[]);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Reflection;
namespace AppInterfaces
{
public class Appinterface
{
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 System.IO;
using System.Collections;
using System.Reflection;
namespace AppInterfaces
{
public class ContextInterface:Appinterface
{
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
using AppInterfaces;
namespace ILeiCaMicroscope
{
public interface LMicroscopeInterface
{
bool hasManager { get; }
bool hasParameter { get; }
bool IsValid { get; }
bool IsAvailable { get; }
bool IsOpen { get; }
SerialPort manager { get; }
LeiCaContext parameter { 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 WaitDone (string buffer, string frameTail, int timeout = 100, int waittime = 50);
byte[] WaitDone (byte[] buffer, string frameTail, int timeout = 100, int waittime = 50);
LMicroscopeInterface Interface();
int setMasterEvents ( ); // 设置显微镜事件
int setZDriveEvents ( ); // 设置Z轴事件
int setObjectiveEvents ( ); // 设置物镜事件
int setTLFieldEvents ( ); // 设置孔径光阑事件
int setTLEvents ( ); // 设置光源事件
int setMasterReset ( ); // 重置显微镜
int setMasterDefault ( ); // 重置显微镜为默认值
int setMasterConfigMode (bool enable ); // 设置显微镜配置模式
int setMasterWaitTimes (int waittimes ); // 设置显微镜等待时间
int setManualOptionStatus (bool enable ); // 设置显微镜手动操作
(int, int) getMicroscopeInitStatus ( ); // 获取显微镜初始化状态
(int, int) getMasterFirmwareStatus ( ); // 获取显微镜固件加载状态
(int, int) getMasterConfigMode ( ); // 获取显微镜配置模式
(int, int) getManualOptionStatus ( ); // 获取显微镜手动开关状态
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IScanCode
{
public interface IScanCodeInterface
{
IScanCodeInterface 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);
string ScanCode (int timeout = 1000, int waittime = 50 );
void StopScanCode (int timeout = 1000, int waittime = 50 );
string SetHostMode (int timeout = 1000, int waittime = 50 );
string GetVersion (int timeout = 1000, int waittime = 50 );
void ClearBuffer ( );
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppInterfaces
{
public interface SerialPortInterface
{
SerialPortInterface 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 ILeiCaMicroscope
{
public class LMicroscopeReader: AbstractLMicroscopeInterface
{
/*===========================================================================*/
public override int setMasterEvents ( ) {
} // 设置显微镜事件
public override int setZDriveEvents ( ) {
} // 设置Z轴事件
public override int setObjectiveEvents ( ) {
} // 设置物镜事件
public override int setTLFieldEvents ( ) {
} // 设置孔径光阑事件
public override int setTLEvents ( ) {
} // 设置光源事件
public override int setMasterReset ( ) {
} // 重置显微镜
public override int setMasterDefault ( ) {
} // 重置显微镜为默认值
public override int setMasterConfigMode (bool enable ) {
} // 设置显微镜配置模式
public override int setMasterWaitTimes (int waittimes ) {
} // 设置显微镜等待时间
public override int setManualOptionStatus (bool enable ) {
} // 设置显微镜手动操作
public override (int, int) getMicroscopeInitStatus ( ) {
} // 获取显微镜初始化状态
public override (int, int) getMasterFirmwareStatus ( ) {
} // 获取显微镜固件加载状态
public override (int, int) getMasterConfigMode ( ) {
} // 获取显微镜配置模式
public override (int, int) getManualOptionStatus ( ) {
} // 获取显微镜手动开关状态
public LMicroscopeReader(string portname = "COM1" , int baudrate = 9600)
{
initialization("SerialPortReader");
setParameter(portname, baudrate);
}
~LMicroscopeReader()
{
deinitialize();
}
public override void initValue()
{
initParameter ();
initManager ();
}
public override void deleValue()
{
deleManager ();
deleParameter ();
}
public override LMicroscopeInterface Interface() { return new LMicroscopeReader(); }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
using AppUtils;
using AppInterfaces;
namespace IScanCode
{
public class ScanCodeReader: Appinterface, IScanCodeInterface
{
private static ScanCodeReader uniqueInstance;
// 定义一个标识确保线程同步
private static readonly object locker = new object();
/// <summary>
/// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
/// </summary>
/// <returns></returns>
public static ScanCodeReader GetInstance()
{
// 当第一个线程运行到这里时,此时会对locker对象 "加锁",
// 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
// lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
// 双重锁定只需要一句判断就可以了
if (uniqueInstance == null)
{
lock (locker)
{
// 如果类的实例不存在则创建,否则直接返回
if (uniqueInstance == null)
{
uniqueInstance = new ScanCodeReader();
}
}
}
return uniqueInstance;
}
private ScanCodeReader(string portname = "COM5", int baudrate = 9600)
{
initialization("ScanCodeReader");
setParameter(portname, baudrate);
}
~ScanCodeReader()
{
deinitialize();
}
public override void initValue()
{
initParameter();
initManager();
}
public override void deleValue()
{
deleManager();
deleParameter();
}
public IScanCodeInterface Instance() { return GetInstance(); }
/*===========================================================================*/
protected SerialPort Manager = null;
protected SerialContext 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 ReOpen()
{
Close();
return Open();
}
public int Open()
{
int isWarning = Settings.RECODE_FAILURE;
initParameter();
if (!IsValid) initManager();
if (IsOpen) Close();
isWarning = SerialPortUtil.Open(Manager, Parameter);
return isWarning;
}
public int Close()
{
int isWarning = Settings.RECODE_SUCCEED;
if (!hasManager || !IsOpen)
return isWarning;
isWarning = SerialPortUtil.Close(Manager);
return isWarning;
}
public void initManager()
{
if (!hasManager)
{
Manager = new SerialPort();
initParameter();
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;
}
}
public void deleManager()
{
Close();
try
{
if (hasManager)
Manager.Dispose();
Manager = null;
GC.Collect();
}
catch (Exception) { }
}
public void initParameter()
{
if (!hasParameter)
{
Parameter = new SerialContext();
}
}
public void deleParameter()
{
try
{
Parameter = null;
GC.Collect();
}
catch (Exception) { }
}
public void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0)
{
if (!hasParameter)
initParameter();
Parameter.PortName = portname;
Parameter.BaudRate = baudrate;
Parameter.DataBits = databits;
Parameter.StopBits = stopbits;
Parameter.Parity = parity;
}
public string ReadString(string frameTail, int timeout = 100)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
public byte[] ReadBinary(string frameTail, int timeout = 100)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
public int SendString(string buffer)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendString(Manager, buffer);
}
public int SendBinary(byte[] buffer)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendBinary(Manager, buffer);
}
public string WaitDone(string buffer, string frameTail, int timeout = 100, int waittime = 50)
{
lock (IOLocker)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendString(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
AppTimeLoop.ProcessEvents(waittime);
return SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
}
return default(string);
}
public byte[] WaitDone(byte[] buffer, string frameTail, int timeout = 100, int waittime = 50)
{
lock (IOLocker)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendBinary(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
AppTimeLoop.ProcessEvents(waittime);
return SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
}
return default(byte[]);
}
public string ScanCode(int timeout = 1000, int waittime = 50)
{
try
{
byte[] buffer = WaitDone(Settings.START_DECODE, Encoding.UTF8.GetString(Settings.DECODE_TAIL), timeout, waittime);
return Encoding.UTF8.GetString(buffer);
}
catch (Exception) { }
return default(string);
}
public void StopScanCode(int timeout = 1000, int waittime = 50)
{
try
{
byte[] buffer = WaitDone(Settings.STOP_DECODE, Encoding.UTF8.GetString(Settings.DECODE_TAIL), timeout, waittime);
}
catch (Exception) { }
return;
}
public string SetHostMode(int timeout = 1000, int waittime = 50)
{
try
{
byte[] buffer = WaitDone(Settings.CONSOLE_MODE, Encoding.UTF8.GetString(Settings.DECODE_FRAME_TAIL), timeout, waittime);
return Encoding.UTF8.GetString(buffer);
}
catch (Exception) { }
return default(string);
}
public string GetVersion(int timeout = 1000, int waittime = 50)
{
try
{
byte[] buffer = WaitDone(Settings.GET_VERSION, Encoding.UTF8.GetString(Settings.DECODE_FRAME_TAIL), timeout, waittime);
return Encoding.UTF8.GetString(buffer);
}
catch (Exception) { }
return default(string);
}
public void ClearBuffer()
{
ReadString(null, 500);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO.Ports;
using AppUtils;
namespace AppInterfaces
{
public class SerialPortReader: Appinterface, SerialPortInterface
{
public SerialPortReader(string portname = "COM5" , int baudrate = 9600)
{
initialization("SerialPortReader");
setParameter(portname, baudrate);
}
~SerialPortReader()
{
deinitialize();
}
public override void initValue()
{
initParameter ();
initManager ();
}
public override void deleValue()
{
deleManager ();
deleParameter ();
}
public SerialPortInterface Instance() { return new SerialPortReader(); }
/*===========================================================================*/
protected SerialPort Manager = null;
protected SerialContext 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 ReOpen ()
{
Close();
return Open();
}
public int Open ()
{
int isWarning = Settings.RECODE_FAILURE;
initParameter();
if (!IsValid) initManager();
if (IsOpen) Close();
isWarning = SerialPortUtil.Open(Manager, Parameter);
return isWarning;
}
public int Close ()
{
int isWarning = Settings.RECODE_SUCCEED;
if (!hasManager || !IsOpen)
return isWarning;
isWarning = SerialPortUtil.Close(Manager);
return isWarning;
}
public void initManager ()
{
if(!hasManager)
{
Manager = new SerialPort();
initParameter();
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 ;
}
}
public void deleManager ()
{
Close();
try
{
if (hasManager)
Manager.Dispose();
Manager = null;
GC.Collect();
}
catch (Exception) { }
}
public void initParameter ()
{
if (!hasParameter)
{
Parameter = new SerialContext();
}
}
public void deleParameter ()
{
try
{
Parameter = null;
GC.Collect();
}
catch (Exception) { }
}
public void setParameter(string portname, int baudrate, int databits = 8, int stopbits = 1, int parity = 0)
{
if (!hasParameter)
initParameter();
Parameter.PortName = portname ;
Parameter.BaudRate = baudrate ;
Parameter.DataBits = databits ;
Parameter.StopBits = stopbits ;
Parameter.Parity = parity ;
}
public string ReadString (string frameTail, int timeout = 100)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
public byte[] ReadBinary (string frameTail, int timeout = 100)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
public int SendString (string buffer)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendString(Manager, buffer);
}
public int SendBinary (byte[] buffer)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
return SerialPortUtil.SendBinary(Manager, buffer);
}
public string WaitDone (string buffer, string frameTail, int timeout = 100, int waittime = 50)
{
lock(IOLocker)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendString(Manager, buffer);
if(Settings.RECODE_SUCCEED == isWarning)
{
AppTimeLoop.ProcessEvents(waittime);
return SerialPortUtil.ReadString(Manager, frameTail, timeout);
}
}
return default(string);
}
public byte[] WaitDone (byte[] buffer, string frameTail, int timeout = 100, int waittime = 50)
{
lock(IOLocker)
{
if (!IsValid) initManager();
if (!IsOpen) Open();
int isWarning = SerialPortUtil.SendBinary(Manager, buffer);
if (Settings.RECODE_SUCCEED == isWarning)
{
AppTimeLoop.ProcessEvents(waittime);
return SerialPortUtil.ReadBinary(Manager, frameTail, timeout);
}
}
return default(byte[]);
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace AppUtils
{
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));
}
}
}
This diff is collapsed.
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 = 3000 ;
public static int MicMaxFrameTimeOut = 300000 ;
public static int MicFrameWaitTimes = 100 ;
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppUtils
{
public class MicroscopeControllerID
{
// 显微镜事件
public static int SET_MASTER_EVENT = 70003 ; // 设置显微镜事件
public static int SET_Z_DRIVE_EVENT = 71003 ; // 设置Z轴事件
public static int SET_OBJECTIVE_EVENT = 76003 ; // 设置物镜事件
public static int SET_FIELD_TL_EVENT = 83003 ; // 设置孔径光阑事件
public static int SET_TL_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_DRIVE_STATUS = 71004; // 参数1:已到达下限硬件开关!参数2:已到达上限硬件开关!参数3:已到达下限阈值!参数 4:焦点位置已到达
public static int SET_Z_DRIVE_MANUAL_OPERATION = 71005 ;// 打开或关闭Z轴的手动操作
public static int GET_Z_DRIVE_MANUAL_OPERATION = 71006 ;// 返回手动操作是否打开或关闭
public static int SET_Z_DRIVE_RESET = 71007 ;// 复位单元 参数重置为默认值
public static int GET_Z_DRIVE_FIRMWARE_STATUS = 71008 ;// 固件状态 0 固件正在从引导扇区运行 1 固件正在从程序内存运行
public static int SET_Z_DRIVE_INIT = 71020 ;// 初始化 Z-DRIVE Z-DRIVE 移动到下方硬件端开关并重置零点
public static int SET_Z_DRIVE_BREAK = 71021 ;// 中止 Z-DRIVE 的当前定位
public static int SET_Z_DRIVE_ABS_POSITION = 71022 ; // 将功能单元定位到以微步(计数)为单位的给定绝对值
public static int GET_Z_DRIVE_ABS_POSITION = 71023 ; // 以微步(计数)为单位读取功能单元的当前位置
public static int SET_Z_DRIVE_REL_POSITION = 71024 ; // 将功能单元定位到以微步(计数)为单位的给定相对位置值
public static int SET_Z_DRIVE_CONST_POSITION = 71025 ; // 以恒定速度移动功能单元
public static int SET_Z_DRIVE_LOWER_LIMIT = 71026 ; // 将下限阈值设置为给定的 Z 轴位置
public static int SET_Z_DRIVE_FOCUS_LIMIT = 71027 ; // 将焦点位置设置为指定的 Z 轴位置
public static int GET_Z_DRIVE_LOWER_LIMIT = 71028 ; // 读取当前下限的Z值
public static int GET_Z_DRIVE_FOCUS_LIMIT = 71029 ; // 读取当前焦点位置。
public static int SET_Z_DRIVE_ACCELERATION = 71030 ; // 设置新的加速度参数
public static int GET_Z_DRIVE_ACCELERATION = 71031 ; // 读取加速度参数
public static int SET_Z_DRIVE_SPEED = 71032 ; // 定义Z轴运动的最大速度
public static int GET_Z_DRIVE_SPEED = 71033 ; // 读取当前Z轴运动速度
public static int Z_DRIVE_MOVE_TO_FOCUS_LIMIT = 71034 ; // 将 Z 轴驱动器移动到当前焦点位置
public static int Z_DRIVE_MOVE_TO_LOWER_LIMIT = 71035 ; // 将 Z 轴驱动移至当前下限
public static int SET_Z_DRIVE_LOWER_POSITION = 71037 ; // 将当前 Z 轴位置定义为下限阈值
public static int SET_Z_DRIVE_FOCUS_POSITION = 71038 ; // 将当前 Z 轴位置定义为下限阈值
public static int GET_Z_DRIVE_CONVERT_FACTOR = 71042 ; // 获取转换因子
public static int Z_DRIVE_INIT_RANGE = 71044 ; // 初始化范围Z
public static int GET_MIN_Z_DRIVE_ACCELERATION = 71048 ; // 读取加速度参数
public static int GET_MAX_Z_DRIVE_ACCELERATION = 71049 ; // 读取加速度参数
public static int SET_Z_DRIVE_MOVE_MODE = 71050 ; // 将当前Z 驱动运动模式0 = 细步 1 = 粗步 2 = 切换
public static int GET_Z_DRIVE_MOVE_MODE = 71051 ; // 将当前Z 驱动运动模式0 = 细步 1 = 粗步 2 = 切换
public static int SET_Z_DRIVE_FOCUS_LIMIT_ENABLED = 71053 ; // 激活焦点限制活动模式
public static int GET_Z_DRIVE_FOCUS_LIMIT_ENABLED = 71054 ; // 激活焦点限制活动模式
public static int SET_Z_DRIVE_UPPER_LIMIT = 71055 ; // 上限阈值设置为给定的 Z 位置
public static int GET_Z_DRIVE_UPPER_LIMIT = 71056 ; // 读取上限阈值的当前 Z 值
public static int GET_MIN_Z_DRIVE_SPEED = 71058 ; // 读取速度参数
public static int GET_MAX_Z_DRIVE_SPEED = 71059 ; // 读取速度参数
public static int SET_Z_DRIVE_INIT_MODE = 71065 ; // 设置开机时 Z 轴的初始化模式 - = 没有初始化Z轴 N = 低于 4 毫米或低于软件阈值(默认)Z = 低于软件阈值 如果未设置阈值,则调整零位。
public static int GET_Z_DRIVE_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_MIN_OBJECTIVE_VALUE = 76038 ; // 获取最小物镜位置
public static int GET_MAX_OBJECTIVE_VALUE = 76039 ; // 获取最大物镜位置
public static int OBJECTIVE_REDUCE_PASS = 76040 ; // 获取DIP
public static int SET_OBJECTIVE_PATHO_MODE = 76046 ; // 设置物镜病理模式
public static int GET_OBJECTIVE_PATHO_MODE = 76047 ; // 获取物镜病理模式
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace AppUtils
{
class MicroscopeUtil
{
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 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(MicroscopeUtil.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 AppUtils
{
using AppInterfaces;
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();
int waittimes = 10;
DateTime starttime = DateTime.Now ;
int readLength = 0 ;
DateTime endtime ;
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;
endtime = DateTime.Now;
timeOffset = (int)(endtime - 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 ;
DateTime endtime ;
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;
endtime = DateTime.Now;
timeOffset = (int)(endtime - 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 AppUtils
{
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 static byte[] DEFAULT_BIT = default(byte[]);
public static int DEFAULT_INT = default(int );
public static string DEFAULT_STR = default(string);
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ScanCodeAPI
{
public class Class1
{
}
}
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的一般信息由以下
// 控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("ScanCodeAPI")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ScanCodeAPI")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 会使此程序集中的类型
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
//请将此类型的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("fff8948e-f2cc-4410-affd-9f55dac65a9c")]
// 程序集的版本信息由下列四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
//通过使用 "*",如下所示:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
<?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>{FFF8948E-F2CC-4410-AFFD-9F55DAC65A9C}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>ScanCodeAPI</RootNamespace>
<AssemblyName>ScanCodeAPI</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="AppContexts\LeiCaContext.cs" />
<Compile Include="AppContexts\SerialContext.cs" />
<Compile Include="AppControllers\ScanCodeController.cs" />
<Compile Include="AppControllers\SerialPortController.cs" />
<Compile Include="AppInterfaces\Appinterface.cs" />
<Compile Include="AppInterfaces\ContextInterface.cs" />
<Compile Include="AppInterfaces\ScanCodeInterface.cs" />
<Compile Include="AppInterfaces\SerialPortInterface.cs" />
<Compile Include="AppReaders\ScanCodeReader.cs" />
<Compile Include="AppReaders\SerialPortReader.cs" />
<Compile Include="AppUtils\AppTimeLoop.cs" />
<Compile Include="AppUtils\MicControllerID.cs" />
<Compile Include="AppUtils\MicroscopeUtil.cs" />
<Compile Include="AppUtils\MicSettings.cs" />
<Compile Include="AppUtils\SerialPortUtil.cs" />
<Compile Include="AppUtils\Settings.cs" />
<Compile Include="Class1.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment