123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178 |
-
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Runtime.InteropServices;
- using System.Runtime.Remoting.Channels;
- using System.Runtime.Remoting.Channels.Ipc;
- using OTSMeasureApp.ServiceCenter;
- using OTSCommon.DBOperate.Model;
- using OTSCLRINTERFACE;
- using OTSDataType;
- using OTSModelSharp.ServiceCenter;
- namespace ServiceInterface
- {
- public class HardwareController
- {
- private IpcSEMController remoteObj;
- static HardwareController sem = null;
- public static HardwareController GetSemController()
- {
- if (sem == null)
- {
- sem = new HardwareController();
- }
- return sem;
- }
- private HardwareController()
- {
-
-
- }
- public bool Connect()
- {
- try
- {
- if (remoteObj == null)
- {
- IpcClientChannel channel = new IpcClientChannel();
- //Register the channel with ChannelServices.
- ChannelServices.RegisterChannel(channel, false);
- remoteObj = (IpcSEMController)Activator.GetObject(typeof(IpcSEMController), "ipc://ServerChannel/RemoteObject");
- if (!remoteObj.TestConn())
- {
- remoteObj = null;
- return false;
- }
- }
- }
- catch (Exception e)
- {
- NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- remoteObj = null;
- return false;
- }
- return true;
- }
- public bool DisConnect()
- {
- //remoteObj = null;
- return true;
- }
- public bool SetMagnification(double a_dMagnification)
- {
- //Connect();
- if (remoteObj == null)
- {
- return false;
- }
- try
- {
- return remoteObj.SetMagnification(a_dMagnification);
- }
- catch (Exception e)
- {
- NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- }
- return false;
- }
- public bool AcquireBSEImage(string sampleName, int width, int height, DwellTimeLevel dwellTime, ref byte[] ImageByte)
- {
- //Connect();
- if (remoteObj == null)
- {
- return false;
- }
- try
- {
- return remoteObj.AcquireBSEImage(sampleName,width,height,dwellTime,ref ImageByte);
- }
- catch (Exception e)
- {
- NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- }
- return false;
- }
- public bool MoveSEMToPoint(Point poi, double rotation)
- {
- //Connect();
- if (remoteObj == null)
- {
- return false;
- }
- try
- {
- return remoteObj.MoveSEMToPoint(poi);
- }
- catch (Exception e)
- {
- NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- }
- return false;
- }
- public bool GetSemPositionXY(ref double ls_PositionX, ref double ls_PositionY, ref double ls_PositionR)
- {
- //Connect();
- if (remoteObj == null)
- {
- return false;
- }
- try
- {
- return remoteObj.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
- }
- catch (Exception e)
- {
- NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
-
- }
- return false;
- }
- public bool AcquisitionSpectrum(string samplePath, int xrayMode, double new_PixelSize, ref Particle particle, uint a_nXRayAQTime)
- {
- //Connect();
- if (remoteObj == null)
- {
- return false;
- }
- try
- {
- return remoteObj.AcquisitionSpectrum(samplePath, xrayMode, new_PixelSize, ref particle, a_nXRayAQTime);
- }
- catch (Exception e)
- {
- NLog.LogManager.GetCurrentClassLogger().Error(e.Message);
- }
- return false;
- }
- }
- }
|