/// <summary> /// Check driver id is unique /// </summary> public void CheckDriverId() { var dict = new Dictionary <string, int>();//Driver Id with Count foreach (var driver in this.manifest.Drivers) { var key = driver.DriverId; if (!dict.ContainsKey(key)) { dict[key] = 0; } dict[key]++; } var duplicates = (from row in dict where row.Value > 1 select row).ToList(); foreach (var did in duplicates) { MvaLog.WarnNs(this, "Duplicate driver id: {0}", did.Key); } if (duplicates.Count != 0) { var did = duplicates.FirstOrDefault().Key; throw new MacWrongDriverException("Exist non-unique driver id " + did); } }
public void LoadPortUnDock() { MacHalContext halContext = null; MacHalLoadPort loportAssembly = null; MacHalLoadPortGudeng TestLoadport = null; try { halContext = new MacHalContext("GenCfg/Manifest/Manifest.xml.real"); halContext.MvaCfLoad(); loportAssembly = halContext.HalDevices[EnumMacDeviceId.loadportA_assembly.ToString()] as MacHalLoadPort; TestLoadport = loportAssembly.Hals[EnumMacDeviceId.loadport_1.ToString()] as MacHalLoadPortGudeng; TestLoadport.HalConnect(); BindLoadPortEvent(TestLoadport); TestLoadport.CommandUndockRequest(); Repeat(); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } finally { if (halContext != null) { halContext.Dispose(); } } }
public override int HalConnect() { // LddPool var connected = false; try { LddPool = MvaKjMachineDrawerLddPool.GetInstance(HostListenDrawerPortRangeStart, HostListenDrawerPortRangeEnd, HostListenDrawerSysEventPort); if (LddPool == null) { connected = false; } else { Ldd = LddPool.CreateLdd(DeviceId, DeviceEndPoint, HostIP); } if (Ldd == null || LddPool == null) { connected = false; } else { BindLddEvent(); connected = true; } } catch (Exception ex) { connected = false; MvaLog.WarnNs(this, ex); } return(connected ? 1 : 0); }
public int HalClose() { //關閉所有HAL foreach (var kv in this.HalDevices) { try { this.HalClose(kv.Value); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } //釋放資源 foreach (var kv in this.Resources) { try { if (kv.Value == null) { continue; } kv.Value.Dispose(); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } return(0); }
public object Read(string VarName) { Exception myex = null; //Fail允許重新再執行, 上限3次 for (var tryIndex = 0; tryIndex < 3; tryIndex++) { try { lock (this) { //每個要存取PLC的 都要稍等一下, 讓PLC有恢復Clock的時間 Thread.Sleep(50); return(_CIPcompolet.ReadVariable(VarName)); } } catch (Exception ex) { LogInfo(ex.Message); MvaLog.WarnNs(this, ex); myex = ex; } } //若3次嘗試存取失敗, 直接拋出Exception throw new MvaException("PLC read fail over 3 times", myex); }
public void ResourceDispose() { foreach (var rsc in this.Resources) { try { rsc.Value.Dispose(); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } }
public void Close() { try { if (this.TcpClient != null) { using (var obj = this.TcpClient) { obj.Disconnect(); } } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }
/// <summary>由IP 取得 Drawer</summary> /// <param name="deviceIP">Drawer IP</param> /// <returns></returns> public MvaKjMachineDrawerLdd GetDrawerByDeviceIP(string deviceIP) { try { var drawer = this.Drawers.Where(m => m.DeviceIP.Equals(deviceIP)).FirstOrDefault(); Debug.WriteLine(drawer.DeviceIP); return(drawer); } catch (Exception ex) { MvaLog.WarnNs(this, ex); return(null); } }
/// <summary>監聽 Server 的Method</summary> private void ListenFromServer() { int rtnEmptyCount = 0; while (true) { try { byte[] B = new byte[1023]; int inLine = ClientSocket.Receive(B);//從Server端回復(Listen Point) string rtn = Encoding.Default.GetString(B, 0, inLine); //rtn = "~001,Placement,0@\0\0\0\0"; Debug.WriteLine("[RETURN] " + rtn); rtn = rtn.Replace("\0", ""); if (string.IsNullOrEmpty(rtn)) { // 忽然斷線(將一直收到空白 50 次視為遺失連線) if (++rtnEmptyCount > 50 && OnHostLostTcpServerHandler != null) { OnHostLostTcpServerHandler.Invoke(this, EventArgs.Empty); break; } System.Threading.Thread.Sleep(100); continue; } else { rtnEmptyCount = 0; } if (OnReceviceRtnFromServerHandler != null) { // 可能一次會有多個結果 var rtnAry = rtn.Split(new string[] { BaseHostToLoadPortCommand.CommandPostfixText }, StringSplitOptions.RemoveEmptyEntries); foreach (var element in rtnAry) { var eventArgs = new OnReceviceRtnFromServerEventArgs(element); OnReceviceRtnFromServerHandler.Invoke(this, eventArgs); } } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } }
public MvaKjMachineDrawerLdd CreateLdd(string drawerIndex, IPEndPoint deviceEndpoint, string localIP) { try { // 檢查一下, ldd 是否存在, 如果存在, 就將 Ldd 找出來,回傳 Note: 2020/11/13 King MvaKjMachineDrawerLdd ldd = new MvaKjMachineDrawerLdd(drawerIndex, deviceEndpoint, localIP, this.PortStatusDictionary); _ldds.Add(ldd); return(ldd); } catch (Exception ex) { MvaLog.WarnNs(this, ex); return(null); } }
/// <summary>產生 Drawer</summary> /// <param name="cabinetNo">Cabinet 編號</param> /// <param name="drawerNo">Drawer 編號</param> /// <param name="deviceIP">裝置 IP</param> /// <param name="udpServerPort">Drawer 內建 UDP Server Port</param> /// <returns></returns> public MvaKjMachineDrawerLdd CreateDrawer(int cabinetNo, string drawerNo, IPEndPoint deviceEndpoint, string localIP) { try { MvaKjMachineDrawerLdd drawer = new MvaKjMachineDrawerLdd(cabinetNo, drawerNo, deviceEndpoint, localIP, this.PortStatusDictionary); Drawers.Add(drawer); return(drawer); } catch (Exception ex) { MvaLog.WarnNs(this, ex); return(null); } }
/// <summary>Client(本地)端 Listen 收到 Server 端回傳資料後引發的事件程序</summary> /// <param name="sender"></param> /// <param name="args"></param> private void ReceiveMessageFromServer(object sender, EventArgs args) { var eventArgs = (OnReceviceRtnFromServerEventArgs)args; ReturnFromServer rtnContent = new ReturnFromServer(eventArgs.RtnContent); var methodName = rtnContent.StringContent.Replace(" ", "_");//.Replace("\0", ""); try { var method = typeof(MvGudengLoadPortLdd).GetMethod(methodName); method.Invoke(this, new object[] { rtnContent }); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }
/// <summary>啟動監聽 Server 端的 Thread</summary> public bool StartListenServerThread() { try { ClientSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); ClientSocket.Connect(ServerEndPoint); ThreadClientListen = new Thread(ListenFromServer); ThreadClientListen.Start(); IsListenServer = true; } catch (Exception ex) { MvaLog.WarnNs(this, ex); IsListenServer = false; } return(IsListenServer); }
public void LoadPortCommandTest() { try { using (var halContext = new MacHalContext("GenCfg/Manifest/Manifest.xml.real")) { halContext.MvaCfLoad(); var loportAssembly = halContext.HalDevices[EnumMacDeviceId.loadportA_assembly.ToString()] as MacHalLoadPort; var testLoadPort = loportAssembly.Hals[EnumMacDeviceId.loadport_1.ToString()] as MacHalLoadPortGudeng; testLoadPort.HalConnect(); // BindLoadPortEvent(loadport1); BindLoadPortEvent(testLoadPort); testLoadPort.CommandAlarmReset(); testLoadPort.CommandInitialRequest(); Repeat(); } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }
public void DrawerTest() { using (var halContext = new MacHalContext("UserData/Manifest/Manifest.xml.real")) { halContext.InitialAndLoad(); var s = halContext.DrawersConnect(); var drawer = halContext.GetDrawer(DrawerKeys[1]); try { drawer.Initial(); // while (true) //{ // System.Threading.Thread. Sleep(100); // } drawer.MoveTrayToOut(); drawer.MoveTrayToHome(); drawer.MoveTrayToIn(); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } }
public MvaKjMachineDrawerLdd(int cabinetNO, string drawerNO, IPEndPoint deviceEndpoint, string localIp, IDictionary <int, bool?> portTable) : this() { DrawerNO = drawerNO; CabinetNO = cabinetNO; DeviceIP = deviceEndpoint.Address.ToString(); TargetEndpoint = deviceEndpoint; UdpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); while (true) { // 可用的 port int variablePort = 0; try { KeyValuePair <int, bool?> keyValuePair = portTable.Where(m => m.Value == default(bool?)).FirstOrDefault(); if (keyValuePair.Equals(default(KeyValuePair <int, bool?>))) { // 無 Port 可用時 // TODO : To Thorw an Exception } variablePort = keyValuePair.Key; // Bind 的端點名稱 IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse(localIp), variablePort); UdpSocket.Bind(endPoint); portTable.Remove(variablePort); portTable.Add(variablePort, true); break; } catch (Exception ex) { portTable.Remove(variablePort); portTable.Add(variablePort, false); MvaLog.WarnNs(this, ex); } } ListenThread = new Thread(Listen); ListenThread.IsBackground = true; ListenThread.Start(); }
public void DrawerBasicTest() { try { var halContext = new MacHalContext("GenCfg/Manifest/Manifest.xml.real"); halContext.MvaCfLoad(); var cabinet = halContext.HalDevices[EnumMacDeviceId.cabinet_drawer_01_01.ToString()] as MacHalCabinet; var drawer = cabinet.Hals[EnumMacDeviceId.cabinet_drawer_01_01.ToString()] as MacHalDrawerKjMachine; var connected = drawer.HalConnect(); var isConnected = drawer.HalIsConnected(); // vs 2013 //Debug.WriteLine($"IsConnected={isConnected}"); Debug.WriteLine("IsConnected=" + isConnected); BindEvents(drawer); Repeat(); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }
/// <summary>按入 Load 鍵</summary> /// <param name="sender"></param> /// <param name="e"></param> private void BtnLoad_Click(object sender, EventArgs e) { try { if (File.Exists(TxtBxDevicePath.Text)) { var datas = ToLoad(); if (datas > 0) { RefreshPositionInfoList(); MessageBox.Show("資料己經載入"); } else { MessageBox.Show("沒有資料"); } } else { MessageBox.Show(TxtBxDevicePath.Text + " 不存在"); } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }
[DataRow(EnumMacMaskBoxType.IronBox, false)] // 鐵盒 //[DataRow(BoxType.CrystalBox,false)]// 水晶盒 public void Test_Ut001_BT(EnumMacMaskBoxType boxType, bool autoConnect) { var BREAK_POINT = 0; using (var halContext = MacHalContextExtends.Create_MacHalContext_Instance()) { try { var universal = halContext.GetUniversalAssembly(autoConnect); var boxTransfer = halContext.GetBoxTransferAssembly(autoConnect); var cabinet = halContext.GetCabinetAssembly(autoConnect); var openStage = halContext.GetOpenStageAssembly(autoConnect); if (!autoConnect) { universal.HalConnect(); boxTransfer.HalConnect(); cabinet.HalConnect(); openStage.HalConnect(); } // Initial OpenStage openStage.Initial(); openStage.SetBoxType((uint)boxType); openStage.SortClamp(); // Initial BoxTransfer boxTransfer.Initial(); // 關燈 boxTransfer.TurnOffCameraLight(); // connect 所有 Drawer halContext.DrawersConnect(); for (int i = 0; 0 < DrawerKeys.Count; i++) { try { // 取得 Drawer var drawer = halContext.GetDrawer(DrawerKeys[i]); // Drawer 代碼 var drawerLocation = DrawerLocations[i]; // Drawer Home var drawerHome = DrawerLocations[i].GetCabinetHomeCode().Item2; // Drawer Initial drawer.Initial(); // boxTransfer 轉向 Cabitnet 1 Home boxTransfer.TurnToCB1Home(); BREAK_POINT = 0; /** 1 光罩鐵盒放置於Open Stage平台上*/ BREAK_POINT = 0; // 確認 光罩鐵盒放置於Open Stage平台上*/ /** 2. Drawer往機台內部移動到光罩盒可放置的位置 */ // 將 Drawer 的Tray 移到 In drawer.MoveTrayToIn(); BREAK_POINT = 0; /** 3. Box Robot從Home點至Open Stage進行光罩鐵盒夾取*/ // 3.1 能否入侵 Open Stage? openStage.SetRobotIntrude(true, null); // 3.2 將 Boxrobot 移到 OpenStage var path = pathFileObj.FromCabinet01HomeToOpenStage_GET_PathFile(); openStage.SortUnclamp(); openStage.Lock(); boxTransfer.Move(path); boxTransfer.Clamp((uint)boxType); BREAK_POINT = 0; /** 4. Box Robot從Open Stage夾持光罩至Drawer放置點位之前一個點位 (暫且定義為 CB1 Home 或CB2 Home) */ path = pathFileObj.FromOpenStageToCabinet01Home_GET_PathFile(); boxTransfer.Move(path); if (drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { boxTransfer.TurnToCB2Home(); } #region 拍照 , 移到 6~7 間 // 5. (編號13-CCD): 開啟光源 -> 拍照(FOV正確) -> 關閉光源, 確認Drawer中無光罩盒 #endregion BREAK_POINT = 0; /** 6. Box Robot從Open Stage夾持光罩至Drawer放置點位 (不做放置光罩鐵盒於drawer的動作) */ // 將 BoxRobot 移到 Drawer if (drawerHome == BoxrobotTransferLocation.Cabinet_01_Home) { path = pathFileObj.FromCabinet01HomeToDrawer_PUT_PathFile(drawerLocation); } else //if(drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { boxTransfer.TurnToCB2Home(); path = pathFileObj.FromCabinet02HomeToDrawer_PUT_PathFile(drawerLocation); } boxTransfer.Move(path); // 拍照 // boxTransfer.CameraShot("Ut001_BT_" + drawerLocation); BREAK_POINT = 0; /** 7. Box Robot夾持光罩回到Drawer entry點位 (目前没有 teach Drawer entry 點 這個點位, 改以 回到 CB1_HOME 或 CB2_Home)*/ // 7.1 以Get 方式回到 Cb1Home(目前有盒子) if (drawerHome == BoxrobotTransferLocation.Cabinet_01_Home) { // cabinet 1 path = pathFileObj.FromDrawerToCabinet01Home_GET_PathFile(drawerLocation); } else if (drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { // cabinet 2 path = pathFileObj.FromDrawerToCabinet02Home_GET_PathFile(drawerLocation); } boxTransfer.Move(path); // 7.2 如果 Drawer 是 Cabinet 2的Drawer, 再回到 Cabitnet 1 Home if (drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { boxTransfer.TurnToCB1Home(); } // 7.3 檢查入侵到 Open Stage openStage.SetRobotIntrude(true, null); // 入侵 path = pathFileObj.FromCabinet01HomeToOpenStage_PUT_PathFile(); // 7.4 BoxTransfer 移到 OpenStage boxTransfer.Move(path); // 7.5 放下盒子 boxTransfer.Unclamp(); // => 第二 個以後Drawer(01_03, 01_04 ,......, 07_03) 的 1. // 7.6 Box robot 回CB1Home path = pathFileObj.FromOpenStageToCabinet01Home_PUT_PathFile(); boxTransfer.Move(path); BREAK_POINT = 0; // 8. Drawer回到Cabinet內 drawer.MoveTrayToHome(); // 9. 重複1~8步驟, 完成20個Drawer的光罩鐵盒的移動測試(下個 Cycle) //10.重複1~8步驟, 完成20個Drawer的光罩水晶盒的移動測試 } catch (Exception ex) { } } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }; }
public void TestMethod1() { MacTestMyUtil.RegisterLog(); //Clean Ch./Light IWDV-100S-24 var are = new AutoResetEvent(false); using (var light = new MvaLeimacLightLdd()) { light.TcpClient.EhDataReceive += (ss, ee) => { MvaLog.WarnNs(this, ee.Message); MvaLog.WarnNs(this, ee.TrxMessage.GetString()); are.Set(); }; light.TcpClient.EhErrorReceive += (ss, ee) => { MvaLog.WarnNs(this, ee.Message); }; light.TcpClient.EhFailConnect += (ss, ee) => { MvaLog.WarnNs(this, ee.Message); }; light.TcpClient.EhDisconnect += (ss, ee) => { MvaLog.WarnNs(this, ee.Message); }; light.TcpClient.EhFirstConnect += (ss, ee) => { MvaLog.WarnNs(this, ee.Message); }; //LP //light.Model = MvEnumLeimacModel.IDGB_50M4PG_24_TP; //light.ConnectTry("192.168.0.119", 1000); //CL //light.Model = MvEnumLeimacModel.IWDV_100S_24; //light.ConnectTry("192.168.0.129", 1000); //OS //light.Model = MvEnumLeimacModel.IDGB_50M4PG_24_TP; //light.ConnectTry("192.168.0.139", 1000); //RB //light.Model = MvEnumLeimacModel.IDGB_50M4PG_24_TP; //light.ConnectTry("192.168.0.155", 1000); //IC1: ch1: Top Defense 環形光 ; ch2: Side Inspection 條形光 ; ch3: Side Defense 條形光 ; ch4: No install light.Model = MvaEnumLeimacModel.IDGB_50M4PG_24_TP; var status = light.ConnectTry("192.168.0.160", 1000); //IC2: ch1: Top Inspcetion 環形光 ; ch2: No install //light.Model = MvEnumLeimacModel.IDGB_50M2PG_12_TP; //var status = light.ConnectTry("192.168.0.161", 1000); while (!light.TcpClient.IsRemoteConnected) { Thread.Sleep(100); } //IC3: ch1: Left Spot Light ; ch2: Right Spot Light //light.Model = MvEnumLeimacModel.IWDV_600M2_24; //light.ConnectTry("192.168.0.162", 1000); for (var idx = 0; idx < 10; idx++) { light.SetValue(1, 0); Thread.Sleep(1000); are.WaitOne(); } } }
public void DrawerCommandTest() { try { using (var halContext = new MacHalContext("GenCfg/Manifest/Manifest.xml.real")) { halContext.MvaCfBootup(); halContext.MvaCfLoad(); // halContext.MvCfInit(); //halContext.MvCfLoad(); var unv = halContext.HalDevices[EnumMacDeviceId.eqp_assembly.ToString()] as MacHalEqp; unv.HalConnect(); var cabinet = halContext.HalDevices[EnumMacDeviceId.cabinet_assembly.ToString()] as MacHalCabinet; cabinet.HalConnect(); // var drawer_01_01 = cabinet.Hals[MacEnumDevice.cabinet_drawer_01_01.ToString()] as MacHalDrawerKjMachine; // var drawer_01_02 = cabinet.Hals[MacEnumDevice.cabinet_drawer_01_02.ToString()] as MacHalDrawerKjMachine; var DR0101 = halContext.HalDevices[EnumMacDeviceId.cabinet_drawer_01_01.ToString()] as MacHalCabinet; //.Hals[MacEnumDevice.cabinet_drawer_01_01.ToString()] as MacHalDrawerKjMachine; var DR0102 = halContext.HalDevices[EnumMacDeviceId.cabinet_drawer_01_02.ToString()] as MacHalCabinet; //.Hals[MacEnumDevice.cabinet_drawer_01_02.ToString()] as MacHalDrawerKjMachine; // var drawer_01_01 = halContext.HalDevices[MacEnumDevice.cabinet_drawer_01_01.ToString()] as MacHalCabinet;//.Hals[MacEnumDevice.cabinet_drawer_01_01.ToString()] as MacHalDrawerKjMachine; // var drawer_01_02 = halContext.HalDevices[MacEnumDevice.cabinet_drawer_01_02.ToString()] as MacHalCabinet;//.Hals[MacEnumDevice.cabinet_drawer_01_02.ToString()] as MacHalDrawerKjMachine; var drawer_01_01 = DR0101.MacHalDrawer; var drawer_01_02 = DR0102.MacHalDrawer; var isConnected = drawer_01_01.HalConnect(); // vs 2013 // Debug.WriteLine($"IsConnected={isConnected}"); Debug.WriteLine("IsConnected=" + isConnected); drawer_01_02.HalConnect(); BindEvents(drawer_01_01); BindEvents(drawer_01_02); /** CommandSetMotionSpeed */ drawer_01_01.CommandSetMotionSpeed(100); drawer_01_02.CommandSetMotionSpeed(100); /** CommandPositionRead * drawer_01_02.CommandPositionRead(); * drawer_01_01.CommandPositionRead(); */ /** CommandBoxDetection * drawer_01_01.CommandBoxDetection(); * drawer_01_02.CommandBoxDetection(); */ /**CommandBrightLEDAllOn() * drawer_01_01.CommandBrightLEDAllOn(); * drawer_01_02.CommandBrightLEDAllOn(); */ /**CommandBrightLEDAllOff() * drawer_01_01.CommandBrightLEDAllOff(); * drawer_01_02.CommandBrightLEDAllOff(); */ /** CommandBrightLEDGreenOn() * drawer_01_01.CommandBrightLEDGreenOn(); * drawer_01_02.CommandBrightLEDGreenOn(); */ /** CommandBrightLEDRedOn() * drawer_01_01.CommandBrightLEDRedOn(); * drawer_01_02.CommandBrightLEDRedOn(); */ /** CommandINI() * drawer_01_01.CommandINI(); * drawer_01_02.CommandINI(); */ /** CommandSetTimeOut() * drawer_01_01.CommandSetTimeOut(100); * drawer_01_02.CommandSetTimeOut(100); */ /** CommandTrayMotionHome() * drawer_01_01.CommandTrayMotionHome(); * drawer_01_02.CommandTrayMotionHome(); */ /** CommandTrayMotionHome() * drawer_01_01.CommandTrayMotionIn(); * drawer_01_02.CommandTrayMotionIn(); */ /** CommandTrayMotionHome() * drawer_01_01.CommandTrayMotionOut(); * drawer_01_01.CommandTrayMotionOut(); */ Repeat(); } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } }
[DataRow(EnumMacMaskBoxType.IronBox, true, DrawerReplaceBoxPlace.In)] // 鐵盒 //[DataRow(BoxType.CrystalBox,true)] // 水晶盒 public void TestMethod1(EnumMacMaskBoxType boxType, bool autoConnect, DrawerReplaceBoxPlace drawerReplaceBoxPlace) { var BREAK_POINT = 0; using (var halContext = new MacHalContext("UserData/Manifest/Manifest.xml.real")) { /** Index & array * [0] [1] [2] * 1-2, 1-3, 1-4 IP: 31~33 * ------------------ * [3] [4] [5] * 2-2, 2-3, 2-4, IP: 41~43 * ------------------ * [6] [7] [8] * 3-2, 3-3, 3-4, IP: 51~53 * ---------------- * [9] [10] [11] * 4-2, 4-3, 4-4, IP: 61~63 * ------------------ * [12] [13] [14] * 5-2, 5-3, 5-4, IP: 71~73 * ------------------ * [15] [16] [17] * 6-2, 6-3, 6-4, IP: 81~83 *-------------------- * [18] [19] * 7-2, 7-3, IP: 91~92 */ halContext.MvaCfBootup(); halContext.MvaCfLoad(); try { var uni = halContext.HalDevices[EnumMacDeviceId.eqp_assembly.ToString()] as MacHalEqp; var bt = halContext.HalDevices[EnumMacDeviceId.boxtransfer_assembly.ToString()] as MacHalBoxTransfer; var os = halContext.HalDevices[EnumMacDeviceId.openstage_assembly.ToString()] as MacHalOpenStage; string btMovePathFile = default(string); uni.HalConnect(); bt.HalConnect(); os.HalConnect(); halContext.DrawersConnect(); //bt.Reset(); bt.Initial(); //bt.TurnToCB1Home(); int start = 8; int end = 10; for (var i = start; i < end; i++) { try { var drawerLocation = DrawerLocations[i]; var drawer = halContext.GetDrawer(DrawerKeys[i]); IMacHalDrawer previousDrawer = null; var drawerHome = drawerLocation.GetCabinetHomeCode().Item2; /** 00 預先動作, 如有上一輪的 Drawer, 將上一輪的 Drawer 推回到 Out , 取出 Box, 將Box放到現在的 Drawer Tray中, 並將 Tray 放回 Home */ // 0.1 如有上一輪的 Drawer, 將其 Tray 移到 可抽換 box 的位置 if (i > start) { previousDrawer = halContext.GetDrawer(DrawerKeys[i - 1]); previousDrawer.MoveTrayToHome(); if (drawerReplaceBoxPlace == DrawerReplaceBoxPlace.In) { previousDrawer.MoveTrayToIn(); } else { previousDrawer.MoveTrayToOut(); } } // 0.2 將目前的 Drawer Tray Initial drawer.Initial(); // 0.3 將 目前的 Drawer Tray 移回 可以置換 Drawer 的地方 if (drawerReplaceBoxPlace == DrawerReplaceBoxPlace.In) { drawer.MoveTrayToIn(); } else { drawer.MoveTrayToOut(); } /**1. 光罩盒置於 Drawer內*/ BREAK_POINT++; //[[[[[[[[[[[[[[[[[[一定要暫停]]]]]]]]]]]]]]]]]]]]]]]]]] 確認有 Box後往下執行 // 1.1 如有上一個 Drawer, 將上一個 Drawer 移到 Home if (previousDrawer != null) { // previousDrawer.MoveTrayToHome();; } // 1.2 Drawer Tray 往機台內部移動到可以取得光罩的位置 drawer.MoveTrayToHome(); drawer.MoveTrayToIn(); /** 02 Box Robot從Home點至Drawer entry處*/ if (drawerHome == BoxrobotTransferLocation.Cabinet_01_Home) { // Drawer 01-01 ~ Drawer 03-05 bt.TurnToCB1Home(); btMovePathFile = pathFileObj.FromCabinet01HomeToDrawer_GET_PathFile(drawerLocation); // Box Transfer 要去 Drawer 夾盒子, 所以用 GET } else //if(drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { // // Drawer 04-01 ~ Drawer 07-05 //Cabinet 2 Drawer 的 Path bt.TurnToCB1Home(); bt.TurnToCB2Home(); btMovePathFile = pathFileObj.FromCabinet02HomeToDrawer_GET_PathFile(drawerLocation); // Box Transfer 要去 Drawer 夾盒子, 所以用 GET } bt.Move(btMovePathFile); /** 03 (編號13-CCD): 開啟光源 -> 拍照(FOV正確) -> 關閉光源*/ try { var lightValue = bt.GetCameraLightValue(boxType); bt.LightForGripperSetValue(lightValue); bt.Camera_CapToSave("D:/Image/BT/Gripper", "jpg"); //bt.LightForGripper(0); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } finally { bt.LightForGripperSetValue(0); } // bt.Clamp((uint)boxType); //var lightValue = bt.GetCameraLightValue(boxType); //var resultTemp=bt.CameraShot("D:/Image/BT/Gripper", "jpg",lightValue); /** 04 Box Robot從Drawer Entry處移至Drawer內進行光罩鐵盒夾取*/ var resultTemp = bt.Clamp((uint)boxType); /** 05 光罩鐵盒夾取前確認Box Robot是水平狀態 (by 水平儀)*/ var Level = bt.ReadLevelSensor(); /** 06 Box Robot將光罩鐵盒從Drawer移動至Open Stage上方*/ // 6.1 回到 Cabinet 1 Home if (drawerHome == BoxrobotTransferLocation.Cabinet_01_Home) { btMovePathFile = pathFileObj.FromDrawerToCabinet01Home_GET_PathFile(drawerLocation); // Box Transfer 夾到盒子後,由 Drawer 回到 Home, 用GET bt.Move(btMovePathFile); } else // if(drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { // Drawer 04_01~07~05 回到 Cabinet 1 Home btMovePathFile = pathFileObj.FromDrawerToCabinet02Home_GET_PathFile(drawerLocation);// Box Transfer 夾到盒子後,由 Drawer 回到 Home, 用GET bt.Move(btMovePathFile); bt.TurnToCB1Home(); } // 6.2 boxrobot 移到 OpenStage os.SetRobotIntrude(true, null); btMovePathFile = pathFileObj.FromCabinet01HomeToOpenStage_PUT_PathFile(); // boxrobot 目前有盒子, 要到 Open Stage, 用PUT bt.Move(btMovePathFile); /** 07 光罩鐵盒放置前確認Box Robot是水平狀態 (by 水平儀)*/ Level = bt.ReadLevelSensor(); /** 08 Box Robot將光罩鐵盒放置於Open Stage上*/ bt.Unclamp(); /** 09 Box Robot退出Open Stage, 並回到Box Robot Home點*/ btMovePathFile = pathFileObj.FromOpenStageToCabinet01Home_PUT_PathFile(); bt.Move(btMovePathFile); os.SetRobotIntrude(false, null); /** 10 (編號9-CCD): 開啟光源 -> 拍照(FOV正確) -> 關閉光源*/ /** * os.LightForTopBarDfsSetValue(200); * os.Camera_Top_CapToSave("D:/Image/OS/Top", "jpg"); * os.LightForTopBarDfsSetValue(0); */ try { os.LightForFrontBarDfsSetValue(85); //bar 0~255 os.LightForSideBarDfsSetValue(140); //bar 0~255 os.LightForTopBarDfsSetValue(20); //bar 0~255 os.Camera_Top_CapToSave("D:/Image/OS/Top", "jpg"); Debug.WriteLine("Open Stage Camera Shot(Top) OK"); } catch (Exception ex) { Debug.WriteLine("Open Stage Camera Shot(Top) Error=" + ex.Message); } finally { os.LightForFrontBarDfsSetValue(0); os.LightForSideBarDfsSetValue(0); os.LightForTopBarDfsSetValue(0); } /** 11 (編號12-CCD): 開啟光源 -> 拍照(FOV正確) -> 關閉光源*/ /** * os.LightForSideBarDfsSetValue(200); * os.Camera_Side_CapToSave("D:/Image/OS/Side", "jpg"); * os.LightForSideBarDfsSetValue(0); */ try { os.LightForFrontBarDfsSetValue(85); //bar 0~255 os.LightForSideBarDfsSetValue(140); //bar 0~255 os.LightForTopBarDfsSetValue(20); //bar 0~255 os.Camera_Side_CapToSave("D:/Image/OS/Side", "jpg"); Debug.WriteLine("Open Stage Camera Shot OK"); } catch (Exception ex) { Debug.WriteLine("Open Stage Camera Shot(Side) Error=" + ex.Message); } finally { os.LightForFrontBarDfsSetValue(0); os.LightForSideBarDfsSetValue(0); os.LightForTopBarDfsSetValue(0); } /** 12 Box Robot(無夾持光罩鐵盒)從Home點移動進入Open Stage上方*/ os.SetRobotIntrude(true, null); btMovePathFile = pathFileObj.FromCabinet01HomeToOpenStage_GET_PathFile(); bt.Move(btMovePathFile); /** 13 光罩鐵盒夾取前確認Box Robot是水平狀態 (by 水平儀)*/ Level = bt.ReadLevelSensor(); /** 14 Box Robot從Open Stage上方夾取光罩鐵盒*/ bt.Clamp((uint)boxType); /** 15 Box Robot將光罩鐵盒移動至Drawer處*/ // 15.1 Boxrobot 移到 Cabitnet 1 Home btMovePathFile = pathFileObj.FromOpenStageToCabinet01Home_GET_PathFile(); // boxrobot 目前有盒子,要回到 Cabinet 1 Home, 用 GET bt.Move(btMovePathFile); os.SetRobotIntrude(false, null); // 15.2 if (drawerHome == BoxrobotTransferLocation.Cabinet_01_Home) { // drawer 01-01 ~ drawer 03-05 btMovePathFile = pathFileObj.FromCabinet01HomeToDrawer_PUT_PathFile(drawerLocation); // boxrobot 目前有盒子,要到 Drawer, 所以用 PUT bt.Move(btMovePathFile); } else //if(drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { // drawer 04-01 ~ drawer 07-05 bt.TurnToCB2Home(); btMovePathFile = pathFileObj.FromCabinet02HomeToDrawer_PUT_PathFile(drawerLocation); // boxrobot 目前有盒子,要到 Drawer, 所以用 PUT bt.Move(btMovePathFile); } /** 16 (編號13-CCD): 開啟光源 -> 拍照(FOV正確) -> 關閉光源*/ try { var lightValue = bt.GetCameraLightValue(boxType); bt.LightForGripperSetValue(lightValue); bt.Camera_CapToSave("D:/Image/BT/Gripper", "jpg"); } catch (Exception ex) { MvaLog.WarnNs(this, ex); } finally { bt.LightForGripperSetValue(0); } //lightValue = bt.GetCameraLightValue(boxType); //resultTemp= bt.CameraShot("D:/Image/BT/Gripper", "jpg", lightValue); /** 17 Box Robot將光罩鐵盒移動至Drawer內*/ bt.Unclamp(); /** 18 Box Robot (無夾持光罩鐵盒) 從Drawer移回Home點*/ // 18.1 Boxrobot 移回 Home 點 if (drawerHome == BoxrobotTransferLocation.Cabinet_01_Home) { btMovePathFile = pathFileObj.FromDrawerToCabinet01Home_PUT_PathFile(drawerLocation); // } else //if(drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { btMovePathFile = pathFileObj.FromDrawerToCabinet02Home_PUT_PathFile(drawerLocation); // T } bt.Move(btMovePathFile); // 18.2 Drawer 04-01 ~ Drawer 07-05 時 Boxrobot 轉回 Cabitnet 1 Home if (drawerHome == BoxrobotTransferLocation.Cabinet_02_Home) { bt.TurnToCB1Home(); } // drawer.CommandINI(); /** 19 重複1~18步驟, 完成20個Drawer的光罩鐵盒測試*/ /** 20 重複1~19步驟, 完成20個Drawer的光罩水晶盒測試*/ BREAK_POINT++; // [一定要暫停] 這個 drawer 做好了, 準備下一個 } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } } catch (Exception ex) { MvaLog.WarnNs(this, ex); } } }