剥离第一阶段需要做的函数,梳理关系,新增测试dll工程

This commit is contained in:
wio
2022-10-10 11:52:53 +08:00
parent 698e1223fa
commit 6d2b284f36
44 changed files with 1500 additions and 302 deletions
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
+587
View File
@@ -0,0 +1,587 @@
using System;
using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace HSI_SEVENOCEAN_EF1_CsTest.HSI
{
internal class Interface
{
// >>>> In Interfaces
public delegate void PEventCallback(
Def.HSI_EVENT_TYPE eventType, Def.HSI_EVENT_RESPONSE_TYPE responseType, uint eventId, string eventData,
ref uint eventCallbackId);
public static PEventCallback HsiCallback;
[DllImport("HSI.dll", EntryPoint = "HSI_GET_INTERFACE_VERSION", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS GetInterfaceVersion(ref uint apiVersionMajor, ref uint apiVersionMinor);
[DllImport("HSI.dll", EntryPoint = "HSI_STARTUP", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS Startup(IntPtr hWnd, bool bOfflineOnly);
[DllImport("HSI.dll", EntryPoint = "HSI_GET_INTERFACE_VERSION", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS GetInterfaceVersion();
[DllImport("HSI.dll", EntryPoint = "HSI_GET_MACHINE_INFO", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS GetMachineInfo(ref int numMachineTypes);
[DllImport("HSI.dll", EntryPoint = "HSI_SET_EVENT_CALLBACK", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS SetEventCallback(PEventCallback pCallback);
[DllImport("HSI.dll", EntryPoint = "HSI_SHUTDOWM", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS Shutdown();
// <<<< Out Interfacess
public static void EventCallback(Def.HSI_EVENT_TYPE eventType, Def.HSI_EVENT_RESPONSE_TYPE responseType,
uint eventId, string eventData, ref uint eventCallbackId)
{
var msgBtn = MessageBoxButtons.OK;
switch (responseType)
{
case Def.HSI_EVENT_RESPONSE_TYPE.HSI_EVENT_RESPONSE_OK:
msgBtn = MessageBoxButtons.OK;
break;
case Def.HSI_EVENT_RESPONSE_TYPE.HSI_EVENT_RESPONSE_RETRY:
msgBtn = MessageBoxButtons.RetryCancel;
break;
case Def.HSI_EVENT_RESPONSE_TYPE.HSI_EVENT_RESPONSE_CANCEL:
msgBtn = MessageBoxButtons.OKCancel;
break;
case Def.HSI_EVENT_RESPONSE_TYPE.HSI_EVENT_RESPONSE_YES:
msgBtn = MessageBoxButtons.YesNo;
break;
}
switch (eventType)
{
case Def.HSI_EVENT_TYPE.HSI_EVENT_NONE:
break;
case Def.HSI_EVENT_TYPE.HSI_EVENT_ERROR:
break;
case Def.HSI_EVENT_TYPE.HSI_EVENT_FUNCTION:
var eventFunctionId = (Def.HSI_EVENT_FUNCTION_ID) eventId;
switch (eventFunctionId)
{
case Def.HSI_EVENT_FUNCTION_ID.HSI_EVENT_MOTION_DCC_HOME:
{
System.Windows.Forms.MessageBox.Show(Resources.Interface_Tips_Home_Machine, Resources.Interface_Tips,
msgBtn, MessageBoxIcon.Information);
break;
}
case Def.HSI_EVENT_FUNCTION_ID.HSI_EVENT_DEBUG_LOG:
{
System.Windows.Forms.MessageBox.Show(eventData, Resources.Interface_Tips,
msgBtn, MessageBoxIcon.Information);
break;
}
case Def.HSI_EVENT_FUNCTION_ID.HSI_EVENT_MOVE_POINT:
{
System.Windows.Forms.MessageBox.Show(Resources.Interface_Tips_Motion_Finished, Resources.Interface_Tips,
msgBtn, MessageBoxIcon.Information);
; //Motion completed
break;
}
}
break;
}
}
}
internal class Motion
{
// >>>> In Interfaces
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS IsSupported(ref uint types);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_STARTUP", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS Startup(bool bHome);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_HOMED", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS IsHomed(ref bool bHomed);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_SPEED_XYZ", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS GetSpeedXyz(ref double speed);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SET_SPEED_XYZ", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS SetSpeedXyz(double speed);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_SPEED_R", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS GetSpeedR(ref double speed);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SET_SPEED_R", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS SetSpeedR(double speed);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_SCALE_RESOLUTION", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS GetScaleResolution(
// ref double scaleX, ref double scaleY, ref double scaleZ);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SET_SCALE_RESOLUTION", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS SetScaleResolution(double scaleX, double scaleY, double scaleZ);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_DEADBAND", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS GetDeadBand(
// ref double deadbandX, ref double deadbandY, ref double deadbandZ, ref double deadbandR);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_REFRESH_DEADBAND", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS GetRefreshDeadBand(ref double deadband);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_JOG", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS Jog(uint axisTypes, double speed);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_STOP_JOG", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS StopJog();
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_POSITION_XYZ", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS GetPositionXyz(
uint axisTypes, ref double positionX, ref double positionY, ref double positionZ, ref double time);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SET_POSITION_XYZ", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS SetPositionXyz(
uint axisTypes, double positionX, double positionY, double positionZ, Def.HSI_MOTION_MOVE_TYPE eType,
double dFlyRadius);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_POSITION_R", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS GetPositionR(uint axisTypes, ref double positionR, ref double time);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SET_POSITION_R", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS SetPositionR(
// uint axisTypes, double positionR, Def.HSI_MOTION_AXIS_R_MOVE_TYPE directionType, bool bWait);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_ABORT_MOTION", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS AbortMotion();
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_GET_DIO", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS GetDIO(uint ioChannel, ref uint status);
//[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SET_DIO", CharSet = CharSet.Unicode)]
//public static extern Def.HSI_STATUS SetDIO(uint ioChannel, uint status);
[DllImport("HSI.dll", EntryPoint = "HSI_MOTION_SHUTDOWN", CharSet = CharSet.Unicode)]
public static extern Def.HSI_STATUS Shutdown();
// <<<< Out Interfaces
public Motion()
{
_supported = 0;
_bFirst = true;
}
//public static bool IsActive(bool bForce = false)
//{
// if (_bFirst || bForce)
// {
// IsSupported(ref _supported);
// _bFirst = false;
// }
// return (_supported != 0);
//}
private static bool _bFirst;
private static uint _supported;
}
//internal class Illumination
// {
// // >>>> In Interfaces
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS IsSupported(ref uint types);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_STARTUP();
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_GET_LAMP_COUNT(ref int nLamps);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_GET_LAMP_INFO(ref int lampInfo, ref int numLamps,
// int[] lampsType,
// int[] numRings, int[] numSectors, int[] color, double[] angle, ref bool bCanBeCalibrated);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_GET_LAMP_STATE(
// int nLamp, bool[] bBulbStates, double[] intensities, ref int color, ref double angle);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_SET_LAMP_STATE(
// int nLamp, bool[] bBulbStates, double[] intensities, int color, double angle, bool bWait);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_GET_LAMP_STATE_ALL(
// int lampInfo, int numLamps, int[] lampsType, int[,] bBulbStates, double[,] intensities);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_SET_LAMP_STATE_ALL(
// int lampInfo, int numLamps, int[] lampsType, int[,] bBulbStates, double[,] intensities, bool bWait);
// [DllImport("HSI.dll", EntryPoint = "HSI_MOTION_IS_SUPPORTED", CharSet = CharSet.Unicode)]
// public static extern Def.HSI_STATUS HSI_ILLUMINATION_SHUTDOWN();
// // <<<< Out Interfaces
// public Illumination()
// {
// _supported = 0;
// _bFirst = true;
// }
// public static bool IsActive(bool bForce = false)
// {
// if (_bFirst || bForce)
// {
// IsSupported(ref _supported);
// _bFirst = false;
// }
// return (_supported != 0);
// }
// private static bool _bFirst;
// private static uint _supported;
// }
internal class Def
{
public const int HSI_APIVersionMajor = 1;
public const int HSI_APIVersionMinor = 3;
public const int HSI_MaxStringLength = 255; // Maximum string length (buffer size - 1)
///////////////////////////////////////////////////////////////////////////////
// Interface API
///////////////////////////////////////////////////////////////////////////////
public enum HSI_STATUS
{
HSI_STATUS_NOT_SUPPORTED = -1,
HSI_STATUS_NORMAL = 0,
HSI_STATUS_FAILED,
HSI_FAILED_DLL_LOAD,
HSI_STATUS_PORTLOCK_HSI_MISMATCH,
HSI_STATUS_FILE_NOT_FOUND,
HSI_STATUS_HARDWARE_NOT_FOUND,
HSI_STATUS_INVALID_PARAMETERS,
HSI_STATUS_INVALID_POINTS,
HSI_STATUS_PART_NOT_DETECTED,
HSI_STATUS_MEASURE_ERROR,
HSI_STATUS_TEMPERATURE_ERROR,
HSI_STATUS_ILLUMINATION_COMM = 50,
HSI_STATUS_OPTICS_COMM = 100,
HSI_STATUS_OPTICS_HOMING,
HSI_STATUS_OPTICS_TIMEOUT,
HSI_STATUS_OPTICS_CALIBRATIONDATA,
HSI_STATUS_OPTICS_CALIBRATIONDATADEFAULT,
HSI_STATUS_OPTICS_CALFILEDATACOUNTMISMATCH,
HSI_STATUS_MOTION_COMM = 150,
HSI_STATUS_MOTION_HOMING,
HSI_STATUS_MOTION_TIMEOUT,
HSI_STATUS_MOTION_EMERGENCY_STOP,
HSI_STATUS_MOTION_EXCEED_LIMIT,
HSI_STATUS_MOTION_UNKNOWN_ERROR,
HSI_STATUS_MOTION_EXCEED_SW_LIMIT,
HSI_STATUS_MOTION_POSITION_ERROR,
HSI_STATUS_MOTION_MOVING,
HSI_STATUS_TP_UNEXPECTED_HIT = 200,
HSI_STATUS_TP_TIMEOUT = 201,
HSI_STATUS_TP_APPROACH_TIMEOUT = 202,
HSI_STATUS_TP_WRIST_ERROR,
HSI_STATUS_FG_COMM = 250,
HSI_STATUS_FG_TIMEOUT,
HSI_STATUS_FG_DIRECTX,
HSI_STATUS_FG_COLORDEPTH,
HSI_STATUS_LP_TIMEOUT = 300,
HSI_STATUS_LP_EXCEED_LIMIT = 301,
HSI_STATUS_VP_TIMEOUT = 350,
HSI_STATUS_VP_IMAGEPROCESS_FAIL
};
public enum HSI_MACHINE_TYPE
{
HSI_MACHINE_UNKNOWN = 0,
HSI_MACHINE_SO7 = 1,
HSI_MACHINE_TYPE_TOTAL,
};
public enum HSI_EVENT_TYPE
{
HSI_EVENT_NONE = 0,
HSI_EVENT_ERROR = 1,
HSI_EVENT_FUNCTION = 2
};
public enum HSI_EVENT_FUNCTION_ID //EventData
{
//SendReceive
// V4.2 & V4.3 +
HSI_EVENT_DONE = 0, //N/A N/A
HSI_EVENT_TAKE_HIT = 1, //N/A N/A
HSI_EVENT_ERASE_HIT = 2, //N/AN/A
HSI_EVENT_TIME_CRITICAL = 3, //"ON", or "OFF" N/A
HSI_EVENT_ZOOM_IN = 4, //"MAX", "COARSE", or "FINE" N/A
HSI_EVENT_ZOOM_OUT = 5, //"MAX", "COARSE", or "FINE" N/A
HSI_EVENT_REFRESH_LIVE_VIEW = 6, //N/AN/A
HSI_EVENT_UPDATE_READOUTS = 7, //"AxisFlags,%lf{x},%lf{y},%lf{z},%lf{r}"N/A
HSI_EVENT_READ_MC_POSITION = 8, //"AxisFlags""AxisFlags,%lf{x},%lf{y},%lf{z},%lf{r}"
HSI_EVENT_MOVE_MC_POSITION = 9, //"AxisFlags,%lf{x},%lf{y},%lf{z},%lf{r},%lf{speed},%1d{bWait}"N/A
HSI_EVENT_CONVERT_MC_TO_GLOBAL = 10, //"%lf{x},%lf{y},%lf{z}" "%lf{x},%lf{y},%lf{z}"
HSI_EVENT_UPDATE_STATUS_MESSAGE = 11, //N/AN/A
HSI_EVENT_OPENFILE_DLG = 12, //N/A"FileName"
HSI_EVENT_DISPLAY_YESNO_MESSAGE = 13, //N/AN/A
HSI_EVENT_DISPLAY_OKCANCEL_MESSAGE = 14, //N/AN/A
HSI_EVENT_DISPLAY_OK_MESSAGE = 15, //N/AN/A
// V4.3 + Only
HSI_EVENT_DEBUG_LOG = 20, //"%s" N/A
HSI_EVENT_MOVE_MC_POSITION_AND_SETTLE = 21, //"AxisFlags,%lf{x},%lf{y},%lf{z},%lf{r},%lf{speed}" N/A
HSI_EVENT_CONVERT_GLOBAL_TO_MM = 22, //"%lf{x},%lf{y},%lf{z}" "%lf{x},%lf{y},%lf{z}"
HSI_EVENT_CONVERT_ROT_TO_TABLE_POINT = 23, //"%lf{x},%lf{y},%lf{z}" "%lf{x},%lf{y},%lf{z}"
HSI_EVENT_CONVERT_ROT_OUT_TABLE_POINT = 24, //"%lf{x},%lf{y},%lf{z}" "%lf{x},%lf{y},%lf{z}"
HSI_EVENT_CONVERT_ROT_TO_TABLE_VECTOR = 25, //"%lf{x},%lf{y},%lf{z}" "%lf{x},%lf{y},%lf{z}"
HSI_EVENT_CONVERT_ROT_OUT_TABLE_VECTOR = 26, //"%lf{x},%lf{y},%lf{z}" "%lf{x},%lf{y},%lf{z}"
HSI_EVENT_ILLUMINATION_REFRESH = 27,
HSI_EVENT_ILLUMINATION_LOCK = 28,
HSI_EVENT_ILLUMINATION_STORE_SET = 29,
HSI_EVENT_ILLUMINATION_RESTORE_SET = 30,
HSI_EVENT_ILLUMINATION_DECREASE_ACTIVE = 31, // "%d"
HSI_EVENT_ILLUMINATION_INCREASE_ACTIVE = 32, // "%d"
HSI_EVENT_ILLUMINATION_DECREASE_ALL = 33, // "%d"
HSI_EVENT_ILLUMINATION_INCREASE_ALL = 34, // "%d"
HSI_EVENT_ILLUMINATION_SELECT_LAMP = 35, // "%d"
HSI_EVENT_ILLUMINATION_SET_LAMP_INTENSITY = 36, // "%d"
HSI_EVENT_ILLUMINATION_GET_LAMP_INTENSITY = 37, // "%d"
HSI_EVENT_ILLUMINATION_SET_LAMP_CALIBRATION_OVERRIDE = 38, // "%d"
HSI_EVENT_ILLUMINATION_NEXT_RING = 39,
HSI_EVENT_ILLUMINATION_PREV_RING = 40,
HSI_EVENT_ILLUMINATION_NEXT_SECTOR = 41,
HSI_EVENT_ILLUMINATION_PREV_SECTOR = 42,
HSI_EVENT_ILLUMINATION_NUM_LAMPS_INSTALLED = 43,
HSI_EVENT_ILLUMINATION_IS_LAMP_INSTALLED = 44,
HSI_EVENT_ILLUMINATION_APPLY = 45,
HSI_EVENT_ILLUMINATION_ALLOFF = 46,
HSI_EVENT_ILLUMINATION_ALLON = 47,
HSI_EVENT_ILLUMINATION_UNLOCK = 48,
HSI_EVENT_IS_PROGRAMMING_MODE = 49, //1/0
HSI_EVENT_IS_PORTLOCK_DCC = 50, //1/0
HSI_EVENT_IS_ROTAB_ENABLED = 51, //1/0
HSI_EVENT_IS_TIME_CRITICAL = 52, // 1/0
HSI_EVENT_CONVERT_MM_TO_GLOBAL = 53,
HSI_EVENT_CONVERT_GLOBAL_TO_MC = 54,
HSI_EVENT_LASER_FOCUS_ENABLE = 55, // "%d" 0 = not available, 1 = available
HSI_EVENT_MOVE_POINT = 56, //N/AN/A
HSI_EVENT_MAG_CHANGED = 57,
HSI_EVENT_ILLUMINATION_SET_LAMP_INTENSITY_IN_MACHINE_LEVELx100 = 58,
// "%d" //PR251359-- Instructed to "Please focus on slide" but it's rather unhelpfully turned the lights off for us.
HSI_EVENT_DCC_SCAN_POINTS_AVAILABLE = 59, //"%d"= more to come, 1 = last set N/A
HSI_EVENT_ILLUMINATION_IS_ALL_OFF = 60,
//1/0//PR253777-- Sensilight does not work if the target has 'ALL OFF' for illum setting--4/16/2008
HSI_EVENT_ILLUMINATION_DECREASE_ALL_NONZERO = 61,
// Sensilight command that wont change a lamp currently set to zero
HSI_EVENT_ILLUMINATION_INCREASE_ALL_NONZERO = 62,
// Sensilight command that wont change a lamp currently set to zero22
HSI_EVENT_LP_QUALITY = 63, //"%d" 0-100%
HSI_EVENT_TP_QUALITY = 64, //"%d" 0-100%
HSI_EVENT_VP_QUALITY = 65, //"%d" 0-100%
HSI_EVENT_FLYMODE_MOVE_COMPLETE = 66, // A queued flymode move has completed
HSI_EVENT_PENDANT_SPEED_PERCENT = 67, // 108336 HMV : Add calls to HSI.H for Speed
HSI_EVENT_PENDANT_AXES_SELECTED = 68, // 108335 HMV : Need to add calls to the HSI.H for Stacked Rotary
HSI_EVENT_MOTION = 500,
HSI_EVENT_MOTION_DCC_HOME = 501,
HSI_EVENT_SHUTDOWN_ = 999 //N/AN/A
};
public enum HSI_NOTIFY_TYPE
{
HSI_NOTIFY_PROGRAM_EXECUTION_START = 0,
HSI_NOTIFY_PROGRAM_EXECUTION_STOP = 1,
HSI_NOTIFY_TIME_CRITICAL_EVENT_START = 2,
HSI_NOTIFY_TIME_CRITICAL_EVENT_STOP = 3,
HSI_NOTIFY_PROGRAM_OPEN = 4,
HSI_NOTIFY_PROGRAM_CLOSE = 5,
HSI_NOTIFY_PCDMIS_SHUTDOWN = 6
};
public enum HSI_EVENT_RESPONSE_TYPE
{
HSI_EVENT_CALLBACK = 0,
HSI_EVENT_RESPONSE_OK = 1,
HSI_EVENT_RESPONSE_RETRY = 2,
HSI_EVENT_RESPONSE_CANCEL = 3,
HSI_EVENT_RESPONSE_YES = 4,
HSI_EVENT_RESPONSE_NO = 5,
HSI_EVENT_FUNCTION_OK = 6,
HSI_EVENT_FUNCTION_FAILED = 7
};
public struct SHsiEventProperties
{
public uint EventId;
public uint EventCallbackId;
public HSI_EVENT_TYPE EventType;
public HSI_EVENT_RESPONSE_TYPE EventResponse;
public char[] EventData;
public void Init()
{
EventId = (uint) HSI_EVENT_FUNCTION_ID.HSI_EVENT_DONE;
EventCallbackId = 0;
EventType = HSI_EVENT_TYPE.HSI_EVENT_NONE;
EventResponse = HSI_EVENT_RESPONSE_TYPE.HSI_EVENT_CALLBACK;
EventData = new char[HSI_MaxStringLength + 1];
}
};
///////////////////////////////////////////////////////////////////////////////
// Motion API
///////////////////////////////////////////////////////////////////////////////
public enum HSI_MOTION_TYPE
{
HSI_MOTION_SUPPORTS_DCC_CONTROL = 0x0001,
HSI_MOTION_SUPPORTS_MANUAL_CONTROL = 0x0002,
HSI_MOTION_SUPPORTS_HOMING = 0x0004,
HSI_MOTION_SUPPORTS_CIRCULAR_MOVES = 0x0008,
HSI_MOTION_SUPPORTS_CMM_WRIST = 0x0010,
HSI_MOTION_SUPPORTS_BUFFERED_MOVES = 0x0020,
HSI_MOTION_SUPPORTS_FLY_MOVES = 0x0040,
HSI_MOTION_SUPPORTS_SCAN = 0x0080,
HSI_MOTION_SUPPORTS_ALL_AXIS_MOVE = 0x0100,
HSI_MOTION_SUPPORTS_MEASPOINT_VW = 0x0200
};
public enum HSI_MOTION_AXIS_TYPE
{
HSI_MOTION_AXIS_X = 0x0001, // This is the default "Sensor level" X Axis - use on single X axis machines
HSI_MOTION_AXIS_Y = 0x0002, // This is the default "Sensor level" Y Axis - use on single Y axis machines
HSI_MOTION_AXIS_Z = 0x0004, // This is the default "Sensor level" Z Axis - use on single Z axis machines
HSI_MOTION_AXIS_R = 0x0008, // This is the default "Sensor level" R Axis - use on single R axis machines
HSI_MOTION_AXIS_X1 = 0x0010, // This is the 1st X Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_Y1 = 0x0020, // This is the 1st Y Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_Z1 = 0x0040, // This is the 1st Z Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_R1 = 0x0080, // This is the 1st R Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_X2 = 0x0100, // This is the 2nd X Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_Y2 = 0x0200, // This is the 2nd Y Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_Z2 = 0x0400, // This is the 2nd Z Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_R2 = 0x0800, // This is the 2nd R Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_X3 = 0x1000, // This is the 3rd X Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_Y3 = 0x2000, // This is the 3rd Y Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_Z3 = 0x4000, // This is the 3rd Z Axis - use on multiple axis machines when specific axis needed
HSI_MOTION_AXIS_R3 = 0x8000 // This is the 3rd R Axis - use on multiple axis machines when specific axis needed
};
public enum HSI_MOTION_IO_TYPE
{
HSI_MOTION_INPUT1 = 0x0001,
HSI_MOTION_INPUT2,
HSI_MOTION_OUTPUT1 = 0x0100,
HSI_MOTION_OUTPUT2
};
public const uint HSI_MOTION_AXIS_ALL =
(uint)
(HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X | HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y |
HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z);
public enum HSI_MOTION_MOVE_TYPE
{
HSI_MOTION_MOVE_WAIT = 1,
HSI_MOTION_MOVE_NOWAIT = 2,
HSI_MOTION_MOVE_INTERMEDIATE_POSITION = 3,
HSI_MOTION_MOVE_FINAL_POSITION = 4,
HSI_MOTION_IN_POSITION_EVENT = 5,
HSI_MOTION_MOVE_FLYMODE = 6,
HSI_MOTION_MOVE_START_POSITION = 7,
HSI_MOTION_MOVE_START_FINAL_POSITION = 8
};
public enum HSI_MOTION_AXIS_R_MOVE_TYPE
{
HSI_MOTION_AXIS_R_CLOCKWISE = 1,
HSI_MOTION_AXIS_R_ANTICLOCKWISE = 2,
HSI_MOTION_AXIS_R_FASTEST = 3
};
public const int HSI_MAX_POSITIONS_STORED = 500;
///////////////////////////////////////////////////////////////////////////////
//Illumination API
///////////////////////////////////////////////////////////////////////////////
public enum HSI_ILLUMINATION_INFO
{
HSI_ILLUMINATION_INFO_UNKNOWN = 0,
HSI_ILLUMINATION_INFO_HSI = 0x01,
HSI_ILLUMINATION_INFO_HSI_II = 0x02, //lvgang
HSI_ILLUMINATION_INFO_HSI_III = 0x04, //shixuyong
HSI_ILLUMINATION_INFO_TOTAL
};
public enum HSI_ILLUMINATION_BULB_TYPE
{
HSI_ILLUMINATION_BULB_ROUND = 1,
HSI_ILLUMINATION_BULB_SQUARE = 2,
HSI_ILLUMINATION_BULB_RING = 3,
HSI_ILLUMINATION_BULB_GRID = 4
};
public enum HSI_ILLUMINATION_LAMP_TYPE
{
HSI_ILLUMINATION_LAMP_NONE = 0,
HSI_ILLUMINATION_LAMP_COAXIAL = 1,
HSI_ILLUMINATION_LAMP_SURFACE = 2,
HSI_ILLUMINATION_LAMP_PROFILE = 3,
HSI_ILLUMINATION_LAMP_PROFILE_OUTER = 4
};
public enum HSI_ILLUMINATION_LAMP_CONTROL_TYPE
{
HSI_ILLUMINATION_LAMP_CONTROL_NONE = 0x0000,
HSI_ILLUMINATION_LAMP_CONTROL_BY_WHOLE_LAMP = 0x0001,
HSI_ILLUMINATION_LAMP_CONTROL_BY_RINGS = 0x0002,
HSI_ILLUMINATION_LAMP_CONTROL_BY_OCTANTS = 0x0004,
HSI_ILLUMINATION_LAMP_CONTROL_BY_SEGMENTS = 0x0008,
HSI_ILLUMINATION_LAMP_CONTROL_BY_OTHER
};
public enum HSI_ILLUMINATION_BULB_STATE
{
HSI_ILLUMINATION_BULB_STATE_TURN_ON = 0,
HSI_ILLUMINATION_BULB_STATE_TURN_OFF = 1,
HSI_ILLUMINATION_BULB_STATE_TOTAL
};
public enum HSI_ILLUMINATION_TYPE
{
HSI_ILLUMINATION_SUPPORTS_DCC_CONTROL = 0x0001,
HSI_ILLUMINATION_SUPPORTS_MANUAL_CONTROL = 0x0002
};
public enum HSI_ILLUMINATION_LAMP_LOCATION_TYPE
{
HSI_ILLUMINATION_LAMP_LOCATION_NONE = 0,
HSI_ILLUMINATION_LAMP_LOCATION_TOP_ON_AXIS = 1,
HSI_ILLUMINATION_LAMP_LOCATION_TOP_ANGLED = 2,
HSI_ILLUMINATION_LAMP_LOCATION_BOTTOM = 3,
HSI_ILLUMINATION_LAMP_LOCATION_MOVABLE = 4
};
public const int HSI_ILLUMINATION_MAX_LAMPS = 6;
public const int HSI_ILLUMINATION_MAX_BULB_COLORS = 3;
public const int HSI_ILLUMINATION_MAX_RINGS = 12;
public const int HSI_ILLUMINATION_MAX_SECTORS = 16;
public const int HSI_ILLUMINATION_MAX_BULBS = HSI_ILLUMINATION_MAX_RINGS*HSI_ILLUMINATION_MAX_SECTORS;
public const int HSI_MaxLampNameLength = 29, HSI_MaxLampDescriptionLength = 255;
// Maximum string length (buffer size - 1)
}
}
@@ -0,0 +1,137 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="12.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{7ED499CB-651C-4154-9741-EEF347BDBFB5}</ProjectGuid>
<OutputType>Exe</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>HSI_SEVENOCEAN_EF1_CsTest</RootNamespace>
<AssemblyName>HSI_SEVENOCEAN_EF1_CsTest</AssemblyName>
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<PublishUrl>发布\</PublishUrl>
<Install>true</Install>
<InstallFrom>Disk</InstallFrom>
<UpdateEnabled>false</UpdateEnabled>
<UpdateMode>Foreground</UpdateMode>
<UpdateInterval>7</UpdateInterval>
<UpdateIntervalUnits>Days</UpdateIntervalUnits>
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>0</ApplicationRevision>
<ApplicationVersion>1.0.0.%2a</ApplicationVersion>
<IsWebBootstrapper>false</IsWebBootstrapper>
<UseApplicationTrust>false</UseApplicationTrust>
<BootstrapperEnabled>true</BootstrapperEnabled>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<PlatformTarget>x64</PlatformTarget>
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<PlatformTarget>AnyCPU</PlatformTarget>
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
<DebugSymbols>true</DebugSymbols>
<OutputPath>bin\x86\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<DebugType>full</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
<OutputPath>bin\x86\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<Optimize>true</Optimize>
<DebugType>pdbonly</DebugType>
<PlatformTarget>x86</PlatformTarget>
<ErrorReport>prompt</ErrorReport>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<Prefer32Bit>true</Prefer32Bit>
</PropertyGroup>
<PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
</PropertyGroup>
<PropertyGroup>
<ApplicationIcon>MainIcon.ico</ApplicationIcon>
</PropertyGroup>
<ItemGroup>
<Reference Include="System" />
<Reference Include="System.Core" />
<Reference Include="System.Drawing" />
<Reference Include="System.Windows.Forms" />
<Reference Include="System.Xml.Linq" />
<Reference Include="System.Data.DataSetExtensions" />
<Reference Include="Microsoft.CSharp" />
<Reference Include="System.Data" />
<Reference Include="System.Xml" />
</ItemGroup>
<ItemGroup>
<Compile Include="HSI\HSI.cs" />
<Compile Include="Resources.Designer.cs">
<AutoGen>True</AutoGen>
<DesignTime>True</DesignTime>
<DependentUpon>Resources.resx</DependentUpon>
</Compile>
<Compile Include="User32API.cs" />
<Compile Include="Program.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="App.config" />
</ItemGroup>
<ItemGroup>
<None Include="Resources\Icon.bmp" />
</ItemGroup>
<ItemGroup>
<BootstrapperPackage Include=".NETFramework,Version=v4.5">
<Visible>False</Visible>
<ProductName>Microsoft .NET Framework 4.5 %28x86 和 x64%29</ProductName>
<Install>true</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Client.3.5">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1 Client Profile</ProductName>
<Install>false</Install>
</BootstrapperPackage>
<BootstrapperPackage Include="Microsoft.Net.Framework.3.5.SP1">
<Visible>False</Visible>
<ProductName>.NET Framework 3.5 SP1</ProductName>
<Install>false</Install>
</BootstrapperPackage>
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="Resources.resx">
<Generator>ResXFileCodeGenerator</Generator>
<LastGenOutput>Resources.Designer.cs</LastGenOutput>
</EmbeddedResource>
</ItemGroup>
<ItemGroup>
<Content Include="MainIcon.ico" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild">
</Target>
<Target Name="AfterBuild">
</Target>
-->
</Project>
@@ -0,0 +1,2 @@
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
<s:String x:Key="/Default/CodeInspection/CSharpLanguageProject/LanguageLevel/@EntryValue">CSharp60</s:String></wpf:ResourceDictionary>
Binary file not shown.

After

Width:  |  Height:  |  Size: 643 KiB

+134
View File
@@ -0,0 +1,134 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using HSI_SEVENOCEAN_EF1_CsTest;
using HSI_SEVENOCEAN_EF1_CsTest.HSI;
namespace HSI_SEVENOCEAN_EF1_CsTest
{
class Program
{
private static Interface.PEventCallback _eventCallback;
static void Main(string[] args)
{
uint major = Def.HSI_APIVersionMajor;
uint minjor = Def.HSI_APIVersionMinor;
var rStatus = Interface.GetInterfaceVersion(ref major, ref minjor);
Console.WriteLine("Interface.GetInterfaceVersion:{0}", rStatus);
Console.WriteLine("Version:{0}.{1}", major, minjor);
var mainIntPtr = User32Api.GetCurrentWindowHandle();
rStatus = Interface.Startup(mainIntPtr, false);
Console.WriteLine("Interface.Startup:{0}", rStatus);
Interface.HsiCallback=new Interface.PEventCallback(Interface.EventCallback);
rStatus = Interface.SetEventCallback(Interface.HsiCallback);
Console.WriteLine("SetEventCallback:{0}", rStatus);
//if (Motion.IsActive(true))
{
rStatus = Motion.Startup(true);
Console.WriteLine("Motion.Startup:{0}", rStatus);
var bHomed = true;
rStatus = Motion.IsHomed(ref bHomed);
Console.WriteLine("Motion.IsHomed:{0}", rStatus);
var bexit = false;
double SpeedGear = 1.0;
var dPos = new double[3];
do
{
var info = Console.ReadKey();
double dTime = 0;
switch (info.Key)
{
case ConsoleKey.P:
dPos[0] += 10.0;
dPos[1] += 10.0;
rStatus = Motion.SetPositionXyz(Def.HSI_MOTION_AXIS_ALL, dPos[0], dPos[1], dPos[2], Def.HSI_MOTION_MOVE_TYPE.HSI_MOTION_MOVE_NOWAIT, 0.0);
break;
case ConsoleKey.Enter:
rStatus = Motion.GetPositionXyz(Def.HSI_MOTION_AXIS_ALL, ref dPos[0], ref dPos[1], ref dPos[2], ref dTime);
Console.WriteLine("Motion.GetPositionXyz:{0}", rStatus);
Console.WriteLine("Motion.XYZ:{0},{1},{2}", dPos[0], dPos[1], dPos[2]);
break;
case ConsoleKey.Escape:
bexit = true;
break;
case ConsoleKey.Spacebar:
rStatus = Motion.StopJog();
Console.WriteLine("Motion.StopJog:{0}", rStatus);
break;
case ConsoleKey.NumPad1:
case ConsoleKey.D1:
SpeedGear = 1.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.NumPad2:
case ConsoleKey.D2:
SpeedGear = 2.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.NumPad3:
case ConsoleKey.D3:
SpeedGear = 3.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.NumPad4:
case ConsoleKey.D4:
SpeedGear = 4.0;
Console.WriteLine("Motion.SpeedGera:{0}", SpeedGear);
break;
case ConsoleKey.LeftArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, -SpeedGear);
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.RightArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_X, SpeedGear);
Console.WriteLine("Motion.Jog(X,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.DownArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, -SpeedGear);
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.UpArrow:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Y, SpeedGear);
Console.WriteLine("Motion.Jog(Y,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.PageUp:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, SpeedGear);
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
break;
case ConsoleKey.PageDown:
rStatus = Motion.Jog((uint)Def.HSI_MOTION_AXIS_TYPE.HSI_MOTION_AXIS_Z, -SpeedGear);
Console.WriteLine("Motion.Jog(Z,{1}):{0}", rStatus, SpeedGear);
break;
default:
Console.WriteLine("Invalid");
break;
}
} while (!bexit);
rStatus = Motion.Shutdown();
Console.WriteLine("Motion.Startup:{0}", rStatus);
}
rStatus = Interface.Shutdown();
Console.WriteLine("Interface.Shutdown:{0}", rStatus);
Console.WriteLine();
Console.WriteLine("Press any key to exit...");
Console.ReadKey();
}
}
}
@@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// 有关程序集的常规信息通过以下
// 特性集控制。更改这些特性值可修改
// 与程序集关联的信息。
[assembly: AssemblyTitle("HSI_SEVENOCEAN_EF1_CsTest")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("HSI_SEVENOCEAN_EF1_CsTest")]
[assembly: AssemblyCopyright("Copyright © 2015")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// 将 ComVisible 设置为 false 使此程序集中的类型
// 对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
// 则将该类型上的 ComVisible 特性设置为 true。
[assembly: ComVisible(false)]
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
[assembly: Guid("eef743e0-3721-4c9e-9744-7d8002c9f7bf")]
// 程序集的版本信息由下面四个值组成:
//
// 主版本
// 次版本
// 生成号
// 修订号
//
// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
+90
View File
@@ -0,0 +1,90 @@
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.18408
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
namespace HSI_SEVENOCEAN_EF1_CsTest {
using System;
/// <summary>
/// A strongly-typed resource class, for looking up localized strings, etc.
/// </summary>
// This class was auto-generated by the StronglyTypedResourceBuilder
// class via a tool like ResGen or Visual Studio.
// To add or remove a member, edit your .ResX file then rerun ResGen
// with the /str option, or rebuild your VS project.
[global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
[global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
[global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
internal class Resources {
private static global::System.Resources.ResourceManager resourceMan;
private static global::System.Globalization.CultureInfo resourceCulture;
[global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
internal Resources() {
}
/// <summary>
/// Returns the cached ResourceManager instance used by this class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Resources.ResourceManager ResourceManager {
get {
if (object.ReferenceEquals(resourceMan, null)) {
global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("HSI_SEVENOCEAN_EF1_CsTest.Resources", typeof(Resources).Assembly);
resourceMan = temp;
}
return resourceMan;
}
}
/// <summary>
/// Overrides the current thread's CurrentUICulture property for all
/// resource lookups using this strongly typed resource class.
/// </summary>
[global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
internal static global::System.Globalization.CultureInfo Culture {
get {
return resourceCulture;
}
set {
resourceCulture = value;
}
}
/// <summary>
/// Looks up a localized string similar to 提示.
/// </summary>
internal static string Interface_Tips {
get {
return ResourceManager.GetString("Interface_Tips", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 准备回家.
/// </summary>
internal static string Interface_Tips_Home_Machine {
get {
return ResourceManager.GetString("Interface_Tips_Home_Machine", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to 定位完成.
/// </summary>
internal static string Interface_Tips_Motion_Finished {
get {
return ResourceManager.GetString("Interface_Tips_Motion_Finished", resourceCulture);
}
}
}
}
+129
View File
@@ -0,0 +1,129 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Interface_Tips" xml:space="preserve">
<value>提示</value>
</data>
<data name="Interface_Tips_Home_Machine" xml:space="preserve">
<value>准备回家</value>
</data>
<data name="Interface_Tips_Motion_Finished" xml:space="preserve">
<value>定位完成</value>
</data>
</root>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 643 KiB

+88
View File
@@ -0,0 +1,88 @@
using System;
using System.Runtime.InteropServices;
using System.Collections;
namespace HSI_SEVENOCEAN_EF1_CsTest
{
class User32Api
{
private static readonly Hashtable ProcessWnd = null;
public delegate bool Wndenumproc(IntPtr hwnd, uint lParam);
static User32Api()
{
if (ProcessWnd == null)
{
ProcessWnd = new Hashtable();
}
}
[DllImport("user32.dll", EntryPoint = "EnumWindows", SetLastError = true)]
public static extern bool EnumWindows(Wndenumproc lpEnumFunc, uint lParam);
[DllImport("user32.dll", EntryPoint = "GetParent", SetLastError = true)]
public static extern IntPtr GetParent(IntPtr hWnd);
[DllImport("user32.dll", EntryPoint = "GetWindowThreadProcessId")]
public static extern uint GetWindowThreadProcessId(IntPtr hWnd, ref uint lpdwProcessId);
[DllImport("user32.dll", EntryPoint = "IsWindow")]
public static extern bool IsWindow(IntPtr hWnd);
[DllImport("kernel32.dll", EntryPoint = "SetLastError")]
public static extern void SetLastError(uint dwErrCode);
public static IntPtr GetCurrentWindowHandle()
{
IntPtr ptrWnd = IntPtr.Zero;
uint uiPid = (uint)System.Diagnostics.Process.GetCurrentProcess().Id; // 当前进程 ID
object objWnd = ProcessWnd[uiPid];
if (objWnd != null)
{
ptrWnd = (IntPtr)objWnd;
if (ptrWnd != IntPtr.Zero && IsWindow(ptrWnd)) // 从缓存中获取句柄
{
return ptrWnd;
}
else
{
ptrWnd = IntPtr.Zero;
}
}
bool bResult = EnumWindows(new Wndenumproc(EnumWindowsProc), uiPid);
// 枚举窗口返回 false 并且没有错误号时表明获取成功
if (!bResult && Marshal.GetLastWin32Error() == 0)
{
objWnd = ProcessWnd[uiPid];
if (objWnd != null)
{
ptrWnd = (IntPtr)objWnd;
}
}
return ptrWnd;
}
private static bool EnumWindowsProc(IntPtr hwnd, uint lParam)
{
uint uiPid = 0;
if (GetParent(hwnd) == IntPtr.Zero)
{
GetWindowThreadProcessId(hwnd, ref uiPid);
if (uiPid == lParam) // 找到进程对应的主窗口句柄
{
ProcessWnd[uiPid] = hwnd; // 把句柄缓存起来
SetLastError(0); // 设置无错误
return false; // 返回 false 以终止枚举窗口
}
}
return true;
}
}
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
</configuration>
@@ -0,0 +1,4 @@
// <autogenerated />
using System;
using System.Reflection;
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETFramework,Version=v4.5", FrameworkDisplayName = ".NET Framework 4.5")]