/// <summary> /// <para>判斷自己是屬於哪個 Cabinet Home;</para> /// 可以判斷: 回傳 Tuple<true, Cabinet Home 代碼> /// <para>自己就是 Cabinet Home: 回傳 Tuple<false, 自己></para> /// 無法判別: 回傳回傳型態的預設值 /// </summary> /// <param name="inst"></param> /// <returns></returns> public static Tuple <bool, BoxrobotTransferLocation> GetCabinetHomeCode(this BoxrobotTransferLocation inst) { if (inst.IsDrawer()) { if (inst < BoxrobotTransferLocationExtends.Cabinet2Start) { return(Tuple.Create(true, BoxrobotTransferLocation.Cabinet_01_Home)); } else { return(Tuple.Create(true, BoxrobotTransferLocation.Cabinet_02_Home)); } } else { if (inst == BoxrobotTransferLocation.Cabinet_01_Home || inst == BoxrobotTransferLocation.Cabinet_02_Home) { return(Tuple.Create(false, inst)); } else { return(default(Tuple <bool, BoxrobotTransferLocation>)); } } }
/// <summary> /// <para>將自己轉換為 4 碼的Drawer 代碼, 如果是,回傳 Tuple<true,代碼>如果不是 Drawer Location 的列舉, 就回傳 Tuple<false,""></para> /// <para>代碼格式, 如:0101, 0102, 0704, ......</para> /// </summary> /// <param name="inst"></param> /// <returns></returns> public static Tuple <bool, string> To4DigitDrawerCode(this BoxrobotTransferLocation inst) { Tuple <bool, string> rtnV = null; if (inst.IsDrawer()) { try { var drawerText = inst.ToString(); string code = ""; string[] ary = drawerText.Split('_'); int aryLength = ary.Length; code = ary[ary.Length - 2] + ary[aryLength - 1]; rtnV = Tuple.Create(true, code); } catch (Exception ex) { rtnV = Tuple.Create(false, string.Empty); } } else { rtnV = Tuple.Create(false, string.Empty); } return(rtnV); }