private void resetSpecifyAdr()
 {
     try
     {
         if (!BCFUtility.isEmpty(reqSelectionStartAdr))
         {
             uctl_Map.changeSpecifyAddressColor
                 (reqSelectionStartAdr, CLR_MAP_ADDRESS_DUFAULT);
             reqSelectionStartAdr = string.Empty;
         }
         if (!BCFUtility.isEmpty(reqSelectionFromAdr))
         {
             uctl_Map.changeSpecifyAddressColor
                 (reqSelectionFromAdr, CLR_MAP_ADDRESS_DUFAULT);
             reqSelectionFromAdr = string.Empty;
         }
         if (!BCFUtility.isEmpty(reqSelectionToAdr))
         {
             uctl_Map.changeSpecifyAddressColor
                 (reqSelectionToAdr, CLR_MAP_ADDRESS_DUFAULT);
             reqSelectionToAdr = string.Empty;
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
 }
        private async void btn_Avoid_Click(object sender, EventArgs e)
        {
            string   vehicle_id = cmb_Vehicle.Text;
            string   avoid_adr  = cmb_toAddress.Text;
            AVEHICLE vh         = scApp.getEQObjCacheManager().getVehicletByVHID(vehicle_id);

            if (vh == null)
            {
                MessageBox.Show("No find vehile.");
                return;
            }
            if (BCFUtility.isEmpty(avoid_adr))
            {
                MessageBox.Show("No find avoid address.");
                return;
            }
            (bool is_success, string result, List <string> guide_address_ids)resule = default((bool is_success, string result, List <string> guide_address_ids));
            await Task.Run(() =>
            {
                resule = scApp.VehicleService.AvoidRequest(vehicle_id, avoid_adr);
            });

            if (resule.is_success)
            {
                MessageBox.Show("Avoid success", "Avoid success.", MessageBoxButtons.OK, MessageBoxIcon.None);
            }
            else
            {
                MessageBox.Show(resule.result, "Avoid fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 private void setSpecifyAdr()
 {
     try
     {
         if (!BCFUtility.isEmpty(InObservationVh.startAdr))
         {
             uctl_Map.changeSpecifyAddressColor
                 (InObservationVh.startAdr, CLR_MAP_ADDRESS_START);
             reqSelectionStartAdr = InObservationVh.startAdr;
         }
         if (!BCFUtility.isEmpty(InObservationVh.FromAdr))
         {
             uctl_Map.changeSpecifyAddressColor
                 (InObservationVh.FromAdr, CLR_MAP_ADDRESS_FROM);
             reqSelectionFromAdr = InObservationVh.FromAdr;
         }
         if (!BCFUtility.isEmpty(InObservationVh.ToAdr))
         {
             uctl_Map.changeSpecifyAddressColor
                 (InObservationVh.ToAdr, CLR_MAP_ADDRESS_TO);
             reqSelectionToAdr = InObservationVh.ToAdr;
         }
     }
     catch (Exception ex)
     {
         logger.Error(ex, "Exception");
     }
 }
        private async void excuteMoveCommand(E_CMD_TYPE cmd_type)
        {
            string toAdr     = string.Empty;
            string vehicleId = string.Empty;

            vehicleId = cmb_Vehicle.Text;
            toAdr     = cmb_toAddress.Text;
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }

            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, string.Empty,
                                                    cmd_type,
                                                    string.Empty,
                                                    toAdr, 0, 0);
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //bcf.App.BCFApplication.onWarningMsg(this, new LogEventArgs("Command create fail.", check_result_info.Num));
            }
        }
        private void tmrRefresh_Tick(object sender, EventArgs e)
        {
            change_flag = !change_flag;
            if (!BCFUtility.isEmpty(current_SelectSegment))
            {
                List <GroupRails> lstGroupRails = m_DicSegmentGroupRails[current_SelectSegment];
                foreach (GroupRails groupRails in lstGroupRails)
                {
                    groupRails.GroupColorChange(change_flag ? RailOriginalColor : Color.Yellow);
                }
            }

            if (current_FlashingSectionGroup != null &&
                current_FlashingSectionGroup.Count() > 0)
            {
                foreach (string[] section_ids in current_FlashingSectionGroup)
                {
                    foreach (string section_id in section_ids)
                    {
                        m_DicSectionGroupRails[section_id]
                        .GroupColorChange(change_flag ? RailOriginalColor : Color.Yellow);
                    }
                }
            }
        }
 public void resetRailColor(string SelectSegment)
 {
     if (!BCFUtility.isEmpty(SelectSegment))
     {
         foreach (GroupRails groupRails in m_DicSegmentGroupRails[SelectSegment.Trim()])
         {
             groupRails.GroupColorChange(RailOriginalColor);
         }
     }
 }
        private async void excuteScanCommand()
        {
            //string fromAdr = string.Empty;
            string vehicleId         = string.Empty;
            string hostsource_portid = cmb_fromAddress.Text;
            string hostdest_portid   = cmb_toAddress.Text;
            string from_adr          = string.Empty;
            string to_adr            = string.Empty;

            string    cmd_id  = string.Empty;
            string    cst_id  = txt_cstID.Text;
            string    box_id  = "box_id";
            string    lot_id  = "lot_id";
            E_VH_TYPE vh_type = E_VH_TYPE.None;

            vehicleId = SCUtility.Trim(cmb_Vehicle.Text, true);
            scApp.PortDefBLL.getAddressID(hostsource_portid, out from_adr, out vh_type);

            cmd_id = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }
            if (BCFUtility.isEmpty(cst_id))
            {
                MessageBox.Show("cst id can't empty.");
                return;
            }
            AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId);

            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                //if (SCUtility.isMatche(vh.CUR_ADR_ID, fromAdr))
                //{
                //    scApp.VehicleService.TransferRequset(vehicleId, cmd_id, ActiveType.Scan, "CST02", new string[0], new string[0], fromAdr, "");
                //}
                //else
                {
                    //scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, "CST06",
                    scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.Scan,
                                                        hostsource_portid, "", 0, 0,
                                                        box_id, lot_id, from_adr);
                    check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                            (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                }
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
 private void resetSpecifyAdr()
 {
     if (!BCFUtility.isEmpty(reqSelectionStartAdr))
     {
     }
     if (!BCFUtility.isEmpty(reqSelectionFromAdr))
     {
     }
     if (!BCFUtility.isEmpty(reqSelectionToAdr))
     {
     }
 }
 private void setSpecifyAdr()
 {
     if (!BCFUtility.isEmpty(InObservationVh.startAdr))
     {
     }
     if (!BCFUtility.isEmpty(InObservationVh.FromAdr))
     {
     }
     if (!BCFUtility.isEmpty(InObservationVh.ToAdr))
     {
     }
 }
        private async void excuteLoadUnloadCommand()
        {
            string   fromSection = cmb_fromSection.Text;
            ASECTION asection    = scApp.MapBLL.getSectiontByID(fromSection);

            string    hostsource = cmb_fromAddress.Text;
            string    hostdest   = cmb_toAddress.Text;
            string    from_adr   = string.Empty;
            string    to_adr     = string.Empty;
            string    cst_id     = txt_cst_id.Text;
            E_VH_TYPE vh_type    = E_VH_TYPE.None;

            scApp.MapBLL.getAddressID(hostsource, out from_adr, out vh_type);
            scApp.MapBLL.getAddressID(hostdest, out to_adr);
            string vehicleId = string.Empty;

            if (BCFUtility.isEmpty(cmb_Vehicle.Text))
            {
                //AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhByFromAdr(fromadr);
                AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhStepByStepFromAdr_New(from_adr, vh_type);
                if (firstVh != null)
                {
                    vehicleId = firstVh.VEHICLE_ID.Trim();
                }
            }
            else
            {
                vehicleId = cmb_Vehicle.Text;
            }

            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find idle vehile.");
                return;
            }
            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id,
                                                    E_CMD_TYPE.LoadUnload,
                                                    from_adr,
                                                    to_adr, 0, 0);
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                // bcf.App.BCFApplication.onWarningMsg(this, new LogEventArgs("Command create fail.", check_result_info.Num));
            }
        }
 public void resetRailColor(string[] lstSec)
 {
     if (!BCFUtility.isEmpty(lstSec))
     {
         foreach (string groupRails in lstSec)
         {
             if (m_DicSectionGroupRails.ContainsKey(groupRails))
             {
                 m_DicSectionGroupRails[groupRails].GroupColorChange(RailOriginalColor);
             }
         }
     }
 }
