using Aurora.Api;
using Hermes;
using System.Runtime.InteropServices;
namespace AuroraLaserScanner
{
internal class ScannerSimul : ScannerObj
{
static new readonly Logger Log = new Logger("Scanner");
// For storage of each queried data set, the user program must provide (at an address specified by Ptr) an area of PC main memory equal to 528520 bytes.
[MarshalAs(UnmanagedType.LPArray, SizeConst = 528520)] uint[] m_coordinationTransformPtr = new uint[528520];
//set_trigger 관련 추가, get_waveform 에서 얻어올 포인터 추가, 최대 크기로 설정 (2^20 = 1,048,576)
[MarshalAs(UnmanagedType.LPArray, SizeConst = 1048576)] int[] m_getWaveformPtr = new int[1048576];
private bool _ModulationMode;
public override uint Open()
{
IsOpenUnit = true;
return NO_ERROR;
}
public override void Close()
{
if (IsOpenUnit == true) {
IsOpenUnit = false;
}
}
public override int Initialize(ScannerConfig config)
{
CommandPosX = 0;
CommandPosY = 0;
CommandPosZ = 0;
_ModulationMode = config.Modulation;
return E1.OK;
}
public override bool GetModulationMode()
{
return _ModulationMode;
}
public override void JumpAbs(double x, double y, eFunctionType type = eFunctionType.COMMAND)
{
CommandPosX = x;
CommandPosY = y;
}
public override void JumpAbs3D(double x, double y, double z, eFunctionType type = eFunctionType.COMMAND)
{
CommandPosX = x;
CommandPosY = y;
CommandPosZ = z;
}
public override void JumpRel(double x, double y, eFunctionType type = eFunctionType.COMMAND)
{
CommandPosX += x;
CommandPosY += y;
}
public override void JumpRel3D(double x, double y, double z, eFunctionType type = eFunctionType.COMMAND)
{
CommandPosX += x;
CommandPosY += y;
CommandPosZ += z;
}
public override void MarkAbs(double x, double y)
{
CommandPosX = x;
CommandPosY = y;
}
public override void MarkRel(double x, double y)
{
CommandPosX += x;
CommandPosY += y;
}
public override void ArcAbs(double x, double y, double angle)
{
CommandPosX = x;
CommandPosY = y;
}
public override void ArcRel(double x, double y, double angle)
{
CommandPosX += x;
CommandPosY += y;
}
public override void JumpAbsZ(double z, eFunctionType type = eFunctionType.COMMAND)
{
CommandPosZ = z;
}
public override void JumpRelZ(double z, eFunctionType type = eFunctionType.COMMAND)
{
CommandPosZ += z;
}
public override void GetXYPos(out double x, out double y)
{
x = CommandPosX;
y = CommandPosY;
}
public override void GetZPos(out double z)
{
z = CommandPosZ;
}
public override void WriteDA(uint portNo, float value/*0~100%*/, eFunctionType type = eFunctionType.COMMAND)
{
}
public override void GetEncoder(out double encoderX, out double encoderY, bool rotateMode = false)
{
// simulation 할때 값 반영 검토 필요
encoderX = 0;
encoderY = 0;
}
public override uint GetMarkingInfo()
{
//return RTC5Wrap.n_get_marking_info(m_deviceNo);
return 0;
}
public override uint GetStartStopInfo()
{
//return RTC5Wrap.n_get_startstop_info(m_deviceNo);
return 0;
}
public override void StoreEncoder(uint pos)
{
//RTC5Wrap.n_store_encoder(m_deviceNo, pos);
}
public override void ReadEncoder(out double encoder0_0, out double encoder1_0, out double encoder0_1, out double encoder1_1, bool rotateMode = false)
{
// simulation 할때 값 반영 검토 필요
encoder0_0 = 0;
encoder1_0 = 0;
encoder0_1 = 0;
encoder1_1 = 0;
}
public override void WaitForEncoderX(double position)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderY(double position)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderRotateX(double angle)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderRotateY(double angle)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderRotateXMode(double angle, eEncoderWaitThroughMode mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderRotateYMode(double angle, eEncoderWaitThroughMode mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderXMode(double position, eEncoderWaitThroughMode mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderYMode(double position, eEncoderWaitThroughMode mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderMode(double position, uint encoderNo, eEncoderWaitThroughMode mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderRange(double minX, double maxX, double minY, double maxY)
{
// simulation 할때 값 반영 검토 필요
}
public override void WaitForEncoderRotateRange(double minX, double maxX, double minY, double maxY)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetFlyX(double encoderResolution)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetFlyY(double encoderResolution)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetRotateCenter(double posX, double posY, eFunctionType type = eFunctionType.COMMAND)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetFlyRotate(double encoderResolution)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetFlyRotatePos(double encoderResolution)
{
// simulation 할때 값 반영 검토 필요
}
public override void ActivateFlyXY(double encoderResolutionX, double encoderResolutionY)
{
// simulation 할때 값 반영 검토 필요
}
public override void ActivateFly1Axis(int axis, int mode, double scale, int offset)
{
}
public override void Fly_Return(double x, double y)
{
// simulation 할때 값 반영 검토 필요
}
public override void ParkPosition(double posX, double posY, eParkType type = eParkType.VirtualImage)
{
// simulation 할때 값 반영 검토 필요
}
public override void ParkReturn(double posX, double posY, eParkType type = eParkType.VirtualImage)
{
// simulation 할때 값 반영 검토 필요
}
public override void InitFly2D(int offsetX = 0, int offsetY = 0)
{
// simulation 할때 값 반영 검토 필요
}
public override void SimulateEncoder(uint EncoderNo)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetControlMode(uint mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetLaesrDelay(int laserOnDelay, uint laserOffDelay)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetScannerDelay(uint jumpDelay, uint markDelay, uint arcDelay)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetJumpSpeedCtrl(double speed)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetJumpSpeed(double speed)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetMarkSpeed(double speed)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetStartList(eListNo no)
{
// simulation 할때 값 반영 검토 필요
}
public override uint LoadList(eListNo no)
{
// simulation 할때 값 반영 검토 필요
return 0;
}
public override void SetEndList()
{
// simulation 할때 값 반영 검토 필요
}
public override void ExecuteList(eListNo no)
{
// simulation 할때 값 반영 검토 필요
}
public override void StartLoop()
{
RTC5Wrap.n_start_loop(m_deviceNo);
}
public override void QuitLoop()
{
// simulation 할때 값 반영 검토 필요
}
public override void AutoChange()
{
// simulation 할때 값 반영 검토 필요
}
public override bool GetBusyStatus()
{
// simulation 할때 값 반영 검토 필요
return false;
}
public override void StopExecution()
{
// simulation 할때 값 반영 검토 필요
}
public override uint GetRTCVersion()
{
// simulation 할때 값 반영 검토 필요
return 0;
}
public override uint GetDLLVersion()
{
// simulation 할때 값 반영 검토 필요
return 0;
}
public override void SetLaserTiming(uint periodHz, uint laser1PulseWidthUs, uint laser2PulseWidthUs) //단위는 Khz, us임
{
// simulation 할때 값 반영 검토 필요
}
public override void SetStandby(uint periodHz, uint laserPulseWidthUs) //단위는 Khz, us임
{
// simulation 할때 값 반영 검토 필요
}
public override void SetLaserMode(eLaserMode mode)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetLaserControl(uint ctrl)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetFirstPulseKiller(uint width) //단위는 us->bit 로 변경해야 함
{
// simulation 할때 값 반영 검토 필요
}
public override void LaserSignalOn()
{
// simulation 할때 값 반영 검토 필요
}
public override void LaserSignalOff()
{
// simulation 할때 값 반영 검토 필요
}
///
/// 지정한 시간 시간만큼 Laser Active 신호를 켜주는 리스트 함수
///
/// 시간[ms]
public override void LaserOnList(double interval)
{
// simulation 할때 값 반영 검토 필요
}
///
/// Laser Active가 Off된 상태에서 지정한 시간 시간만큼 delay를 추가하는 함수
///
/// 시간[ms]
public override void LongDelay(uint delay)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetAngle(double angle/*degree*/, uint atOnce, eFunctionType type = eFunctionType.COMMAND)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetOffset(double offsetX, double offsetY, uint atOnce, eFunctionType type = eFunctionType.COMMAND)
{
// simulation 할때 값 반영 검토 필요
}
public override void DisableLaser()
{
// simulation 할때 값 반영 검토 필요
}
public override void EnableLaser()
{
// simulation 할때 값 반영 검토 필요
}
public override void ParaLaserOnPulsesList(double period, uint pulses, float powerValue)
{
// simulation 할때 값 반영 검토 필요
}
//Ramping 기능
public override void ParaMarkAbs(double x, double y, float power)
{
CommandPosX = x;
CommandPosY = y;
// simulation 할때 값 반영 검토 필요
}
public override void ParaMarkRel(double x, double y, float power)
{
CommandPosX += x;
CommandPosY += y;
// simulation 할때 값 반영 검토 필요
}
public override void ParaJumpAbs(double x, double y, float power)
{
CommandPosX = x;
CommandPosY = y;
// simulation 할때 값 반영 검토 필요
}
public override void ParaJumpRel(double x, double y, float power)
{
CommandPosX += x;
CommandPosY += y;
// simulation 할때 값 반영 검토 필요
}
public override void SetVectorControl(uint portNo, uint value)
{
// simulation 할때 값 반영 검토 필요
}
//측정 기능
public override void StopTrigger()
{
// simulation 할때 값 반영 검토 필요
}
public override void SetTrigger(uint period/*㎲*/, eRecordSignal signal1, eRecordSignal signal2, eRecordSignal signal3, eRecordSignal signal4)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetTrigger(uint period/*㎲*/, eRecordSignal signal1, eRecordSignal signal2)
{
// simulation 할때 값 반영 검토 필요
}
public override void Measurement_status(out uint busy, out uint pos)
{
// simulation 할때 값 반영 검토 필요
busy = 0; pos = 0;
}
public override uint ReadStatus()
{
// simulation 할때 값 반영 검토 필요
return 0;
}
public override void GetWaveForm(uint channel, uint number, out int[] data)
{
data = new int[number];
// simulation 할때 값 반영 검토 필요
}
//안오산-170224-Wobbel모드 추가(V1.7.0)
//set_wobbel_mode
public override void SetWobbelMode(bool wobbelEnable, double transversal, double longitudinal, double frequency, int shape)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetWobbelDirection(int dX, int dY)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetWobbelVector(double tansversal, double longitudinal, uint period, float power)
{
// simulation 할때 값 반영 검토 필요
}
public override void ConfigLaserSignal(eLaserSignal pin2, eLaserSignal pin1, eLaserSignal pin9)
{
// simulation 할때 값 반영 검토 필요
}
public override void SelectCorrectionTable(int no)
{
// simulation 할때 값 반영 검토 필요
}
public override void SetEthernetConfigLinkLoss(eEthConfigLinkLossMode mode)
{
}
public override int CheckEthernetConnection(out uint errorCode)
{
errorCode = 0;
return 0;
}
#region 리스트 실행 시간 측정
///
/// Delayed Short List Command
/// Stores the current value of the RTC6 timer and resets it to zero.
///
public override void SaveAndRestartTimer()
{
// simulation 할때 값 반영 검토 필요
}
///
/// Ctrl Command
/// Returns the RTC5 timer value (without resetting it to zero). It has been stored during the most recent call of save_and_restart_timer.
///
/// RTC5 timer value in seconds. As a 64-bit IEEE floating point value.
public override double GetTime()
{
// simulation 할때 값 반영 검토 필요
return 0;
}
#endregion
// 기존 추상함수 아닌 3개 항목 추상함수로 추가
//ExecuteUpdateParameterList는 Initialize에 직접구현할수밖에.. config의 항목 쓰려면..
public override uint LoadProgramFile(string fileName)
{
// simulation 할때 값 반영 검토 필요
return 0;
}
public override uint LoadCorrectionFile(string fileName, uint correctionNo, bool use3DMode)
{
// simulation 할때 값 반영 검토 필요
return 0;
}
public static int CutValue(int value, int min, int max)
{
if (value > max) {
return max;
} else if (value < min) {
return min;
} else {
return value;
}
}
public override void SetLaserPinOutList(uint pins)
{
}
public override void SetPortDefault(uint port, uint value)
{
}
public override void SetLaserPinOut(uint pins)
{
}
public override uint GetLastError()
{
return 0;
}
public override void SetConfigList(uint mem1, uint mem2)
{
}
public override uint GetListSpace()
{
return 0;
}
}
}