private bool BidingGroupRailsAndAddress()
        {
            bool          bRet        = false;
            List <string> secIDs      = mainForm.BCApp.SCApplication.MapBLL.loadAllSectionID();
            uctlAddress   addressTemp = null;

            foreach (string sec_id in secIDs)
            {
                ASECTION section = mainForm.BCApp.SCApplication.MapBLL.getSectiontByID(sec_id);
                if (section == null)
                {
                    continue;
                }
                addressTemp = m_objItemAddr.Where(a => a.p_Address.Trim() == section.FROM_ADR_ID.Trim()).FirstOrDefault();
                if (addressTemp != null)
                {
                    m_DicSectionGroupRails[section.SEC_ID.Trim()].p_Points[0].BindingAddress(addressTemp, false);
                }
                addressTemp = m_objItemAddr.Where(a => a.p_Address.Trim() == section.TO_ADR_ID.Trim()).FirstOrDefault();
                if (addressTemp != null)
                {
                    m_DicSectionGroupRails[section.SEC_ID.Trim()].p_Points[1].BindingAddress(addressTemp, true);
                }
            }
            return(bRet);
        }
 public void UnBindAddress()
 {
     if (BindAddress != null)
     {
         BindAddress = null;
     }
 }
Beispiel #3
0
        private bool readAddressPortDatas()
        {
            bool bRet       = false;
            int  iAddrCount = 0;

            try
            {
                IEnumerable <AADDRESS> enumerAdr = mainForm.BCApp.SCApplication.MapBLL.loadAllAddress();

                iAddrCount = enumerAdr.Count();

                int index = 0;
                m_objItemAddr = new uctlAddress[iAddrCount];
                foreach (AADDRESS adr in enumerAdr)
                {
                    m_objItemAddr[index]           = new uctlAddress(this);
                    m_objItemAddr[index].p_AddrPt  = index;
                    m_objItemAddr[index].p_Address = adr.ADR_ID.Trim();
                    var port_obj = mainForm.BCApp.SCApplication.PortStationBLL.OperateCatch.getPortStationByID(adr.ADR_ID.Trim());
                    if (port_obj != null)
                    {
                        m_objItemAddr[index].p_Port = port_obj.PORT_ID.Trim();
                    }
                    APOINT point = mainForm.BCApp.SCApplication.MapBLL.getPointByID(adr.ADR_ID);
                    if (point != null)
                    {
                        m_objItemAddr[index].str_Map_Add_Info = point;
                        m_objItemAddr[index].p_LayoutPoint    = 0;
                        m_objItemAddr[index].p_Text           = string.Empty;
                        m_objItemAddr[index].p_PointType      = point.POINTTYPE;
                        m_objItemAddr[index].p_LocX           = point.LOCATIONX;
                        m_objItemAddr[index].p_LocY           = point.LOCATIONY;
                        m_objItemAddr[index].p_SizeW          = (int)point.WIDTH;
                        m_objItemAddr[index].p_SizeH          = (int)point.HEIGHT;
                        m_objItemAddr[index].p_Color          = BCUtility.ConvStr2Color(point.COLOR);
                        m_objItemAddr[index].p_ZoomLV         = adr.ZOOM_LV;
                        m_objItemAddr[index].Visible          = adr.ZOOM_LV >= trackBar_scale.Value;
                        m_objItemAddr[index].Tag = m_objItemAddr[index].Top + "|" + m_objItemAddr[index].Left + "|"
                                                   + m_objItemAddr[index].Height + "|" + m_objItemAddr[index].Width;
                    }
                    index++;
                }

                if (iAddrCount > 0)
                {
                    this.pnl_Map.Controls.AddRange(m_objItemAddr);
                }

                bRet = true;
            }
            catch (Exception ex)
            {
                bRet = false;
                logger.Error(ex, "Exception");
            }
            return(bRet);
        }
        public void changeSpecifyAddressColor(string adr_id, Color change_color)
        {
            if (SCUtility.isEmpty(adr_id))
            {
                return;
            }
            uctlAddress uctAdr = m_objItemAddr.
                                 Where(adr_obj => adr_obj.p_Address == adr_id.Trim()).
                                 SingleOrDefault();

            if (uctAdr != null)
            {
                uctAdr.p_Color = change_color;
            }
        }
        public void BindingAddress(uctlAddress _addressObj, bool isLast)
        {
            BindAddressID = _addressObj.p_Address;


            if (isLast)
            {
                BindAddress        = _addressObj;
                BindAddress.p_LocX = (int)RealPointf.X;
                BindAddress.p_LocY = (int)RealPointf.Y;
                //ToDo CTLIF.g_objMapIf.p_AddressLayout[BindAddress.p_LayoutPoint] = BindAddress.str_Map_Add_Info;
            }
            else
            {
                _addressObj.p_sectionID = rail.p_SectionID;
            }
        }