Exemplo n.º 12
0
 private com.mirle.ibg3k0.sc.ConfigHandler.ProcessDataConfigHandler procDataConfigHandler; //A0.11
 public com.mirle.ibg3k0.sc.ConfigHandler.ProcessDataConfigHandler getProcessDataConfigHandler()
 {
     if (BCFUtility.isEmpty(Process_Data_Format))
     {
         return(null);
     }
     if (procDataConfigHandler == null)
     {
         procDataConfigHandler =
             new com.mirle.ibg3k0.sc.ConfigHandler.ProcessDataConfigHandler(Process_Data_Format);
     }
     return(procDataConfigHandler);
 }
        public void setMonitorVehicle(string vh_id)
        {
            lock (predictPathHandler)
            {
                if (InObservationVh != null)
                {
                    InObservationVh.removeEventHandler(predictPathHandler);
                }

                resetSpecifyRail();
                resetSpecifyAdr();
                if (!BCFUtility.isEmpty(vh_id))
                {
                    InObservationVh = scApp.getEQObjCacheManager().getVehicletByVHID(vh_id);

                    changePredictPathByInObservation();

                    InObservationVh.addEventHandler(predictPathHandler
                                                    , BCFUtility.getPropertyName(() => InObservationVh.VhExcuteCMDStatusChangeEvent)
                                                    , (s1, e1) => { changePredictPathByInObservation(); });
                    InObservationVh.addEventHandler(predictPathHandler
                                                    , BCFUtility.getPropertyName(() => InObservationVh.VhStatusChangeEvent)
                                                    , (s1, e1) => { changePredictPathByInObservation(); });

                    cmb_Vehicle.Text = vh_id;
                    VehicleObjToShow veicleObjShow = scApp.getEQObjCacheManager().CommonInfo.ObjectToShow_list.Where(o => o.VEHICLE_ID == vh_id).FirstOrDefault();
                    if (veicleObjShow != null)
                    {
                        int selectIndex = scApp.getEQObjCacheManager().CommonInfo.ObjectToShow_list.IndexOf(veicleObjShow);
                        if (selectIndex >= 0)
                        {
                            if ((dgv_vhStatus.SelectedRows.Count > 0 && dgv_vhStatus.SelectedRows[0].Index != selectIndex) ||
                                dgv_vhStatus.SelectedRows.Count == 0)
                            {
                                dgv_vhStatus.Rows[selectIndex].Selected      = true;
                                dgv_vhStatus.FirstDisplayedScrollingRowIndex = selectIndex;
                            }
                        }
                    }
                }
                else
                {
                    if (dgv_vhStatus.SelectedRows.Count > 0)
                    {
                        dgv_vhStatus.SelectedRows[0].Selected = false;
                    }
                    cmb_Vehicle.Text = string.Empty;
                }
            }
        }
        private async void excuteLoadUnloadCommand()
        {
            string   fromSection = cmb_fromSection.Text;
            ASECTION asection    = scApp.MapBLL.getSectiontByID(fromSection);

            string    hostsource_portid = cmb_fromAddress.Text;
            string    hostdest_portid   = cmb_toAddress.Text;
            string    from_adr          = string.Empty;
            string    to_adr            = string.Empty;
            E_VH_TYPE vh_type           = E_VH_TYPE.None;

            scApp.PortDefBLL.getAddressID(hostsource_portid, out from_adr, out vh_type);
            scApp.PortDefBLL.getAddressID(hostdest_portid, out to_adr);
            string vehicleId = string.Empty;

            vehicleId = SCUtility.Trim(cmb_Vehicle.Text, true);

            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find idle vehile.");
                return;
            }

            string cst_id = txt_cstID.Text;
            string box_id = txt_boxID.Text;
            string lot_id = "lot_id";

            if (BCFUtility.isEmpty(box_id))
            {
                MessageBox.Show(" 'BOX ID' must not be empty.");
                return;
            }

            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id, E_CMD_TYPE.LoadUnload,
                                                    hostsource_portid, hostdest_portid, 0, 0,
                                                    box_id, lot_id, from_adr, to_adr);
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private (bool isSuccess, string result) excuteCommandNew(E_CMD_TYPE cmdType, string fromAddess, string toAddress, string cstID, string vhID)
        {
            try
            {
                Console.WriteLine(Thread.CurrentThread.ManagedThreadId.ToString());
                var    source_info = getAdrPortID(fromAddess);
                var    dest_info   = getAdrPortID(toAddress);
                string cst_id      = cstID;
                string vehicleId   = vhID;
                if (BCFUtility.isEmpty(vehicleId))
                {
                    return(false, "No find idle vehile.");
                }
                switch (cmdType)
                {
                case E_CMD_TYPE.Move: scApp.VehicleService.Command.Move(vehicleId, dest_info.adrID); break;

                //case E_CMD_TYPE.Move_Charger: scApp.VehicleService.Command.MoveToCharge(vehicleId, dest_info.adrID); break;
                case E_CMD_TYPE.Move_Charger: scApp.VehicleChargerModule.askVhToChargerForWaitByManual(vehicleId); break;

                case E_CMD_TYPE.LoadUnload: scApp.VehicleService.Command.Loadunload(vehicleId, cst_id, source_info.adrID, dest_info.adrID, source_info.portID, dest_info.portID); break;

                case E_CMD_TYPE.Load: scApp.VehicleService.Command.Load(vehicleId, cst_id, source_info.adrID, source_info.portID); break;

                case E_CMD_TYPE.Unload: scApp.VehicleService.Command.Unload(vehicleId, cst_id, dest_info.adrID, dest_info.portID); break;

                case E_CMD_TYPE.Home:
                    string cmdID = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
                    scApp.VehicleService.Send.CommandHome(vehicleId, cmdID);
                    break;
                }
                sc.BLL.CMDBLL.CommandCheckResult check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.CommandCheckResult>
                                                                         (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                if (check_result_info == null)
                {
                    return(false, "");
                }
                else
                {
                    return(check_result_info.IsSuccess, check_result_info.ToString());
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
                return(false, "Exception happend");
            }
        }
        private void excuteMTLHomeCommand()
        {
            string toAdr     = string.Empty;
            string vehicleId = string.Empty;

            vehicleId = cmb_Vehicle.Text;
            toAdr     = cmb_toAddress.Text;
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }

            AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId);

            Task.Run(() =>
                     scApp.VehicleService.TransferRequset(vehicleId, scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual), ActiveType.Mtlhome, "", new string[0], new string[0], new string[0], new string[0], new string[0], new string[0], "", ""));
            //vh.sned_Str31(scApp.SequenceBLL.getCommandID_Manual(), ActiveType.Home, "", new string[0], new string[0], "", ""));
        }
