Initial commit
This commit is contained in:
673
Handler/Project_form2/Util/Util_DO.cs
Normal file
673
Handler/Project_form2/Util/Util_DO.cs
Normal file
@@ -0,0 +1,673 @@
|
||||
/*
|
||||
* Created by SharpDevelop.
|
||||
* User: amkor
|
||||
* Date: 5/16/2018
|
||||
* Time: 3:08 PM
|
||||
*
|
||||
* To change this template use Tools | Options | Coding | Edit Standard Headers.
|
||||
*/
|
||||
using System;
|
||||
using System.Collections;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
|
||||
public static partial class Util_DO
|
||||
{
|
||||
public static Boolean isEmergencyOn()
|
||||
{
|
||||
//둘중 하나라도 켜져있드면 비상 상태이다
|
||||
var b1 = GetIOInput(eDIName.BUT_EMGF);
|
||||
return b1;
|
||||
//BitArray ba1 = new BitArray(8);
|
||||
//ba1.Set(0, GetIOInput(eDIName.BUT_EMG1));
|
||||
//ba1.Set(1, GetIOInput(eDIName.BUT_EMG2));
|
||||
//ba1.Set(2, GetIOInput(eDIName.BUT_EMG3));
|
||||
//ba1.Set(3, GetIOInput(eDIName.BUT_EMG4));
|
||||
//return ba1.ValueI();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 감지센서확인
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static int isVacOKL()
|
||||
{
|
||||
var cnt = 0;
|
||||
if (GetIOOutput(eDOName.PICK_VAC1)) cnt += 1;
|
||||
if (GetIOOutput(eDOName.PICK_VAC2)) cnt += 1;
|
||||
if (GetIOOutput(eDOName.PICK_VAC3)) cnt += 1;
|
||||
if (GetIOOutput(eDOName.PICK_VAC4)) cnt += 1;
|
||||
return cnt;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 포트에 장작된 카트의 크기를 반환합니다. 없는경우 0, 7,13 입니다.
|
||||
/// </summary>
|
||||
/// <param name="idx">Port Index(left=0, Center=1, Right=2)</param>
|
||||
/// <returns></returns>
|
||||
public static eCartSize getCartSize(int idx)
|
||||
{
|
||||
var s07 = false;
|
||||
var s13 = false;
|
||||
if (idx == 0)
|
||||
{
|
||||
s07 = Util_DO.GetIOInput(eDIName.PORT0_SIZE_07);
|
||||
s13 = Util_DO.GetIOInput(eDIName.PORT0_SIZE_13);
|
||||
}
|
||||
else if (idx == 1)
|
||||
{
|
||||
s07 = Util_DO.GetIOInput(eDIName.PORT1_SIZE_07);
|
||||
s13 = Util_DO.GetIOInput(eDIName.PORT1_SIZE_13);
|
||||
}
|
||||
else
|
||||
{
|
||||
s07 = Util_DO.GetIOInput(eDIName.PORT2_SIZE_07);
|
||||
s13 = Util_DO.GetIOInput(eDIName.PORT2_SIZE_13);
|
||||
}
|
||||
if (s07 == false && s13 == false) return eCartSize.None;
|
||||
else if (s13 == true) return eCartSize.Inch13;
|
||||
else return eCartSize.Inch7;
|
||||
}
|
||||
|
||||
public static string getPinDescription(eDIName pin)
|
||||
{
|
||||
if (pin == eDIName.L_PICK_VAC) return "(좌) 프린트 용지 감지 센서";
|
||||
else if (pin == eDIName.R_PICK_VAC) return "(우) 프린트 용지 감지 센서";
|
||||
else if (pin == eDIName.R_PICK_BW) return "(우) 부착실린더 후진 감지 센서";
|
||||
else if (pin == eDIName.R_PICK_FW) return "(우) 부착실린더 전진 감지 센서";
|
||||
else if (pin == eDIName.L_PICK_BW) return "(좌) 부착실린더 후진 감지 센서";
|
||||
else if (pin == eDIName.L_PICK_FW) return "(좌) 부착실린더 전진 감지 센서";
|
||||
else if (pin == eDIName.AIR_DETECT) return "AIR 감지 센서";
|
||||
else return pin.ToString();
|
||||
}
|
||||
public static string getPinDescription(eDOName pin)
|
||||
{
|
||||
if (pin == eDOName.SOL_AIR) return "AIR 공급 출력";
|
||||
else if (pin == eDOName.BUZZER) return "BUZZER";
|
||||
else if (pin == eDOName.CART_MAG0) return "(좌) 전자석 출력";
|
||||
else if (pin == eDOName.CART_MAG1) return "(중앙) 전자석 출력";
|
||||
else if (pin == eDOName.CART_MAG2) return "(우) 전자석 출력";
|
||||
else if (pin == eDOName.PICK_VAC1) return "피커 진공 출력 #1";
|
||||
else if (pin == eDOName.PICK_VAC2) return "피커 진공 출력 #2";
|
||||
else if (pin == eDOName.PICK_VAC3) return "피커 진공 출력 #3";
|
||||
else if (pin == eDOName.PICK_VAC4) return "피커 진공 출력 #4";
|
||||
else if (pin == eDOName.PORT0_MOT_DIR) return "(좌) 포트 방향 출력";
|
||||
else if (pin == eDOName.PORT1_MOT_DIR) return "(중앙) 포트 방향 출력";
|
||||
else if (pin == eDOName.PORT2_MOT_DIR) return "(우) 포트 방향 출력";
|
||||
else if (pin == eDOName.PORT0_MOT_RUN) return "(좌) 포트 동작 출력";
|
||||
else if (pin == eDOName.PORT1_MOT_RUN) return "(중앙) 포트 동작 출력";
|
||||
else if (pin == eDOName.PORT2_MOT_RUN) return "(우) 포트 동작 출력";
|
||||
else if (pin == eDOName.PRINTL_AIRON) return "(좌) 프린트 하단 AIR";
|
||||
else if (pin == eDOName.PRINTR_AIRON) return "(우) 프린트 하단 AIR";
|
||||
else return pin.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ADLink I/O Board input status
|
||||
/// </summary>
|
||||
/// <param name="pin"></param>
|
||||
/// <returns></returns>
|
||||
public static Boolean GetIOInput(eDIName pin)
|
||||
{
|
||||
var curValue = Pub.dio.INPUT(GetDINum(pin) - 1);
|
||||
|
||||
//B접점으로 쓸 것들만 반전 시킨다.
|
||||
if (pin == eDIName.BUT_EMGF)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_Emgergency) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.PICKER_SAFE)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_PickerSafe) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.BUT_AIRF)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_ButtonAir) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.DOORF1 || pin == eDIName.DOORF2 || pin == eDIName.DOORF3)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_DoorF) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.DOORR1 || pin == eDIName.DOORR2 || pin == eDIName.DOORR3)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_DoorR) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.AIR_DETECT)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_AirCheck) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.PORT0_LIM_UP || pin == eDIName.PORT1_LIM_UP || pin == eDIName.PORT2_LIM_UP)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_PortLimitUp) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.PORT0_LIM_DN || pin == eDIName.PORT1_LIM_DN || pin == eDIName.PORT2_LIM_DN)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_PortLimitDn) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.PORT0_DET_UP)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_PortDetect0Up) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.PORT1_DET_UP)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_PortDetect1Up) curValue = !curValue;
|
||||
}
|
||||
else if (pin == eDIName.PORT2_DET_UP)
|
||||
{
|
||||
if (Pub.system.ReverseSIG_PortDetect2Up) curValue = !curValue;
|
||||
}
|
||||
return curValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// ADLink I/O Board Output Status
|
||||
/// </summary>
|
||||
/// <param name="pin"></param>
|
||||
/// <returns></returns>
|
||||
public static Boolean GetIOOutput(eDOName pin)
|
||||
{
|
||||
return Pub.dio.OUTPUT(GetDONum(pin) - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A/D Link Digital input Pin number
|
||||
/// </summary>
|
||||
/// <param name="pin"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetDINum(eDIName pin)
|
||||
{
|
||||
return (int)pin + 1;
|
||||
//return Pub.setting.DI[(byte)pin];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// adlink digital output in number
|
||||
/// </summary>
|
||||
/// <param name="pin"></param>
|
||||
/// <returns></returns>
|
||||
public static int GetDONum(eDOName pin)
|
||||
{
|
||||
return (int)pin + 1;
|
||||
//return Pub.setting.DO[(byte)pin];
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 포트내의 안전센서 여부
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Boolean isSaftyDoorF(Boolean RealSensor = false)
|
||||
{
|
||||
//모든 포트가 안전해야 전체가 안전한것이다
|
||||
return isSaftyDoorF(0, RealSensor) && isSaftyDoorF(1, RealSensor) && isSaftyDoorF(2, RealSensor);
|
||||
}
|
||||
|
||||
public static Boolean isSaftyDoorF(int idx, Boolean RealSensor)
|
||||
{
|
||||
if (idx == 0 && Pub.setting.Disable_safty_F0 == true) return true;
|
||||
else if (idx == 1 && Pub.setting.Disable_safty_F1 == true) return true;
|
||||
else if (idx == 2 && Pub.setting.Disable_safty_F2 == true) return true;
|
||||
|
||||
|
||||
if (RealSensor == false && idx == 0 && Pub.setting.Disable_safty_F0 == true) return true;
|
||||
else if (RealSensor == false && idx == 1 && Pub.setting.Disable_safty_F1 == true) return true;
|
||||
else if (RealSensor == false && idx == 2 && Pub.setting.Disable_safty_F2 == true) return true;
|
||||
else if (idx == 0 && Util_DO.GetIOInput(eDIName.DOORF1) == false) return true;
|
||||
else if (idx == 1 && Util_DO.GetIOInput(eDIName.DOORF2) == false) return true;
|
||||
else if (idx == 2 && Util_DO.GetIOInput(eDIName.DOORF3) == false) return true;
|
||||
else return false;
|
||||
}
|
||||
public static Boolean isSaftyDoorR(Boolean RealSensor = false)
|
||||
{
|
||||
//모든 포트가 안전해야 전체가 안전한것이다
|
||||
return isSaftyDoorR(0, RealSensor) && isSaftyDoorR(1, RealSensor) && isSaftyDoorR(2, RealSensor);
|
||||
}
|
||||
|
||||
public static Boolean isSaftyDoorR(int idx, Boolean RealSensor)
|
||||
{
|
||||
if (RealSensor == false && idx == 0 && Pub.setting.Disable_safty_R0 == true) return true;
|
||||
else if (RealSensor == false && idx == 1 && Pub.setting.Disable_safty_R1 == true) return true;
|
||||
else if (RealSensor == false && idx == 2 && Pub.setting.Disable_safty_R2 == true) return true;
|
||||
else if (idx == 0 && Util_DO.GetIOInput(eDIName.DOORR1) == false) return true;
|
||||
else if (idx == 1 && Util_DO.GetIOInput(eDIName.DOORR2) == false) return true;
|
||||
else if (idx == 2 && Util_DO.GetIOInput(eDIName.DOORR3) == false) return true;
|
||||
else return false;
|
||||
}
|
||||
|
||||
private static DateTime RoomLightControlTime = DateTime.Now;
|
||||
public static Boolean SetRoomLight(Boolean on)
|
||||
{
|
||||
if (on == true && Pub.setting.Disable_RoomLight == true)
|
||||
{
|
||||
Pub.log.Add("비활성화 됨");
|
||||
return true; //200708
|
||||
}
|
||||
|
||||
//형광등은 너무 빠른 제어는 하지 않는다
|
||||
var ts = DateTime.Now - RoomLightControlTime;
|
||||
if (ts.TotalMilliseconds < 500) return false;
|
||||
RoomLightControlTime = DateTime.Now;
|
||||
return Pub.dio.SetOutput(GetDONum(eDOName.LAMPON1) - 1, on);
|
||||
}
|
||||
public static Boolean SetAIR(Boolean ON)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
return Pub.dio.SetOutput(GetDONum(eDOName.SOL_AIR) - 1, ON);
|
||||
|
||||
}
|
||||
public static Boolean SetOutput(eDOName pin, Boolean value)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
return Pub.dio.SetOutput((int)pin, value);
|
||||
}
|
||||
public static bool GetPortMotorRun(int index)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
if (index < 0 || index > 3) throw new Exception("포트번호는 (0~2) 사이로 입력되어야 함");
|
||||
|
||||
Boolean b1 = false;
|
||||
|
||||
eDOName Pin_Dir = eDOName.PORT0_MOT_RUN;
|
||||
if (index == 1) Pin_Dir = eDOName.PORT1_MOT_RUN;
|
||||
else if (index == 2) Pin_Dir = eDOName.PORT2_MOT_RUN;
|
||||
|
||||
//direction을 먼저 전송한다
|
||||
b1 = Util_DO.GetIOOutput(Pin_Dir);
|
||||
return b1;
|
||||
}
|
||||
|
||||
public static eMotDir GetPortMotorDir(int index)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return eMotDir.CW;
|
||||
if (index < 0 || index > 3) throw new Exception("포트번호는 (0~2) 사이로 입력되어야 함");
|
||||
|
||||
Boolean b1 = false;
|
||||
|
||||
eDOName Pin_Dir = eDOName.PORT0_MOT_DIR;
|
||||
if (index == 1) Pin_Dir = eDOName.PORT1_MOT_DIR;
|
||||
else if (index == 2) Pin_Dir = eDOName.PORT2_MOT_DIR;
|
||||
|
||||
//direction을 먼저 전송한다
|
||||
b1 = Util_DO.GetIOOutput(Pin_Dir);
|
||||
if (b1 == false) return eMotDir.CW;
|
||||
else return eMotDir.CCW;
|
||||
}
|
||||
|
||||
public static Boolean SetPortMagnet(int index, Boolean on)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
|
||||
//기능적용 2100129
|
||||
if (on == true)
|
||||
{
|
||||
if (index == 0 && Pub.setting.Enable_Magnet0 == false) return true;
|
||||
if (index == 1 && Pub.setting.Enable_Magnet1 == false) return true;
|
||||
if (index == 2 && Pub.setting.Enable_Magnet2 == false) return true;
|
||||
}
|
||||
|
||||
if (index == 0) return Util_DO.SetOutput(eDOName.CART_MAG0, on);
|
||||
else if (index == 1) return Util_DO.SetOutput(eDOName.CART_MAG1, on);
|
||||
else return Util_DO.SetOutput(eDOName.CART_MAG2, on);
|
||||
}
|
||||
/// <summary>
|
||||
/// CW = Up, CCW = Dn
|
||||
/// </summary>
|
||||
/// <param name="index"></param>
|
||||
/// <param name="Dir"></param>
|
||||
/// <param name="run"></param>
|
||||
/// <returns></returns>
|
||||
public static Boolean SetPortMotor(int index, eMotDir Dir, Boolean run, string remark, Boolean smalldown = false)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
|
||||
//Pub.log.AddI($"포트모터({index}) {(Dir == eMotDir.CW ? "(정)" : "(역)")}방향 : {(run ? "O" : "X")} => {remark}");
|
||||
|
||||
|
||||
Boolean b1, b2; b1 = b2 = false;
|
||||
|
||||
int Pin_Dir, Pin_Run;
|
||||
eDIName pin_limp, pin_limn;
|
||||
|
||||
if (index == 0) Pin_Dir = (int)eDOName.PORT0_MOT_DIR;
|
||||
else if (index == 1) Pin_Dir = (int)eDOName.PORT1_MOT_DIR;
|
||||
else Pin_Dir = (int)eDOName.PORT2_MOT_DIR;
|
||||
|
||||
if (index == 0) Pin_Run = (int)eDOName.PORT0_MOT_RUN;
|
||||
else if (index == 1) Pin_Run = (int)eDOName.PORT1_MOT_RUN;
|
||||
else Pin_Run = (int)eDOName.PORT2_MOT_RUN;
|
||||
|
||||
if (index == 0) pin_limp = eDIName.PORT0_LIM_UP;
|
||||
else if (index == 1) pin_limp = eDIName.PORT1_LIM_UP;
|
||||
else pin_limp = eDIName.PORT2_LIM_UP;
|
||||
|
||||
if (index == 0) pin_limn = eDIName.PORT0_LIM_DN;
|
||||
else if (index == 1) pin_limn = eDIName.PORT1_LIM_DN;
|
||||
else pin_limn = eDIName.PORT2_LIM_DN;
|
||||
|
||||
//direction을 먼저 전송한다
|
||||
if (run)
|
||||
{
|
||||
|
||||
//b2 = Pub.dio.SetOutput(Pin_Dir, Dir != eMotDir.CW);
|
||||
//System.Threading.Thread.Sleep(5);
|
||||
|
||||
//켜야하는 상황인데.. 리밋이 걸렸다면 처리하지 않는다
|
||||
if (Dir == eMotDir.CW && Util_DO.GetIOInput(pin_limp) == true)
|
||||
{
|
||||
Pub.log.AddI(string.Format("포트({0})번의 출력을 무시합니다(LIMIT_UP) 방향:{1}", index, Dir));
|
||||
b1 = true;
|
||||
}
|
||||
else if (Dir == eMotDir.CCW && Util_DO.GetIOInput(pin_limn) == true)
|
||||
{
|
||||
Pub.log.AddI(string.Format("포트({0})번의 출력을 무시합니다(LIMIT_DN) 방향:{1}", index, Dir));
|
||||
b1 = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (smalldown)
|
||||
{
|
||||
if (index == 0)
|
||||
{
|
||||
Pub.flag.set(eFlag.PORT0_ENDDOWN, true, remark + ":SETPORT");
|
||||
Pub.SetVarTime(eVarTime.PORT0); //내린시간
|
||||
}
|
||||
if (index == 1)
|
||||
{
|
||||
Pub.flag.set(eFlag.PORT1_ENDDOWN, true, remark + ":SETPORT");
|
||||
Pub.SetVarTime(eVarTime.PORT1); //내린시간
|
||||
}
|
||||
if (index == 2)
|
||||
{
|
||||
Pub.flag.set(eFlag.PORT2_ENDDOWN, true, remark + ":SETPORT");
|
||||
Pub.SetVarTime(eVarTime.PORT2); //내린시간
|
||||
}
|
||||
Pub.log.AddAT(string.Format("P{0} Small Down Active Dir={1}",index, Dir));
|
||||
}
|
||||
else
|
||||
{
|
||||
//다른곳에서 이동을 설정해버리면 sdmall down 기능을 없앤다 -- 210405
|
||||
if (index == 0 && Pub.flag.get(eFlag.PORT0_ENDDOWN) == true)
|
||||
{
|
||||
Pub.flag.set(eFlag.PORT0_ENDDOWN, false, remark + ":SETPORT");
|
||||
Pub.log.AddAT("P0 Small Down Ignore");
|
||||
}
|
||||
if (index == 1 && Pub.flag.get(eFlag.PORT1_ENDDOWN) == true)
|
||||
{
|
||||
Pub.flag.set(eFlag.PORT1_ENDDOWN, false, remark + ":SETPORT");
|
||||
Pub.log.AddAT("P1 Small Down Ignore");
|
||||
}
|
||||
if (index == 2 && Pub.flag.get(eFlag.PORT2_ENDDOWN) == true)
|
||||
{
|
||||
Pub.flag.set(eFlag.PORT2_ENDDOWN, false, remark + ":SETPORT");
|
||||
Pub.log.AddAT("P2 Small Down Ignore");
|
||||
}
|
||||
}
|
||||
|
||||
//방향전환을 해야한다면 우선 정지 후 500ms 대기한다
|
||||
if (Util_DO.GetPortMotorDir(index) != Dir)
|
||||
{
|
||||
//일단 멈춤고
|
||||
b1 = Pub.dio.SetOutput(Pin_Run, false);
|
||||
System.Threading.Thread.Sleep(20);
|
||||
|
||||
//방향전환 ON
|
||||
b2 = Pub.dio.SetOutput(Pin_Dir, Dir != eMotDir.CW);
|
||||
System.Threading.Thread.Sleep(20);
|
||||
|
||||
//모터 가동
|
||||
b1 = Pub.dio.SetOutput(Pin_Run, run);
|
||||
System.Threading.Thread.Sleep(20);
|
||||
}
|
||||
else
|
||||
{
|
||||
//방향전환을 하지 않는 경우
|
||||
|
||||
//모터 가동
|
||||
b2 = true;
|
||||
b1 = Pub.dio.SetOutput(Pin_Run, run);
|
||||
System.Threading.Thread.Sleep(20);
|
||||
}
|
||||
|
||||
//b1 = Pub.dio.SetOutput(Pin_Run, run);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
//동작을 먼저 끈다
|
||||
b1 = Pub.dio.SetOutput(Pin_Run, run);
|
||||
System.Threading.Thread.Sleep(20);
|
||||
|
||||
//방향핀을 끈다
|
||||
b2 = Pub.dio.SetOutput(Pin_Dir, false);
|
||||
System.Threading.Thread.Sleep(20);
|
||||
}
|
||||
|
||||
|
||||
//System.Threading.Thread.Sleep(5);
|
||||
return b1 && b2;
|
||||
}
|
||||
|
||||
|
||||
public static Boolean SetPrintLVac(ePrintVac run, bool force)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
if (force == false && Pub.setting.Disable_PLVac == true) run = ePrintVac.off;
|
||||
bool b1, b2;
|
||||
if (run == ePrintVac.inhalation)
|
||||
{
|
||||
//흡기
|
||||
b1 = Util_DO.SetOutput(eDOName.PRINTL_VACO, false);
|
||||
b2 = Util_DO.SetOutput(eDOName.PRINTL_VACI, true);
|
||||
}
|
||||
else if (run == ePrintVac.exhaust)
|
||||
{
|
||||
//배기
|
||||
b1 = Util_DO.SetOutput(eDOName.PRINTL_VACI, false);
|
||||
b2 = Util_DO.SetOutput(eDOName.PRINTL_VACO, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//끄기
|
||||
b1 = Util_DO.SetOutput(eDOName.PRINTL_VACO, false);
|
||||
b2 = Util_DO.SetOutput(eDOName.PRINTL_VACI, false);
|
||||
}
|
||||
return b1 && b2;
|
||||
}
|
||||
public static Boolean SetPrintRVac(ePrintVac run, bool force)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
if (force == false && Pub.setting.Disable_PRVac == true) run = ePrintVac.off;
|
||||
bool b1, b2;
|
||||
if (run == ePrintVac.inhalation)
|
||||
{
|
||||
//흡기
|
||||
b1 = Util_DO.SetOutput(eDOName.PRINTR_VACO, false);
|
||||
b2 = Util_DO.SetOutput(eDOName.PRINTR_VACI, true);
|
||||
}
|
||||
else if (run == ePrintVac.exhaust)
|
||||
{
|
||||
//배기
|
||||
b1 = Util_DO.SetOutput(eDOName.PRINTR_VACI, false);
|
||||
b2 = Util_DO.SetOutput(eDOName.PRINTR_VACO, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
//끄기
|
||||
b1 = Util_DO.SetOutput(eDOName.PRINTR_VACO, false);
|
||||
b2 = Util_DO.SetOutput(eDOName.PRINTR_VACI, false);
|
||||
}
|
||||
return b1 && b2;
|
||||
}
|
||||
public static Boolean SetPickerVac(Boolean run, Boolean force)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
// Pub.log.Add("[F] 진공 : " + run.ToString());
|
||||
bool b1, b2, b3, b4;
|
||||
//if (Pub.setting.Disable_vacum) run = false;
|
||||
if (run)
|
||||
{
|
||||
if (force == true || Pub.setting.Disable_PKVac == false)
|
||||
{
|
||||
b1 = Pub.dio.SetOutput((int)eDOName.PICK_VAC1, true);
|
||||
b2 = Pub.dio.SetOutput((int)eDOName.PICK_VAC2, true);
|
||||
b3 = Pub.dio.SetOutput((int)eDOName.PICK_VAC3, true);
|
||||
b4 = Pub.dio.SetOutput((int)eDOName.PICK_VAC4, true);
|
||||
}
|
||||
else
|
||||
{
|
||||
b1 = b2 = b3 = b4 = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
b1 = Pub.dio.SetOutput((int)eDOName.PICK_VAC1, false);
|
||||
b2 = Pub.dio.SetOutput((int)eDOName.PICK_VAC2, false);
|
||||
b3 = Pub.dio.SetOutput((int)eDOName.PICK_VAC3, false);
|
||||
b4 = Pub.dio.SetOutput((int)eDOName.PICK_VAC4, false);
|
||||
//if (Pub.flag.get(eFlag.PK_ITEMON) == true)
|
||||
// Pub.flag.set(eFlag.PK_ITEMON, false, "VACOFF");
|
||||
}
|
||||
return b1 & b2 & b3 & b4;
|
||||
}
|
||||
|
||||
|
||||
#region "Tower Lamp"
|
||||
|
||||
/// <summary>
|
||||
/// 타워램프버튼 작업
|
||||
/// </summary>
|
||||
/// <param name="g"></param>
|
||||
/// <param name="r"></param>
|
||||
/// <param name="y"></param>
|
||||
public static void SetTWLamp(Boolean bFront, Boolean r, Boolean g, Boolean y)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return;
|
||||
|
||||
if (Util_DO.GetIOOutput(eDOName.TWR_GRNF) != g) Pub.dio.SetOutput(GetDONum(eDOName.TWR_GRNF) - 1, g);
|
||||
if (Util_DO.GetIOOutput(eDOName.TWR_REDF) != r) Pub.dio.SetOutput(GetDONum(eDOName.TWR_REDF) - 1, r);
|
||||
if (Util_DO.GetIOOutput(eDOName.TWR_YELF) != y) Pub.dio.SetOutput(GetDONum(eDOName.TWR_YELF) - 1, y);
|
||||
|
||||
if (Pub.flag.get(eFlag.MOVE_PICKER) == true)
|
||||
{
|
||||
g = true;
|
||||
r = true;
|
||||
if (Util_DO.GetIOOutput(eDOName.BUT_STARTF) != g) Pub.dio.SetOutput(GetDONum(eDOName.BUT_STARTF) - 1, g);
|
||||
if (Util_DO.GetIOOutput(eDOName.BUT_STOPF) != r) Pub.dio.SetOutput(GetDONum(eDOName.BUT_STOPF) - 1, r);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Util_DO.GetIOOutput(eDOName.BUT_STARTF) != g) Pub.dio.SetOutput(GetDONum(eDOName.BUT_STARTF) - 1, g);
|
||||
if (Util_DO.GetIOOutput(eDOName.BUT_STOPF) != r) Pub.dio.SetOutput(GetDONum(eDOName.BUT_STOPF) - 1, r);
|
||||
}
|
||||
|
||||
if (Util_DO.GetIOOutput(eDOName.BUT_RESETF) != y) Pub.dio.SetOutput(GetDONum(eDOName.BUT_RESETF) - 1, y);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static Boolean SetTwRed(Boolean ON)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
Pub.dio.SetOutput(GetDONum(eDOName.BUT_STOPF) - 1, ON);
|
||||
return Pub.dio.SetOutput(GetDONum(eDOName.TWR_REDF) - 1, ON);
|
||||
|
||||
}
|
||||
public static Boolean SetTwYel(Boolean ON)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
Pub.dio.SetOutput(GetDONum(eDOName.BUT_RESETF) - 1, ON);
|
||||
return Pub.dio.SetOutput(GetDONum(eDOName.TWR_YELF) - 1, ON);
|
||||
|
||||
}
|
||||
public static Boolean SetTwGrn(Boolean ON)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
Pub.dio.SetOutput(GetDONum(eDOName.BUT_STARTF) - 1, ON);
|
||||
return Pub.dio.SetOutput(GetDONum(eDOName.TWR_GRNF) - 1, ON);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
public static void ToggleRoomLight()
|
||||
{
|
||||
//var current = Util_DO.GetIOOutput(eDOName.ROOM_LIGHT);
|
||||
//Pub.dio.SetOutput((int)eDOName.ROOM_LIGHT, !current);
|
||||
}
|
||||
|
||||
public static Boolean SetBuzzer(Boolean ON)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
if (ON)
|
||||
{
|
||||
Pub.BuzzerTime = DateTime.Now;
|
||||
if (Pub.setting.Disable_Buzzer == true) return true; //부저기능OFF시 사용 안함
|
||||
}
|
||||
if (ON && Pub.setting.Disable_Buzzer == true)
|
||||
{
|
||||
Pub.log.AddAT("buzzer Disabled");
|
||||
ON = false;
|
||||
}
|
||||
return Pub.dio.SetOutput(GetDONum(eDOName.BUZZER) - 1, ON);
|
||||
}
|
||||
public static Boolean SetMotPowerOn(Boolean ON)
|
||||
{
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
|
||||
|
||||
|
||||
var c0 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_0);
|
||||
var c1 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_1);
|
||||
var c2 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_2);
|
||||
var c3 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_3);
|
||||
var c4 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_4);
|
||||
var c5 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_5);
|
||||
var c6 = !Util_DO.GetIOOutput(eDOName.SVR_PWR_6);
|
||||
|
||||
//꺼져잇는 신호가 하나도 없다면 이번에 끄니깐 메세지를 추가하자
|
||||
//if (c0 == false && c0 == c1 && c0 == c2 && c0 == c3 && c0 == c4 && c0 == c5 && c0 == c6)
|
||||
// Console.WriteLine("mot power off");
|
||||
|
||||
|
||||
bool b0, b1, b2, b3, b4, b5, b6;
|
||||
b0 = b1 = b2 = b3 = b4 = b5 = b6 = true;
|
||||
|
||||
if (c0 != ON) b0 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_0) - 1, !ON);
|
||||
if (c1 != ON) b1 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_1) - 1, !ON);
|
||||
if (c2 != ON) b2 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_2) - 1, !ON);
|
||||
if (c3 != ON) b3 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_3) - 1, !ON);
|
||||
if (c4 != ON) b4 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_4) - 1, !ON);
|
||||
if (c5 != ON) b5 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_5) - 1, !ON);
|
||||
if (c6 != ON) b6 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_PWR_6) - 1, !ON);
|
||||
|
||||
return b0 && b1 && b2 && b3 && b4 && b5 && b6;
|
||||
}
|
||||
public static Boolean SetMotEmergency(Boolean ON)
|
||||
{
|
||||
//if (ON == true) Console.WriteLine("mot emg on");
|
||||
if (Pub.dio == null || !Pub.dio.IsInit) return false;
|
||||
|
||||
var c0 = Util_DO.GetIOOutput(eDOName.SVR_EMG_0);
|
||||
var c1 = Util_DO.GetIOOutput(eDOName.SVR_EMG_1);
|
||||
var c2 = Util_DO.GetIOOutput(eDOName.SVR_EMG_2);
|
||||
var c3 = Util_DO.GetIOOutput(eDOName.SVR_EMG_3);
|
||||
var c4 = Util_DO.GetIOOutput(eDOName.SVR_EMG_4);
|
||||
var c5 = Util_DO.GetIOOutput(eDOName.SVR_EMG_5);
|
||||
var c6 = Util_DO.GetIOOutput(eDOName.SVR_EMG_6);
|
||||
|
||||
bool b0, b1, b2, b3, b4, b5, b6;
|
||||
b0 = b1 = b2 = b3 = b4 = b5 = b6 = ON;
|
||||
|
||||
if (c0 != ON) b0 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_0) - 1, ON);
|
||||
if (c1 != ON) b1 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_1) - 1, ON);
|
||||
if (c2 != ON) b2 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_2) - 1, ON);
|
||||
if (c3 != ON) b3 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_3) - 1, ON);
|
||||
if (c4 != ON) b4 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_4) - 1, ON);
|
||||
if (c5 != ON) b5 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_5) - 1, ON);
|
||||
if (c6 != ON) b6 = Pub.dio.SetOutput(GetDONum(eDOName.SVR_EMG_6) - 1, ON);
|
||||
return b0 && b1 && b2 && b3 && b4 && b5 && b6;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
451
Handler/Project_form2/Util/Util_Mot.cs
Normal file
451
Handler/Project_form2/Util/Util_Mot.cs
Normal file
@@ -0,0 +1,451 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace Project
|
||||
{
|
||||
public struct sPositionData
|
||||
{
|
||||
public double position;
|
||||
public double acc;
|
||||
public double dcc;
|
||||
public double speed;
|
||||
public Boolean isError;
|
||||
public string message;
|
||||
public void Clear()
|
||||
{
|
||||
position = 0;
|
||||
acc = 0;
|
||||
dcc = 0;
|
||||
speed = 0;
|
||||
isError = true;
|
||||
message = "Not Set";
|
||||
}
|
||||
}
|
||||
public static partial class Util_Mot
|
||||
{
|
||||
|
||||
#region "Get Axis Position"
|
||||
|
||||
public static sPositionData GetAxPXPos(eAxisPXPos pos) { return GetAxPos(eAxis.X_PICKER, (int)pos); }
|
||||
public static sPositionData GetAxPZPos(eAxisPZPos pos) { return GetAxPos(eAxis.Z_PICKER, (int)pos); }
|
||||
|
||||
public static sPositionData GetAxPLMPos(eAxisPLMovePos pos) { return GetAxPos(eAxis.PL_MOVE, (int)pos); }
|
||||
public static sPositionData GetAxPLZPos(eAxisPLUPDNPos pos) { return GetAxPos(eAxis.PL_UPDN, (int)pos); }
|
||||
|
||||
public static sPositionData GetAxPRMPos(eAxisPRMovePos pos) { return GetAxPos(eAxis.PR_MOVE, (int)pos); }
|
||||
public static sPositionData GetAxPRZPos(eAxisPRUPDNPos pos) { return GetAxPos(eAxis.PR_UPDN, (int)pos); }
|
||||
|
||||
public static sPositionData GetAxPTPos(eAxisPTPos pos) { return GetAxPos(eAxis.Z_THETA, (int)pos); }
|
||||
|
||||
public static sPositionData GetAxPos(eAxis axis, int pos)
|
||||
{
|
||||
return GetAxpos((int)axis, pos);
|
||||
}
|
||||
public static sPositionData GetAxpos(int axis, int pos)
|
||||
{
|
||||
var retval = new sPositionData();
|
||||
retval.Clear();
|
||||
if (Pub.Result.mModel == null || Pub.Result.mModel.isSet == false)
|
||||
{
|
||||
retval.message = "모션 모델이 설정되어 있지 않습니다";
|
||||
return retval;
|
||||
}
|
||||
var data = Pub.Result.mModel.Position[axis][pos];
|
||||
if (data.index == -1)
|
||||
{
|
||||
retval.message = string.Format("축:{0})의 위치:{1} 의 값이 존재하지 않습니다", axis, pos);// "모션 모델이 설정되어 있지 않습니다";
|
||||
return retval;
|
||||
}
|
||||
|
||||
retval.position = data.value;
|
||||
retval.speed = data.speed;
|
||||
retval.acc = data.acc;
|
||||
if (data.dcc < 1) retval.dcc = retval.acc;
|
||||
else retval.dcc = data.dcc;
|
||||
|
||||
//환경설정에서 저속모드로 설정했다면 지정된 속도로만 처리한다
|
||||
if (Pub.setting.Enable_SpeedLimit == true)
|
||||
retval.speed = Math.Min(retval.speed, Pub.setting.LimitSpeed);
|
||||
|
||||
retval.isError = false;
|
||||
retval.message = string.Empty;
|
||||
return retval;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Get Position Match"
|
||||
|
||||
|
||||
public static Boolean getPositionMatch(eAxisPXPos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPXPos(pos);
|
||||
return getPositionMatch(eAxis.X_PICKER, posData.position, offset);
|
||||
}
|
||||
|
||||
public static Boolean getPositionMatch(eAxisPZPos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPZPos(pos);
|
||||
return getPositionMatch(eAxis.Z_PICKER, posData.position, offset);
|
||||
}
|
||||
public static Boolean getPositionMatch(eAxisPTPos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPTPos(pos);
|
||||
return getPositionMatch(eAxis.Z_THETA, posData.position, offset);
|
||||
}
|
||||
|
||||
public static Boolean getPositionMatch(eAxisPLMovePos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPLMPos(pos);
|
||||
return getPositionMatch(eAxis.PL_MOVE, posData.position, offset);
|
||||
}
|
||||
|
||||
public static Boolean getPositionMatch(eAxisPLUPDNPos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPLZPos(pos);
|
||||
return getPositionMatch(eAxis.PL_UPDN, posData.position, offset);
|
||||
}
|
||||
|
||||
public static Boolean getPositionMatch(eAxisPRMovePos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPRMPos(pos);
|
||||
return getPositionMatch(eAxis.PR_MOVE, posData.position, offset);
|
||||
}
|
||||
|
||||
public static Boolean getPositionMatch(eAxisPRUPDNPos pos, double offset = 0.1)
|
||||
{
|
||||
var posData = GetAxPRZPos(pos);
|
||||
return getPositionMatch(eAxis.PR_UPDN, posData.position, offset);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region "Get Position Name"
|
||||
|
||||
public static ePickYPosition GetPKX_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.X_PICKER;
|
||||
if (Pub.mot.IsInit == false) return ePickYPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return ePickYPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return ePickYPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPXPos(eAxisPXPos.PICKON).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickYPosition.PICKON;
|
||||
|
||||
PosT = Util_Mot.GetAxPXPos(eAxisPXPos.PICKOFFR).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickYPosition.PICKOFFR;
|
||||
|
||||
PosT = Util_Mot.GetAxPXPos(eAxisPXPos.PICKOFFL).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickYPosition.PICKOFFL;
|
||||
|
||||
PosT = Util_Mot.GetAxPXPos(eAxisPXPos.READYL).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickYPosition.READYL;
|
||||
|
||||
PosT = Util_Mot.GetAxPXPos(eAxisPXPos.READYR).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickYPosition.READYR;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return ePickYPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return ePickYPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return ePickYPosition.HOME;
|
||||
else return ePickYPosition.UNKNOWN;
|
||||
}
|
||||
public static ePickZPosition GetPKZ_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.Z_PICKER;
|
||||
if (Pub.mot.IsInit == false) return ePickZPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return ePickZPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return ePickZPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPZPos(eAxisPZPos.PICKOFFR).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickZPosition.PICKOFFR;
|
||||
|
||||
PosT = Util_Mot.GetAxPZPos(eAxisPZPos.PICKOFFL).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickZPosition.PICKOFFL;
|
||||
|
||||
PosT = Util_Mot.GetAxPZPos(eAxisPZPos.PICKON).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickZPosition.PICKON;
|
||||
|
||||
PosT = Util_Mot.GetAxPZPos(eAxisPZPos.READY).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePickZPosition.READY;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return ePickZPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return ePickZPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return ePickZPosition.HOME;
|
||||
else return ePickZPosition.UNKNOWN;
|
||||
}
|
||||
public static eThetaPosition GetPT_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.Z_THETA;
|
||||
if (Pub.mot.IsInit == false) return eThetaPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return eThetaPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return eThetaPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPTPos(eAxisPTPos.READY).position;
|
||||
if (MatchPosition(Pos, PosT)) return eThetaPosition.READY;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return eThetaPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return eThetaPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return eThetaPosition.HOME;
|
||||
else return eThetaPosition.UNKNOWN;
|
||||
}
|
||||
|
||||
public static ePrintYPosition GetPLM_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.PL_MOVE;
|
||||
if (Pub.mot.IsInit == false) return ePrintYPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return ePrintYPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return ePrintYPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.PRINTH07).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTH07;
|
||||
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.PRINTH13).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTH13;
|
||||
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.PRINTL07).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTL07;
|
||||
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.PRINTL13).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTL13;
|
||||
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.PRINTM07).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTM07;
|
||||
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.PRINTM13).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTM13;
|
||||
|
||||
PosT = Util_Mot.GetAxPLMPos(eAxisPLMovePos.READY).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.READY;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return ePrintYPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return ePrintYPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return ePrintYPosition.HOME;
|
||||
else return ePrintYPosition.UNKNOWN;
|
||||
}
|
||||
|
||||
public static ePrintYPosition GetPRM_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.PR_MOVE;
|
||||
if (Pub.mot.IsInit == false) return ePrintYPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return ePrintYPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return ePrintYPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPRMPos(eAxisPRMovePos.PRINTH07).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTH07;
|
||||
|
||||
PosT = Util_Mot.GetAxPRMPos(eAxisPRMovePos.PRINTL07).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTL07;
|
||||
|
||||
PosT = Util_Mot.GetAxPRMPos(eAxisPRMovePos.PRINTH13).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTH13;
|
||||
|
||||
PosT = Util_Mot.GetAxPRMPos(eAxisPRMovePos.PRINTL13).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.PRINTL13;
|
||||
|
||||
|
||||
PosT = Util_Mot.GetAxPRMPos(eAxisPRMovePos.READY).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintYPosition.READY;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return ePrintYPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return ePrintYPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return ePrintYPosition.HOME;
|
||||
else return ePrintYPosition.UNKNOWN;
|
||||
}
|
||||
|
||||
public static ePrintZPosition GetPLZ_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.PL_UPDN;
|
||||
if (Pub.mot.IsInit == false) return ePrintZPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return ePrintZPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return ePrintZPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPLZPos(eAxisPLUPDNPos.PICKOFF).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintZPosition.PICKOFF;
|
||||
|
||||
PosT = Util_Mot.GetAxPLZPos(eAxisPLUPDNPos.PICKON).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintZPosition.PICKON;
|
||||
|
||||
PosT = Util_Mot.GetAxPLZPos(eAxisPLUPDNPos.READY).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintZPosition.READY;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return ePrintZPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return ePrintZPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return ePrintZPosition.HOME;
|
||||
else return ePrintZPosition.UNKNOWN;
|
||||
}
|
||||
|
||||
public static ePrintZPosition GetPRZ_PosName(double Pos = -1)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함\
|
||||
//eYPPosition retval = eYPPosition.Unknown;
|
||||
|
||||
var motIndex = (int)eAxis.PR_UPDN;
|
||||
if (Pub.mot.IsInit == false) return ePrintZPosition.ERROR; //200213
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return ePrintZPosition.ERROR;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return ePrintZPosition.ERROR;
|
||||
|
||||
//위치가 입력되지 않았다면 현재 위치를 사용한다
|
||||
if (Pos == -1) Pos = Pub.mot.dACTPOS[motIndex];
|
||||
|
||||
var PosT = 0.0;
|
||||
|
||||
//지정한 위치가 저장된 어느위치에 속해잇느지 확인해서 반환한다
|
||||
PosT = Util_Mot.GetAxPRZPos(eAxisPRUPDNPos.PICKOFF).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintZPosition.PICKOFF;
|
||||
|
||||
PosT = Util_Mot.GetAxPRZPos(eAxisPRUPDNPos.PICKON).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintZPosition.PICKON;
|
||||
|
||||
PosT = Util_Mot.GetAxPRZPos(eAxisPRUPDNPos.READY).position;
|
||||
if (MatchPosition(Pos, PosT)) return ePrintZPosition.READY;
|
||||
|
||||
if (Pub.mot.isLimitN[motIndex]) return ePrintZPosition.LIMITN;
|
||||
else if (Pub.mot.isLimitP[motIndex]) return ePrintZPosition.LIMITP;
|
||||
else if (Pub.mot.isOrg[motIndex]) return ePrintZPosition.HOME;
|
||||
else return ePrintZPosition.UNKNOWN;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// Z-L축이 안전위치에있는가?(Ready 보다 위에있으면 안전위치이다)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static Boolean isAxisSaftyZone(eAxis axis, int allowoffset = 2)
|
||||
{
|
||||
//홈을 잡지 않았다면 오류로 처리함
|
||||
var motIndex = (int)axis;
|
||||
if (Pub.mot.IsInit == false) return false;
|
||||
if (Pub.mot.isHomeSet[motIndex] == false) return false;
|
||||
if (Pub.Result == null || Pub.Result.isSetmModel == false) return false;
|
||||
|
||||
sPositionData readypos;
|
||||
if (axis == eAxis.X_PICKER)
|
||||
{
|
||||
//피커는 안전위이가 2개 있다
|
||||
readypos = GetAxPXPos(eAxisPXPos.PICKON);
|
||||
//var readypos1 = GetAxPXPos(eAxisPXPos.ReadyR);
|
||||
//var offset1 = getPositionOffset(axis, readypos.position);
|
||||
//var offset2 = getPositionOffset(axis, readypos1.position);
|
||||
//if (offset1 < allowoffset || offset2 < allowoffset ) return true; //오차가 2미만이라면 안전하다
|
||||
//return false;
|
||||
}
|
||||
else if (axis == eAxis.Z_PICKER) readypos = GetAxPZPos(eAxisPZPos.READY);
|
||||
else if (axis == eAxis.Z_THETA) readypos = GetAxPTPos(eAxisPTPos.READY);
|
||||
else if (axis == eAxis.PL_MOVE) readypos = GetAxPLMPos(eAxisPLMovePos.READY);
|
||||
else if (axis == eAxis.PR_MOVE) readypos = GetAxPRMPos(eAxisPRMovePos.READY);
|
||||
else if (axis == eAxis.PR_UPDN) readypos = GetAxPRZPos(eAxisPRUPDNPos.READY);
|
||||
else if (axis == eAxis.PL_UPDN) readypos = GetAxPLZPos(eAxisPLUPDNPos.READY);
|
||||
else return false;
|
||||
|
||||
var offset = getPositionOffset(axis, readypos.position);
|
||||
if (offset < allowoffset) return true; //오차가 2미만이라면 안전하다
|
||||
return false;
|
||||
}
|
||||
|
||||
private static Boolean Home_Validation(eAxis axis, out string errorMessage)
|
||||
{
|
||||
Boolean retval = true;
|
||||
// int axis = (int)axis_;
|
||||
if (!Move_Validation(axis, out errorMessage)) retval = false; //이동이 불가한 경우 체크
|
||||
else if (axis == eAxis.X_PICKER)
|
||||
{
|
||||
//Z축 홈이 필요하다
|
||||
var zFHome = Pub.mot.isHomeSet[(int)eAxis.Z_PICKER];
|
||||
var zRHome = Pub.mot.isHomeSet[(int)eAxis.Z_THETA];
|
||||
if (zFHome == false || zRHome == false)
|
||||
{
|
||||
//errorMessage = "Z-PICKER,Z-THETA 축 홈이 필요 합니다";
|
||||
//retval = false;
|
||||
}
|
||||
}
|
||||
else if (axis == eAxis.PL_MOVE) //Z축의 경우 Y축이 홈으로 된 상태여야 한다.
|
||||
{
|
||||
if (Pub.mot.isHomeSet[(int)eAxis.PL_UPDN] == false)
|
||||
{
|
||||
errorMessage = "PRINT-L Z 축 홈이 필요 합니다";
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
else if (axis == eAxis.PR_MOVE) //Z축의 경우 Y축이 홈으로 된 상태여야 한다.
|
||||
{
|
||||
if (Pub.mot.isHomeSet[(int)eAxis.PR_UPDN] == false)
|
||||
{
|
||||
errorMessage = "PRINT-R Z 축 홈이 필요 합니다";
|
||||
retval = false;
|
||||
}
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
private static Boolean Move_Validation(eAxis axis, out string errorMessage)
|
||||
{
|
||||
errorMessage = string.Empty;
|
||||
|
||||
if (Util_DO.isEmergencyOn() == true)
|
||||
{
|
||||
errorMessage = ("비상정지 상태일때에는 움직일 수 없습니다.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
486
Handler/Project_form2/Util/Util_Vision.cs
Normal file
486
Handler/Project_form2/Util/Util_Vision.cs
Normal file
@@ -0,0 +1,486 @@
|
||||
//using Emgu.CV;
|
||||
//using Emgu.CV.CvEnum;
|
||||
//using Emgu.CV.Structure;
|
||||
//using Euresys.Open_eVision_2_11;
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Drawing;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using System.Threading.Tasks;
|
||||
|
||||
//namespace Project
|
||||
//{
|
||||
// public static class Util_Vision
|
||||
// {
|
||||
// //private static object imageLockObj = new object();
|
||||
|
||||
// //public struct SCodeData
|
||||
// //{
|
||||
// // public Point[] corner;
|
||||
// // public string data;
|
||||
// // public string model;
|
||||
// // public string version;
|
||||
// // public string level;
|
||||
// // public string sid;
|
||||
// //}
|
||||
|
||||
|
||||
// //public static void DisplayQRData(List<SCodeData> DataArr, Rectangle roi, arCtl.ImageBox iv)
|
||||
// //{
|
||||
// // iv.ClearShape();
|
||||
// // foreach (var item in DataArr)
|
||||
// // {
|
||||
// // var p = new PointF[4];
|
||||
// // p[0] = new PointF(item.corner[0].X + roi.Left, item.corner[0].Y + roi.Top);
|
||||
// // p[1] = new PointF(item.corner[1].X + roi.Left, item.corner[1].Y + roi.Top);
|
||||
// // p[2] = new PointF(item.corner[2].X + roi.Left, item.corner[2].Y + roi.Top);
|
||||
// // p[3] = new PointF(item.corner[3].X + roi.Left, item.corner[3].Y + roi.Top);
|
||||
|
||||
// // iv.AddShapeLine(p[0], p[1], Color.Gold, false, 5);
|
||||
// // iv.AddShapeLine(p[1], p[2], Color.Gold, false, 5);
|
||||
// // iv.AddShapeLine(p[2], p[3], Color.Gold, false, 5);
|
||||
// // iv.AddShapeLine(p[3], p[0], Color.Gold, false, 5);
|
||||
|
||||
// // if (item.data.isEmpty() == false)
|
||||
// // {
|
||||
// // iv.AddShapeText(item.corner[1], item.data, Color.Black, 200);
|
||||
// // }
|
||||
// // }
|
||||
// //}
|
||||
|
||||
// /// <summary>
|
||||
// /// 마스킹이적용된 이미지가 반환됩니다. 마스킹
|
||||
// /// </summary>
|
||||
// /// <param name="orgEImage"></param>
|
||||
// /// <param name="Message"></param>
|
||||
// /// <param name="iv"></param>
|
||||
// /// <param name="reelsize"></param>
|
||||
// /// <returns></returns>
|
||||
// //public static EImageBW8 FindReelOutline(EImageBW8 orgEImage, out string Message, out PointF CenterPX, out float Diameter, arCtl.ImageBox iv = null, eCartSize reelsize = eCartSize.Inch7)
|
||||
// //{
|
||||
|
||||
// // EImageBW8 retval = null;// new EImageBW8(orgEImage.Width, orgEImage.Height); //마스킹이적용된 이미지
|
||||
|
||||
// // Message = string.Empty;
|
||||
// // CenterPX = PointF.Empty;
|
||||
// // Diameter = 0;
|
||||
|
||||
// // //EWorldShape EWorldShape1 = new EWorldShape(); // EWorldShape instance
|
||||
// // ECircleGauge ECircleGauge1 = new ECircleGauge(); // ECircleGauge instance
|
||||
// // ECircle Circle1 = new ECircle(); // ECircle instance
|
||||
// // ECircle measuredCircle = null; // ECircle instance
|
||||
// // iv.ClearShape("OUTLINE");
|
||||
|
||||
// // try
|
||||
// // {
|
||||
// // // EBW8Image1.Load("C:\\temp\\b.bmp");
|
||||
// // //ECircleGauge1.Attach(EWorldShape1);
|
||||
// // ECircleGauge1.Dragable = true;
|
||||
// // ECircleGauge1.Resizable = true;
|
||||
// // ECircleGauge1.Rotatable = true;
|
||||
// // // EWorldShape1.SetSensorSize(3289, 2406);
|
||||
// // // EWorldShape1.Process(EBW8Image1, true);
|
||||
// // ECircleGauge1.Thickness = 20;
|
||||
// // ECircleGauge1.TransitionChoice = ETransitionChoice.NthFromEnd;
|
||||
// // ECircleGauge1.FilteringThreshold = 3.00f;
|
||||
// // ECircleGauge1.SetCenterXY(2000f, 1400f);
|
||||
// // ECircleGauge1.Amplitude = 360f;
|
||||
// // ECircleGauge1.Tolerance = 500;
|
||||
// // ECircleGauge1.Diameter = 2200f;
|
||||
// // ECircleGauge1.Threshold = 20;
|
||||
// // ECircleGauge1.FilteringThreshold = 3.0f;
|
||||
// // ECircleGauge1.Measure(orgEImage);
|
||||
// // measuredCircle = ECircleGauge1.MeasuredCircle;
|
||||
// // if (measuredCircle.CenterX < 1 && measuredCircle.CenterY < 1)
|
||||
// // {
|
||||
// // Message = "outline not found";
|
||||
// // if (reelsize != eCartSize.None)
|
||||
// // {
|
||||
// // //마스크파일이 존재하면 해당 마스크를 사용한다
|
||||
// // var maskfilname = "Mask" + reelsize.ToString() + ".bmp";
|
||||
// // var filename = System.IO.Path.Combine(Util.CurrentPath, "Data", maskfilname);
|
||||
// // if (System.IO.File.Exists(filename))
|
||||
// // {
|
||||
// // var maskimg = new EImageBW8(); // Image<Gray, byte>(filename);
|
||||
// // maskimg.Load(filename);
|
||||
// // retval = new EImageBW8(orgEImage.Width, orgEImage.Height);
|
||||
// // EasyImage.Oper(EArithmeticLogicOperation.BitwiseAnd, orgEImage, maskimg, retval);
|
||||
// // }
|
||||
// // else Pub.log.AddE("마스크파일:" + maskfilname + "이존재하지 않아 사용하지 않습니다");
|
||||
// // }
|
||||
// // }
|
||||
// // else
|
||||
// // {
|
||||
// // retval = new EImageBW8(orgEImage.Width, orgEImage.Height);
|
||||
// // Diameter = measuredCircle.Diameter;
|
||||
// // CenterPX = new PointF(measuredCircle.CenterX, measuredCircle.CenterY);
|
||||
|
||||
// // var rect = new RectangleF(CenterPX.X - Diameter / 2.0f, CenterPX.Y - Diameter / 2.0f, Diameter, Diameter);
|
||||
// // var sh = iv.AddShapePoint(CenterPX.X, CenterPX.Y, 50, Color.Gold);
|
||||
// // sh.Tag = "OUTLINE";
|
||||
// // var shc = iv.AddShapeCircle(rect, Color.Lime, 50);
|
||||
// // shc.Tag = "OUTLINE";
|
||||
|
||||
// // //찾은 영역을 제외하고 마스크를 만든다.
|
||||
// // var dt = DateTime.Now;
|
||||
// // var maskimg = new Image<Gray, byte>(orgEImage.Width, orgEImage.Height);
|
||||
// // maskimg.SetZero();
|
||||
// // CvInvoke.Circle(maskimg, new Point((int)measuredCircle.CenterX, (int)measuredCircle.CenterY), (int)(Diameter / 2.0f), new Gray(255).MCvScalar, -1);
|
||||
|
||||
// // //maskimg.Save(@"c:\temp\mask_" + dt.ToString("HHmmss") + ".bmp");
|
||||
|
||||
// // //마스크와 결합
|
||||
// // var orgImage = new Image<Gray, byte>(orgEImage.Width, orgEImage.Height, orgEImage.RowPitch, orgEImage.GetImagePtr());
|
||||
// // {
|
||||
// // var retimg = new Image<Gray, byte>(retval.Width, retval.Height, retval.RowPitch, retval.GetImagePtr());
|
||||
// // {
|
||||
// // CvInvoke.BitwiseAnd(orgImage, maskimg, retimg);
|
||||
// // }
|
||||
// // }
|
||||
// // //orgImage.Save(@"c:\temp\type1_src1_" + dt.ToString("HHmmss") + ".bmp");
|
||||
// // //maskimg.Save(@"c:\temp\type1_src2_" + dt.ToString("HHmmss") + ".bmp");
|
||||
// // //maskedimg.Save(@"c:\temp\type1_dest_" + dt.ToString("HHmmss") + ".bmp");
|
||||
// // //iv.AddShapeBox(rect, Color.Tomato).Tag = "OUTLINE";
|
||||
// // }
|
||||
// // }
|
||||
// // catch (EException ex)
|
||||
// // {
|
||||
// // // Insert exception handling code herem
|
||||
// // Message = ex.Message;
|
||||
// // }
|
||||
// // if (iv != null) iv.Invalidate();
|
||||
// // return retval;
|
||||
// //}
|
||||
|
||||
|
||||
// //public static PointF GetGainOffset(int idx)
|
||||
// //{
|
||||
// // if (idx == 0) return new PointF(1.0f, 0.0f);
|
||||
// // else if (idx == 1) return new PointF(1.3f, 0.0f);
|
||||
// // else if (idx == 2) return new PointF(0.7f, 0.0f);
|
||||
|
||||
// // else if (idx == 3) return new PointF(1.0f, 50.0f);
|
||||
// // else if (idx == 4) return new PointF(1.0f, -50.0f);
|
||||
|
||||
// // else if (idx == 5) return new PointF(3.0f, 50.0f); //아주어두운이미지용
|
||||
// // else if (idx == 6) return new PointF(0.5f, -20.0f); //아주밝은이미지용
|
||||
|
||||
// // //else if (idx == 7) return new PointF(1.0f, -150.0f); //밝은이미지용
|
||||
// // //else if (idx == 8) return new PointF(1.0f, -170.0f); //밝은이미지용
|
||||
// // //else if (idx == 9) return new PointF(1.0f, -190.0f); //밝은이미지용
|
||||
|
||||
// // else return new PointF(1f, 0f);
|
||||
// //}
|
||||
|
||||
// //private static List<System.Drawing.PointF> GetGainOffsetList(string gainstr)
|
||||
// //{
|
||||
// // var retval = new List<System.Drawing.PointF>();
|
||||
// // var list = gainstr.Split(';');
|
||||
// // foreach (var item in list)
|
||||
// // {
|
||||
// // var ptitem = item.Split(',');
|
||||
// // if (ptitem.Length == 2)
|
||||
// // {
|
||||
// // retval.Add(new System.Drawing.PointF(float.Parse(ptitem[0]), float.Parse(ptitem[1])));
|
||||
// // }
|
||||
// // }
|
||||
// // return retval;
|
||||
// //}
|
||||
|
||||
// //public static System.Collections.Generic.List<Util_Vision.SCodeData> DetectQR_eVision(
|
||||
// // EImageBW8 EBW8Image4,
|
||||
// // arCtl.ImageBox iv1, int idx,
|
||||
// // out string Message,
|
||||
// // string erodevaluestr = "3,1",
|
||||
// // string gainoffsetlist = "2,1",
|
||||
// // uint blob_area_min = 5000,
|
||||
// // uint blob_area_max = 50000,
|
||||
// // float blob_sigmaxy = 500f,
|
||||
// // float blob_sigmayy = 500f,
|
||||
// // float blob_sigmaxx = 5000f,
|
||||
// // string maskfile = "",
|
||||
// // Image<Bgr, byte> DispImage = null
|
||||
// // )
|
||||
// //{
|
||||
// // Message = string.Empty;
|
||||
// // var pts = new System.Collections.Generic.List<Util_Vision.SCodeData>();
|
||||
// // System.Diagnostics.Stopwatch wat = new System.Diagnostics.Stopwatch();
|
||||
// // wat.Restart();
|
||||
|
||||
// // //바코드리더
|
||||
// // EQRCodeReader EQRCode1 = new EQRCodeReader(); // EQRCodeReader instance
|
||||
// // EQRCode1.DetectionMethod = 15; //모든방법으로 데이터를 찾는다
|
||||
// // EQRCode1.TimeOut = 1000 * 1000; //timeout (1초)
|
||||
|
||||
// // //Blob 으로 바코드영역을 찾는다
|
||||
// // ECodedImage2 codedImage4 = new ECodedImage2(); // ECodedImage2 instance
|
||||
// // EImageEncoder codedImage4Encoder = new EImageEncoder(); // EImageEncoder instance
|
||||
// // EObjectSelection codedImage4ObjectSelection = new EObjectSelection(); //
|
||||
// // codedImage4ObjectSelection.FeretAngle = 0.00f;
|
||||
// // using (var psegment = codedImage4Encoder.GrayscaleSingleThresholdSegmenter) //.BlackLayerEncoded = true;
|
||||
// // {
|
||||
// // psegment.BlackLayerEncoded = true;
|
||||
// // psegment.WhiteLayerEncoded = false;
|
||||
// // psegment.Mode = EGrayscaleSingleThreshold.MaxEntropy;
|
||||
// // }
|
||||
|
||||
// // //침식해서 바코드영역이 뭉치도록 한다. (바코드는 검은색 영역이 된다)
|
||||
// // List<uint> erodevalues = new List<uint>();
|
||||
// // var erodebuffer = erodevaluestr.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
|
||||
// // foreach (var erbuf in erodebuffer) erodevalues.Add(uint.Parse(erbuf));
|
||||
|
||||
// // //마스크적용 - 210209
|
||||
// // if (maskfile.isEmpty() == false && System.IO.File.Exists(maskfile))
|
||||
// // {
|
||||
// // using (var maskmig = new EImageBW8())
|
||||
// // {
|
||||
// // maskmig.Load(maskfile);//이미지불러오지
|
||||
// // EasyImage.Oper(EArithmeticLogicOperation.BitwiseAnd, EBW8Image4, maskmig, EBW8Image4);
|
||||
// // }
|
||||
// // }
|
||||
|
||||
|
||||
// // var GainOffsetList = GetGainOffsetList(gainoffsetlist);
|
||||
// // uint objectCountT = 0;
|
||||
|
||||
// // for (int maxtype = 0; maxtype < 2; maxtype++)
|
||||
// // {
|
||||
// // //침식데이터도 여러개를 사용한다.
|
||||
// // foreach (var erodevalue in erodevalues)
|
||||
// // {
|
||||
// // //인코딩된 이미지가 들어간다
|
||||
// // var ErodeImageBW8 = new EImageBW8(EBW8Image4.Width, EBW8Image4.Height);
|
||||
// // EasyImage.ErodeBox(EBW8Image4, ErodeImageBW8, erodevalue);
|
||||
|
||||
|
||||
// // using (var psegment = codedImage4Encoder.GrayscaleSingleThresholdSegmenter)
|
||||
// // {
|
||||
// // if (maxtype == 0)
|
||||
// // psegment.Mode = EGrayscaleSingleThreshold.MinResidue;
|
||||
// // else if (maxtype == 1)
|
||||
// // psegment.Mode = EGrayscaleSingleThreshold.MaxEntropy;
|
||||
// // else if (maxtype == 2)
|
||||
// // psegment.Mode = EGrayscaleSingleThreshold.IsoData;
|
||||
// // }
|
||||
|
||||
|
||||
// // codedImage4Encoder.Encode(ErodeImageBW8, codedImage4);
|
||||
// // codedImage4ObjectSelection.Clear();
|
||||
// // codedImage4ObjectSelection.AddObjects(codedImage4);
|
||||
// // codedImage4ObjectSelection.AttachedImage = ErodeImageBW8;
|
||||
|
||||
|
||||
// // //너무큰 개체를 제거한다.
|
||||
// // codedImage4ObjectSelection.RemoveUsingUnsignedIntegerFeature(EFeature.Area, blob_area_min, ESingleThresholdMode.LessEqual);
|
||||
// // codedImage4ObjectSelection.RemoveUsingUnsignedIntegerFeature(EFeature.Area, blob_area_max, ESingleThresholdMode.GreaterEqual);
|
||||
|
||||
// // //개체제거
|
||||
// // codedImage4ObjectSelection.RemoveUsingFloatFeature(EFeature.SigmaXY, blob_sigmaxy, ESingleThresholdMode.GreaterEqual);
|
||||
// // codedImage4ObjectSelection.RemoveUsingFloatFeature(EFeature.SigmaYY, blob_sigmayy, ESingleThresholdMode.LessEqual);
|
||||
// // codedImage4ObjectSelection.RemoveUsingFloatFeature(EFeature.SigmaXX, blob_sigmaxx, ESingleThresholdMode.GreaterEqual);
|
||||
|
||||
// // //찾은데이터수량
|
||||
// // var objectCount = codedImage4ObjectSelection.ElementCount;
|
||||
// // objectCountT += objectCount;
|
||||
|
||||
// // //데이터표시
|
||||
// // //찾은영역을 표시한다.
|
||||
// // for (uint i = 0; i < objectCount; i++)
|
||||
// // {
|
||||
// // //각 요소를 가져와서 처리한다.
|
||||
// // var CElement = codedImage4ObjectSelection.GetElement(i);
|
||||
// // var sigXY = CElement.SigmaXY;
|
||||
// // var sigYY = CElement.SigmaYY;
|
||||
// // var rCnt = CElement.RunCount;
|
||||
// // var rArea = CElement.Area;
|
||||
|
||||
// // var boxW = CElement.BoundingBoxWidth * Pub.setting.RosRectScale;
|
||||
// // var boxH = CElement.BoundingBoxHeight * Pub.setting.RosRectScale; //좀더크게간다 210209
|
||||
// // var boxCX = CElement.BoundingBoxCenterX;
|
||||
// // var boxCY = CElement.BoundingBoxCenterY;
|
||||
|
||||
// // var boxRate = (boxW * 1.0) / boxH;
|
||||
|
||||
// // var rect = new RectangleF(boxCX - boxW / 2.0f, boxCY - boxH / 2.0f, boxW, boxH);
|
||||
|
||||
// // //외각상자를 표시한다
|
||||
// // iv1.AddShapeBox(rect, Color.Tomato, 10);
|
||||
// // if (DispImage != null)
|
||||
// // CvInvoke.Rectangle(DispImage,
|
||||
// // new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height),
|
||||
// // new Bgr(Color.Tomato).MCvScalar, 2);
|
||||
|
||||
// // //해당영역을 ROI로 잡고 이미지를 검색한다
|
||||
// // var RoiImage = new EROIBW8();
|
||||
// // RoiImage.Attach(EBW8Image4);
|
||||
|
||||
// // //ROI로 사용할 영역의 오류를 체크해야한다
|
||||
// // var rLeft = (int)rect.Left;
|
||||
// // var rTop = (int)rect.Top;
|
||||
// // var rWid = (int)rect.Width;
|
||||
// // var rHei = (int)rect.Height;
|
||||
|
||||
// // //roi 오류수정 210621
|
||||
// // if (rLeft < 2) rLeft = 1;
|
||||
// // if (rTop < 2) rTop = 1;
|
||||
// // if (rWid < 10) rWid = 10;
|
||||
// // if (rHei < 10) rHei = 10;
|
||||
// // if (rLeft + rWid > EBW8Image4.Width) rWid = EBW8Image4.Width - rLeft - 1;
|
||||
// // if (rTop + rHei > EBW8Image4.Height) rHei = EBW8Image4.Height - rTop - 1;
|
||||
|
||||
// // var rourect = new Rectangle(rLeft, rTop, rWid, rHei);
|
||||
// // RoiImage.SetPlacement(rourect.Left, rourect.Top, rourect.Width, rourect.Height); //ROI적용
|
||||
|
||||
// // var TargetImage = new EImageBW8(RoiImage.Width, RoiImage.Height);
|
||||
|
||||
// // //밝기를 변경해서 처리해야한다
|
||||
// // //int processCount = 9;
|
||||
|
||||
// // foreach (var param in GainOffsetList) //원본, gain +-, offset +- 5가지 색상처리함
|
||||
// // {
|
||||
|
||||
// // EasyImage.ScaleRotate(RoiImage, 0, 0, 0, 0, 1.0f, 1.0f, 0f, TargetImage);
|
||||
// // //EasyImage.Copy(RoiImage, TargetImage);
|
||||
|
||||
// // //밝기를 변경해서 사용할 것이므로 해당 변경된 밝기를 저장할 이미지를 생성한다. 210128
|
||||
// // //var roiimg = new EImageBW8(TargetImage);
|
||||
// // //var param = Util_Vision.GetGainOffset(bright);
|
||||
// // if (param.X != 1.0f || param.Y != 0.0f) EasyImage.GainOffset(TargetImage, TargetImage, param.X, param.Y);
|
||||
// // //else RoiImage.CopyTo(TargetImage); ;// TargetImage.CopyTo(roiimg); //변경하지 않고 그대로 사용한다
|
||||
|
||||
// // //적용파일을 모두 저장해준다.
|
||||
// // //var roifilename = @"c:\temp\roi_" + i.ToString() + "_g" + param.X.ToString() + "_o" + param.Y.ToString() + ".bmp";
|
||||
// // //TargetImage.Save(roifilename);
|
||||
|
||||
// // EQRCode1.SearchField = TargetImage;
|
||||
// // var EQRCode2Result = EQRCode1.Read();
|
||||
// // for (int j = 0; j < EQRCode2Result.Length; j++)
|
||||
// // {
|
||||
// // var QrData = EQRCode2Result[j];
|
||||
// // if (QrData.IsDecodingReliable)
|
||||
// // {
|
||||
// // var geo = QrData.Geometry;
|
||||
// // var pos = geo.Position;
|
||||
// // var cornous = pos.Corners;
|
||||
|
||||
// // var resultData = new Util_Vision.SCodeData();
|
||||
|
||||
// // //테두리좌표 읽기
|
||||
// // var resultcorns = new List<Point>();
|
||||
// // for (int k = 0; k < cornous.Length; k++)
|
||||
// // {
|
||||
// // var con = cornous[k];
|
||||
// // resultcorns.Add(new Point((int)(con.X + rect.X), (int)(con.Y + rect.Y)));
|
||||
// // con.Dispose();
|
||||
// // }
|
||||
// // resultData.corner = resultcorns.ToArray();
|
||||
|
||||
// // //데이터읽기
|
||||
// // resultData.model = QrData.Model.ToString();
|
||||
// // resultData.version = QrData.Version.ToString();
|
||||
// // resultData.level = QrData.Level.ToString();
|
||||
// // resultData.sid = string.Empty;
|
||||
|
||||
// // //바코드데이터확인
|
||||
// // var decodestr = QrData.DecodedStream;
|
||||
// // resultData.data = string.Empty;
|
||||
// // foreach (var item in decodestr.DecodedStreamParts)
|
||||
// // {
|
||||
// // resultData.data += System.Text.Encoding.Default.GetString(item.DecodedData);
|
||||
// // item.Dispose();
|
||||
// // }
|
||||
|
||||
// // var c = new StdLabelPrint.CAmkorSTDBarcode(resultData.data);
|
||||
// // if (c.isValid) resultData.sid = c.SID;
|
||||
// // else resultData.sid = string.Empty;
|
||||
// // //if (c.isValid) break;
|
||||
// // //else resultData.data = string.Empty;
|
||||
|
||||
// // //결과데이터 추가
|
||||
// // if (resultData.data.isEmpty() == false)
|
||||
// // {
|
||||
// // if (pts.Where(t => t.data == resultData.data).Any() == false)
|
||||
// // {
|
||||
// // pts.Add(resultData);
|
||||
|
||||
// // //자료가잇다면 표시한다.
|
||||
// // var dispvalue = resultData.data;
|
||||
// // if (c.isValid == false) dispvalue += "\n" + c.Message;
|
||||
// // else if (c.DateError) dispvalue += "\n** Date Error **";
|
||||
// // iv1.AddShapeText(resultcorns[1].X, resultcorns[1].Y, dispvalue, (c.isValid ? Color.Yellow : Color.Red), 50);
|
||||
|
||||
// // if (DispImage != null)
|
||||
// // CvInvoke.PutText(DispImage,
|
||||
// // dispvalue,
|
||||
// // new Point(resultcorns[1].X, resultcorns[1].Y), FontFace.HersheyDuplex, 2,
|
||||
// // new Bgr(Color.Tomato).MCvScalar, 2);
|
||||
|
||||
// // //찾은테두리를 화면에 표시한다.
|
||||
// // foreach (var pt in resultcorns)
|
||||
// // {
|
||||
// // iv1.AddShapePoint(pt, 20f, Color.Lime);
|
||||
// // if (DispImage != null)
|
||||
// // {
|
||||
// // CvInvoke.Line(DispImage,
|
||||
// // new Point(pt.X - 10, pt.Y - 10),
|
||||
// // new Point(pt.X + 10, pt.Y + 10),
|
||||
// // new Bgr(Color.Lime).MCvScalar, 2);
|
||||
|
||||
// // CvInvoke.Line(DispImage,
|
||||
// // new Point(pt.X + 10, pt.Y - 10),
|
||||
// // new Point(pt.X - 10, pt.Y + 10),
|
||||
// // new Bgr(Color.Lime).MCvScalar, 2);
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
// // }
|
||||
|
||||
// // decodestr.Dispose();
|
||||
// // decodestr = null;
|
||||
|
||||
// // cornous = null;
|
||||
// // pos.Dispose();
|
||||
// // geo.Dispose();
|
||||
// // }
|
||||
// // QrData.Dispose();
|
||||
// // }
|
||||
|
||||
// // }
|
||||
// // TargetImage.Dispose();
|
||||
// // TargetImage = null;
|
||||
// // CElement.Dispose();
|
||||
// // }
|
||||
|
||||
// // ErodeImageBW8.Dispose(); //침식된 이미지
|
||||
// // }
|
||||
|
||||
// // }
|
||||
|
||||
|
||||
// // EQRCode1.Dispose();
|
||||
// // codedImage4ObjectSelection.Dispose(); //엔코더결과값소거
|
||||
// // codedImage4Encoder.Dispose(); //엔코더소거
|
||||
// // codedImage4.Dispose(); //코딩된이미지
|
||||
|
||||
// // wat.Stop();
|
||||
// // //iv1.AddShapeText(50, 50, wat.ElapsedMilliseconds.ToString() + "ms", Color.Lime, 50f);
|
||||
// // var mm = "[" + objectCountT.ToString() + "] " + wat.ElapsedMilliseconds.ToString() + "ms";
|
||||
// // var mmpt = new Point(20, 30 + (idx * 140));
|
||||
// // iv1.AddShapeText(mmpt.X, mmpt.Y, mm, Color.Lime, 100f);
|
||||
// // if (DispImage != null)
|
||||
// // {
|
||||
// // mmpt.Offset(0, 150);
|
||||
// // CvInvoke.PutText(DispImage, mm, mmpt, FontFace.HersheyDuplex, 6, new Bgr(Color.Lime).MCvScalar, 4);
|
||||
// // mmpt.Offset(1100, 0);
|
||||
// // CvInvoke.PutText(DispImage, DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"), mmpt, FontFace.HersheyDuplex, 6, new Bgr(Color.Gold).MCvScalar, 4);
|
||||
// // }
|
||||
|
||||
// // iv1.Invalidate();
|
||||
// // return pts;
|
||||
// //}
|
||||
|
||||
|
||||
|
||||
// }
|
||||
//}
|
||||
Reference in New Issue
Block a user