Beispiel #6
0
        private void moveVehiclePosition()
        {
            Adapter.Invoke((obj) =>
            {
                try
                {
                    GroupRails groupRails = Uctl_Map.getGroupRailBySecID(eqpt.CUR_SEC_ID);
                    if (groupRails != null)
                    {
                        switch (eqpt.VhRecentTranEvent)
                        {
                        case EventType.AdrPass:
                            if (p_CurrentSecID != groupRails.Section_ID)
                            {
                                if (!string.IsNullOrWhiteSpace(p_CurrentSecID))
                                {
                                    Uctl_Map.p_DicSectionGroupRails[p_CurrentSecID.Trim()].VehicleLeave(this);
                                }
                            }
                            groupRails.VehicleEnterSection(this, eqpt.CUR_ADR_ID, eqpt.ACC_SEC_DIST);
                            break;

                        case EventType.LoadArrivals:
                        //groupRails.VehicleArrivalsStartAdr(this);
                        //break;
                        case EventType.UnloadArrivals:
                        case EventType.UnloadComplete:
                        case EventType.AdrOrMoveArrivals:
                            uctlAddress uctlAdr = Uctl_Map.getuctAddressByAdrID(eqpt.CUR_ADR_ID);
                            //point = bcApp.SCApplication.MapBLL.getPointByID(eqpt.currentAddress);
                            PrcSetLocation(uctlAdr.p_LocX, uctlAdr.p_LocY);
                            //groupRails.VehicleArrivalsEndAdr(this);
                            Uctl_Map.stopFlashingSpecifyRail(eqpt.PredictPath);
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    logger.Error(ex, "Exception");
                }
            }, null);
        }
 private void updateVehiclePosition()
 {
     Adapter.Invoke((obj) =>
     {
         try
         {
             //如果車子目前是位於9開頭的Address 就把他換成用Address的座標來定位
             if (vh.CUR_ADR_ID != null && vh.CUR_ADR_ID.StartsWith("9"))
             {
                 string replaced_cur_adr = replaceFirstChar(vh.CUR_ADR_ID);
                 uctlAddress uctlAdr     = Uctl_Map.getuctAddressByAdrID(replaced_cur_adr);
                 if (uctlAdr == null)
                 {
                     return;
                 }
                 PrcSetLocation(uctlAdr.p_LocX, uctlAdr.p_LocY);
             }
             else
             {
                 GroupRails groupRails = Uctl_Map.getGroupRailBySecID(vh.CUR_SEC_ID);
                 if (groupRails != null)
                 {
                     groupRails.VehicleEnterSection(this, vh.CUR_ADR_ID, vh.ACC_SEC_DIST, vh.CurrentDriveDirction);
                 }
                 else
                 {
                     PrcSetLocation((UNKNOW_DEFAULT_X_LOCATION_VALUE * Num) + 2, UNKNOW_DEFAULT_Y_LOCATION_VALUE);
                 }
             }
         }
         catch (Exception ex)
         {
             logger.Error(ex, "Exception");
         }
     }, null);
 }
        public uctlAddress getuctAddressByAdrID(string adr_id)
        {
            uctlAddress uctl_adr = m_objItemAddr.Where(obj => obj.p_Address == adr_id).SingleOrDefault();

            return(uctl_adr);
        }