Exemplo n.º 17
0
        private async void excuteUnloadCommand()
        {
            string toAdr     = string.Empty;
            string vehicleId = string.Empty;
            string cmd_id    = string.Empty;
            string cst_id    = string.Empty;

            vehicleId = cmb_Vehicle.Text;
            toAdr     = cmb_toAddress.Text;
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }
            AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId);

            cmd_id = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
            //cst_id = SCUtility.Trim(vh.CST_ID, true);
            cst_id = SCUtility.Trim(txt_cstID.Text, true);

            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;

            await Task.Run(() =>
            {
                //if (SCUtility.isMatche(vh.CUR_ADR_ID, toAdr))
                //{
                //    scApp.VehicleService.TransferRequset(vehicleId, cmd_id, ActiveType.Unload, cst_id, new string[0], new string[0], "", toAdr);
                //}
                //else
                {
                    scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id,
                                                        E_CMD_TYPE.Unload,
                                                        string.Empty,
                                                        toAdr, 0, 0);
                    check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                            (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
                }
                if (check_result_info != null && !check_result_info.IsSuccess)
                {
                    MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                }
            });
        }
        private async void excuteLoadCommand()
        {
            string fromAdr   = string.Empty;
            string vehicleId = string.Empty;
            string cmd_id    = string.Empty;
            string cst_id    = txt_cst_id.Text;

            vehicleId = cmb_Vehicle.Text;
            fromAdr   = cmb_fromAddress.Text;
            cmd_id    = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }
            AVEHICLE vh = scApp.getEQObjCacheManager().getVehicletByVHID(vehicleId);

            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                //if (SCUtility.isMatche(vh.CUR_ADR_ID, fromAdr))
                //{
                //    scApp.VehicleService.TransferRequset(vehicleId, cmd_id, ActiveType.Load, "CA0070", new string[0], new string[0], new string[0], new string[0], new string[0], new string[0], fromAdr, "");
                //}
                //else
                {
                    scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id,
                                                        E_CMD_TYPE.Load,
                                                        fromAdr,
                                                        string.Empty, 0, 0);
                }
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            }
                           );

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //bcf.App.BCFApplication.onWarningMsg(this, new LogEventArgs("Command create fail.", check_result_info.Num));
            }
        }
 private void setSpecifyAdr()
 {
     if (!BCFUtility.isEmpty(InObservationVh.startAdr))
     {
         uctl_Map.changeSpecifyAddressColor
             (InObservationVh.startAdr, BCAppConstants.CLR_MAP_ADDRESS_START);
         reqSelectionStartAdr = InObservationVh.startAdr;
     }
     if (!BCFUtility.isEmpty(InObservationVh.FromAdr))
     {
         uctl_Map.changeSpecifyAddressColor
             (InObservationVh.FromAdr, BCAppConstants.CLR_MAP_ADDRESS_FROM);
         reqSelectionFromAdr = InObservationVh.FromAdr;
     }
     if (!BCFUtility.isEmpty(InObservationVh.ToAdr))
     {
         uctl_Map.changeSpecifyAddressColor
             (InObservationVh.ToAdr, BCAppConstants.CLR_MAP_ADDRESS_TO);
         reqSelectionToAdr = InObservationVh.ToAdr;
     }
 }
 private void resetSpecifyAdr()
 {
     if (!BCFUtility.isEmpty(reqSelectionStartAdr))
     {
         uctl_Map.changeSpecifyAddressColor
             (reqSelectionStartAdr, BCAppConstants.CLR_MAP_ADDRESS_DUFAULT);
         reqSelectionStartAdr = string.Empty;
     }
     if (!BCFUtility.isEmpty(reqSelectionFromAdr))
     {
         uctl_Map.changeSpecifyAddressColor
             (reqSelectionFromAdr, BCAppConstants.CLR_MAP_ADDRESS_DUFAULT);
         reqSelectionFromAdr = string.Empty;
     }
     if (!BCFUtility.isEmpty(reqSelectionToAdr))
     {
         uctl_Map.changeSpecifyAddressColor
             (reqSelectionToAdr, BCAppConstants.CLR_MAP_ADDRESS_DUFAULT);
         reqSelectionToAdr = string.Empty;
     }
 }
        public void setMonitorVehicle(object obj, string vh_id)
        {
            try
            {
                lock (predictPathHandler)
                {
                    if (InObservationVh != null)
                    {
                        InObservationVh.removeEventHandler(predictPathHandler);
                    }

                    resetSpecifyRail();
                    resetSpecifyAdr();
                    if (!BCFUtility.isEmpty(vh_id))
                    {
                        InObservationVh = app.ObjCacheManager.GetVEHICLE(vh_id);

                        changePredictPathByInObservation();

                        InObservationVh.addEventHandler(predictPathHandler
                                                        , BCFUtility.getPropertyName(() => InObservationVh.VhExcuteCMDStatusChangeEvent)
                                                        , (s1, e1) => { changePredictPathByInObservation(); });
                        InObservationVh.addEventHandler(predictPathHandler
                                                        , BCFUtility.getPropertyName(() => InObservationVh.VhStatusChangeEvent)
                                                        , (s1, e1) => { changePredictPathByInObservation(); });

                        IndicateVhInfoFromDgv(vh_id);
                    }
                    //else
                    //{
                    //    if (dgv_vehilce_status.SelectedRows.Count > 0)
                    //        dgv_vehilce_status.SelectedRows[0].Selected = false;
                    //}
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Exception");
            }
        }
        private async void excuteMoveCommand(E_CMD_TYPE cmd_type)
        {
            string toAdr     = string.Empty;
            string vehicleId = string.Empty;

            vehicleId = cmb_Vehicle.Text;
            toAdr     = cmb_toAddress.Text;
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }

            //scApp.CMDBLL.creatCommand_OHTC(vehicleId, string.Empty, string.Empty,
            //                                E_CMD_TYPE.Move,
            //                                string.Empty,
            //                                toAdr, 0, 0);
            //Task.Run(() => { scApp.CMDBLL.generateCmd_OHTC_Details(); });
            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            string box_id = "";
            string lot_id = "";
            await Task.Run(() =>
            {
                string from_adr = string.Empty;
                scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, string.Empty,
                                                    cmd_type,
                                                    string.Empty,
                                                    toAdr, 0, 0,
                                                    box_id, lot_id, from_adr, toAdr);
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
        private Task excuteCommand(E_CMD_TYPE cmdType)
        {
            var    source_info = getAdrPortID(cmb_fromAddress.Text);
            var    dest_info   = getAdrPortID(cmb_toAddress.Text);
            string cst_id      = txt_cst_id.Text;
            string vehicleId   = cmb_Vehicle.Text;

            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find idle vehile.");
                return(Task.CompletedTask);
            }
            switch (cmdType)
            {
            case E_CMD_TYPE.Move: scApp.VehicleService.Command.Move(vehicleId, dest_info.adrID); break;

            //case E_CMD_TYPE.Move_Charger: scApp.VehicleService.Command.MoveToCharge(vehicleId, dest_info.adrID); break;
            case E_CMD_TYPE.Move_Charger: scApp.VehicleChargerModule.askVhToChargerForWaitByManual(vehicleId); break;

            case E_CMD_TYPE.LoadUnload: scApp.VehicleService.Command.Loadunload(vehicleId, cst_id, source_info.adrID, dest_info.adrID, source_info.portID, dest_info.portID); break;

            case E_CMD_TYPE.Load: scApp.VehicleService.Command.Load(vehicleId, cst_id, source_info.adrID, source_info.portID); break;

            case E_CMD_TYPE.Unload: scApp.VehicleService.Command.Unload(vehicleId, cst_id, dest_info.adrID, dest_info.portID); break;

            case E_CMD_TYPE.Home:
                string cmdID = scApp.SequenceBLL.getCommandID(SCAppConstants.GenOHxCCommandType.Manual);
                scApp.VehicleService.Send.CommandHome(vehicleId, cmdID);
                break;
            }
            sc.BLL.CMDBLL.CommandCheckResult check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.CommandCheckResult>
                                                                     (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            return(Task.CompletedTask);
        }
Exemplo n.º 24
0
        private void excuteMoveCommandAllVh()
        {
            //string toAdr = string.Empty;
            List <AVEHICLE> lstVh = scApp.VehicleBLL.cache.loadVhs();

            foreach (AVEHICLE vh in lstVh)
            {
                if (SCUtility.isEmpty(vh.CUR_ADR_ID) || SCUtility.isEmpty(vh.CUR_SEC_ID))
                {
                    continue;
                }

                ASECTION sec = scApp.MapBLL.getSectiontByID(vh.CUR_SEC_ID);

                string   vehicleId    = vh.VEHICLE_ID.Trim();
                string   toAdr        = sec.TO_ADR_ID;
                string[] nextSections = scApp.MapBLL.loadNextSectionIDBySectionID(vh.CUR_SEC_ID);
                ASECTION nextSection  = null;
                if (nextSections != null && nextSections.Count() > 0)
                {
                    nextSection = scApp.MapBLL.getSectiontByID(nextSections[0]);
                }

                if (BCFUtility.isEmpty(vehicleId))
                {
                    MessageBox.Show("No find vehile.");
                    return;
                }
                Task.Run(() =>
                         scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, string.Empty,
                                                             E_CMD_TYPE.Move,
                                                             string.Empty,
                                                             nextSection.TO_ADR_ID, 0, 0));
                SpinWait.SpinUntil(() => false, 1000);
            }
        }
        private void excuteCycleRunCommand()
        {
            string toAdr     = string.Empty;
            string vehicleId = string.Empty;

            vehicleId = cmb_Vehicle.Text;
            toAdr     = cmb_cycRunZone.Text;
            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find vehile.");
                return;
            }

            //scApp.CMDBLL.creatCommand_OHTC(vehicleId, string.Empty, string.Empty,
            //                                E_CMD_TYPE.Round,
            //                                string.Empty,
            //                                toAdr, 0, 0);
            //Task.Run(() => { scApp.CMDBLL.generateCmd_OHTC_Details(); });
            Task.Run(() =>
                     scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, string.Empty,
                                                         E_CMD_TYPE.Round,
                                                         string.Empty,
                                                         toAdr, 0, 0));
        }
        static void Main(string[] args)
        {
            using (Mutex m = new Mutex(false, "Global\\" + appGuid))
            {
                //MessageBox.Show("Test 1.0.0.2");
                SCUtility.SystemEventLog("Start BC System!!", EventLogEntryType.Information);
                //檢查是否同名Mutex已存在(表示另一份程式正在執行)
                //if (!m.WaitOne(0, false))
                //{
                //    Console.WriteLine("Only one instance is allowed!");
                //    SCUtility.SystemEventLog("Can Not Execute Multiple BC System!!", EventLogEntryType.Warning);
                //    var confirmResult = MessageBox.Show("Can Not Execute Multiple BC System!!",
                //            "Confirm Exit BC System!!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}
                //////檢查是否有重複開啟BC System
                //System.Diagnostics.Process crProcess = System.Diagnostics.Process.GetCurrentProcess();
                //System.Diagnostics.Process[] myProcess = System.Diagnostics.Process.GetProcessesByName(crProcess.ProcessName);
                //if (myProcess.Length > 1)
                //{
                //    SCUtility.SystemEventLog("Can Not Execute Multiple BC System!!", EventLogEntryType.Warning);
                //    var confirmResult = MessageBox.Show("Can Not Execute Multiple BC System!",
                //            "Confirm Exit BC System!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                //    return;
                //}

                string bcName = Environment.GetEnvironmentVariable("BCNAME");
                //Console.WriteLine("BCNAME:{0}", bcName);

                string argStr = SCUtility.stringListToString(" ", args.ToList());
                if (BCFUtility.isEmpty(argStr))
                {
                    bcName = "OHS100";
                    args   = new string[] { bcName };
                    argStr = bcName;
                }
                else
                {
                    bcName = args[0];
                }

                copyConfig(bcName);
                ConfigSystem.Install();

                //var wi = WindowsIdentity.GetCurrent();
                //var wp = new WindowsPrincipal(wi);
                //bool runAsAdmin = wp.IsInRole(WindowsBuiltInRole.Administrator);
                //if (!runAsAdmin)
                //{
                //    Console.WriteLine("Try Change Run As Admin.");
                //    MessageBox.Show("Try Change Run As Admin.");
                //    var processInfo = new ProcessStartInfo(Assembly.GetExecutingAssembly().CodeBase);
                //    processInfo.UseShellExecute = true;
                //    processInfo.Verb = "runas";


                //    processInfo.Arguments = argStr;
                //    // Start the new process
                //    try
                //    {
                //        Process.Start(processInfo);
                //    }
                //    catch (Exception)
                //    {
                //        Console.WriteLine("Sorry, can't to start " +
                //           "this program with administrator rights!");
                //        MessageBox.Show("Sorry, can't to start " +
                //           "this application with administrator rights!");
                //    }
                //    return;
                //}
                AppDomain currentDomain = AppDomain.CurrentDomain;                                     //A0.12
                currentDomain.UnhandledException     += new UnhandledExceptionEventHandler(MyHandler); //A0.12
                Application.ThreadException          += Application_ThreadException;
                Thread.CurrentThread.CurrentUICulture = Properties.Settings.Default.UICulture;
                //Localization.BuildMultiLanguageResources();
                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new BCMainForm(args[0], args[1]));
                SCUtility.SystemEventLog("Close BC System!!", EventLogEntryType.Information);
                Application.ExitThread();
                //crProcess.Kill();
            }
        }
Exemplo n.º 27
0
        private async void excuteLoadUnloadCommand()
        {
            string   fromSection = cmb_fromSection.Text;
            ASECTION asection    = scApp.MapBLL.getSectiontByID(fromSection);

            string    hostsource = cmb_fromAddress.Text;
            string    hostdest   = cmb_toAddress.Text;
            string    from_adr   = string.Empty;
            string    to_adr     = string.Empty;
            E_VH_TYPE vh_type    = E_VH_TYPE.None;

            scApp.MapBLL.getAddressID(hostsource, out from_adr, out vh_type);
            scApp.MapBLL.getAddressID(hostdest, out to_adr);
            string vehicleId = string.Empty;

            //if (BCFUtility.isEmpty(cmb_Vehicle.Text))
            //{
            //    //AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhByFromAdr(fromadr);
            //    AVEHICLE firstVh = scApp.VehicleBLL.findBestSuitableVhStepByStepFromAdr(from_adr, vh_type);
            //    if (firstVh != null)
            //        vehicleId = firstVh.VEHICLE_ID.Trim();
            //}
            //else
            //{
            //    vehicleId = cmb_Vehicle.Text;
            //}

            vehicleId = cmb_Vehicle.Text;

            if (BCFUtility.isEmpty(vehicleId))
            {
                MessageBox.Show("No find idle vehile.");
                return;
            }
            //string cst_id = $"{from_adr}To{to_adr}";
            string cst_id = txt_cstID.Text;

            if (BCFUtility.isEmpty(cst_id))
            {
                MessageBox.Show("cst id can't empty.");
                return;
            }
            //scApp.CMDBLL.creatCommand_OHTC(vehicleId, string.Empty, string.Empty,
            //                                E_CMD_TYPE.LoadUnload,
            //                                cmb_fromAddress.Text,
            //                                cmb_toAddress.Text, 0, 0);
            //Task.Run(() => { scApp.CMDBLL.generateCmd_OHTC_Details(); });
            //string from_adr = cmb_fromAddress.Text;
            //string to_adr = cmb_toAddress.Text;
            sc.BLL.CMDBLL.OHTCCommandCheckResult check_result_info = null;
            await Task.Run(() =>
            {
                scApp.CMDBLL.doCreatTransferCommand(vehicleId, string.Empty, cst_id,
                                                    E_CMD_TYPE.LoadUnload,
                                                    from_adr,
                                                    to_adr, 0, 0);
                check_result_info = sc.BLL.CMDBLL.getCallContext <sc.BLL.CMDBLL.OHTCCommandCheckResult>
                                        (sc.BLL.CMDBLL.CALL_CONTEXT_KEY_WORD_OHTC_CMD_CHECK_RESULT);
            });

            if (check_result_info != null && !check_result_info.IsSuccess)
            {
                MessageBox.Show(check_result_info.ToString(), "Command create fail.", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }