예제 #1
0
        public CRStartFile(DeviceBase dev, string floder)
        {
            device = dev;
            deviceType = (int)dev.DP.Type;
            localPortBase = deviceType * 1000;

            fileType = FileBaseType.FILE_BASE_TYPE_START;

            GenerateConfig(floder);
        }
예제 #2
0
파일: HWHardCfg.cs 프로젝트: kuki89/IP_Lab
        public HWHardCfg(DeviceBase dev, string floder, string ver)
        {
            device = dev;
            deviceType = (int)dev.DP.Type;
            localPortBase = deviceType * 1000;
            version = ver;

            fileType = FileBaseType.FILE_BASE_TYPE_CONFIG;

            GenerateConfig(floder);
        }
예제 #3
0
        public bool setDevice(DeviceBase src, DeviceBase dst)
        {
            Reset_Window();

            deviceSrc = src;
            deviceDst = dst;

            tbSrc.Text = src.DP.Name;
            tbDst.Text = dst.DP.Name;

            return Init_SlotCmd();
        }
예제 #4
0
파일: DeviceBase.cs 프로젝트: kuki89/IP_Lab
        /// <summary>
        /// 添加连接,之所以使用偏移而不使用起始点,是因为在保存文件时,double会导致精度问题,从而点跑出框外
        /// </summary>
        /// <param name="pt1">起点偏移</param>
        /// <param name="pt2">终点偏移</param>
        public void AddLink(Point pt1, Point pt2,
            DeviceCard srcCard, DeviceCard dstCard, DeviceSocket srcSocket, DeviceSocket dstSocket, DeviceBase dest)
        {
            Link lnk = new Link();

            lnk.PTSrcOffset = pt1;
            lnk.PTDstOffset = pt2;

            lnk.PTSRC = new Point(
                pt1.X + (double)ImageBorder.GetValue(Canvas.LeftProperty),
                pt1.Y + (double)ImageBorder.GetValue(Canvas.TopProperty));

            lnk.PTDST = new Point(
                pt2.X + (double)dest.ImageBorder.GetValue(Canvas.LeftProperty),
                pt2.Y + (double)dest.ImageBorder.GetValue(Canvas.TopProperty));

            lnk.PaintBoard = paintBoard;

            lnk.SrcDevice = this;
            lnk.SrcCard = srcCard;
            lnk.SrcSocket = srcSocket;

            lnk.DstDevice = dest;
            lnk.DstCard = dstCard;
            lnk.DstSocket = dstSocket;

            lnk.TextSrc.Text = srcCard.toString();
            if (srcCard.ShowSocket)
                lnk.TextSrc.Text += "/" + srcSocket.toString();

            lnk.TextDst.Text = dstCard.toString();
            if (dstCard.ShowSocket)
                lnk.TextDst.Text += "/" + dstSocket.toString();

            try
            {
                if (SetDeviceSocketUsed(srcCard, srcSocket, this)
                && SetDeviceSocketUsed(dstCard, dstSocket, dest))
                {
                    linkList.Add(lnk);
                    dest.GetLinkList().Add(lnk);

                    paintBoard.Children.Add(lnk);
                    AdjustLinkPosition(lnk);

                    destination = null;
                }
            }
            catch (System.Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
예제 #5
0
파일: DeviceBase.cs 프로젝트: kuki89/IP_Lab
 private bool SetDeviceSocketUsed(DeviceCard card, DeviceSocket socket, DeviceBase device)
 {
     if (card != null && socket != null)
     {
         socket.Used = true;
         card.Socket_Used_Number++;
         return true;
     }
     else
         return false;
 }
예제 #6
0
파일: DeviceBase.cs 프로젝트: kuki89/IP_Lab
        void ImageBorder_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            Point point = e.GetPosition(paintBoard);

            if (sysData.Command == Enum.CommandType.COMMAND_TYPE_CONNECT)
            {
                LineVirtual.Visibility = Visibility.Collapsed;

                destination = sysData.IsDeviceInPosition(point);
                if (destination != null && destination != this)
                {
                    linkWindow.Title = "您将连接设备 " + DP.Name + " 和 " + destination.DP.Name;
                    if(linkWindow.setDevice(this, destination))
                        linkWindow.Show();
                }
            }

            DejectMoveEvent();
        }
예제 #7
0
파일: Link.cs 프로젝트: kuki89/IP_Lab
 /// <summary>
 /// 判断一个点位于矩形的哪条直线
 /// </summary>
 /// <param name="pt">点</param>
 /// <returns>
 ///       0
 ///    --------
 ///   |        | 
 /// 1 |        | 3
 ///   |        |
 ///    --------
 ///       2
 /// </returns>
 private int PointInLine(Point pt, DeviceBase dev)
 {
     Rect rect = dev.GetPosition();
     if (Math.Abs(pt.Y - rect.Top) < 1)
         return 0;
     else if (Math.Abs(pt.X - rect.Left) < 1)
         return 1;
     else if (Math.Abs(pt.Y - rect.Bottom) < 1)
         return 2;
     else
         return 3;
 }
예제 #8
0
파일: Link.cs 프로젝트: kuki89/IP_Lab
 private void adjustTextPositionByPoint(TextBlock txt, Point pt, DeviceBase dev)
 {
     int flag = PointInLine(pt, dev);
     switch (flag)
     {
         case 0:
             txt.SetValue(Canvas.LeftProperty, pt.X);
             txt.SetValue(Canvas.TopProperty, pt.Y - txt.ActualHeight - 10);
             break;
         case 1:
             txt.SetValue(Canvas.LeftProperty, pt.X - txt.ActualWidth - 20);
             txt.SetValue(Canvas.TopProperty, pt.Y);
             break;
         case 2:
             txt.SetValue(Canvas.LeftProperty, pt.X);
             txt.SetValue(Canvas.TopProperty, pt.Y + dev.GetTxtHeight());
             break;
         case 3:
             txt.SetValue(Canvas.LeftProperty, pt.X);
             txt.SetValue(Canvas.TopProperty, pt.Y);
             break;
     }
 }
예제 #9
0
파일: CSStartAll.cs 프로젝트: kuki89/IP_Lab
        protected void GenerateLinkData(DeviceBase dev)
        {
            foreach (Link lnk in dev.GetLinkList())
            {
                // 两种设备都是思科交换机时,无需添加iou2net的信息
                if (lnk.SrcDevice.DP.Type == lnk.DstDevice.DP.Type)
                    continue;

                string str = "";       // 配置语句
                int srcType = (int)lnk.SrcDevice.DP.Type;    // 本端设备类型
                int srcIndex = (int)lnk.SrcDevice.DP.Index;   // 本端设备序号
                int dstType = (int)lnk.DstDevice.DP.Type;   // 远端设备类型
                int dstIndex = (int)lnk.DstDevice.DP.Type;  // 远端设备序号
                int srcPort = 0;     // 本端设备端口
                int dstPort = 0;    // 远端设备端口

                srcPort = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"])
                        + (int)lnk.SrcDevice.DP.Type * 1000 + (int)lnk.SrcDevice.DP.Index * 100
                        + lnk.SrcCard.Number * 10 + lnk.SrcSocket.Number;
                dstPort = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"])
                        + (int)lnk.DstDevice.DP.Type * 1000 + (int)lnk.DstDevice.DP.Index * 100
                        + lnk.DstCard.Number * 10 + lnk.DstSocket.Number;

                string serverip = ConfigurationManager.AppSettings["NormalServerIP"];

                // 本地端口
                str = "../public/iou2net.pl -u ";
                if (lnk.SrcDevice == dev)
                {
                    if (lnk.DstCard.Card_Prefix.Contains("FXP"))
                        dstPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"])
                            - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]));

                    str += srcPort + ":" + serverip + ":" + dstPort;
                    str += " -p " + lnk.GUID + " & " + "\\n";
                }
                else
                {
                    if (lnk.SrcCard.Card_Prefix.Contains("FXP"))
                        srcPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"])
                            - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]));

                    str += dstPort + ":" + serverip + ":" + srcPort;
                    str += " -p " + lnk.GUID + " & " + "\\n";
                }
                fileContent += str + "\\nsleep 2\\n";
                startTimeOut += 4;
            }
        }
예제 #10
0
 private void mi_HostLogin(DeviceBase dev, string logintype)
 {
     var u = new Uri(dev.DP.Name + logintype + "://"
         + dev.DP.Name + logintype, UriKind.RelativeOrAbsolute);
     System.Windows.Browser.HtmlPage.Window.Navigate(u, "_blank");
 }
예제 #11
0
파일: SystemData.cs 프로젝트: kuki89/IP_Lab
 public void SetSelectedDevice(DeviceBase device)
 {
     ClearSelectedControl();
     AddSelectedControl(device);
 }
예제 #12
0
파일: SystemData.cs 프로젝트: kuki89/IP_Lab
 public void RemoveSelectedControl(DeviceBase device)
 {
     if (SelectedDeviceList.Contains(device))
     {
         SelectedDeviceList.Remove(device);
         device.Selected = false;
     }
 }
예제 #13
0
파일: SystemData.cs 프로젝트: kuki89/IP_Lab
 public void AddSelectedControl(DeviceBase device)
 {
     if (device != null && !SelectedDeviceList.Contains(device))
     {
         SelectedDeviceList.Add(device);
         device.Selected = true;
     }
 }
예제 #14
0
 public HWConfigFileMgr(DeviceBase dev, string floder)
 {
     device = dev;
     flodername = floder;
 }
예제 #15
0
파일: CRStartAll.cs 프로젝트: kuki89/IP_Lab
        protected void GenerateLinkData(DeviceBase dev)
        {
            foreach (Link lnk in dev.GetLinkList())
            {
                // 两种设备都是思科路由器时,无需添加iou2net的信息
                if (lnk.SrcDevice.DP.Type == lnk.DstDevice.DP.Type)
                    continue;

                string str = "";       // 配置语句
                int srcType = (int)lnk.SrcDevice.DP.Type;    // 本端设备类型
                int srcIndex = (int)lnk.SrcDevice.DP.Index;   // 本端设备序号
                int dstType = (int)lnk.DstDevice.DP.Type;   // 远端设备类型
                int dstIndex = (int)lnk.DstDevice.DP.Type;  // 远端设备序号

                int srcPort = 0;     // 本端设备端口
                int dstPort = 0;     // 远端设备端口

                int srcportbase = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]);
                int dstportbase = Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]);

                if (lnk.SrcCard.Card_Type == DeviceCardType.DEVICE_CARD_TYPE_SERIAL)
                {
                    srcportbase = Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]);
                    dstportbase = Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"]);
                }

                srcPort = srcportbase + (int)lnk.SrcDevice.DP.Type * 1000 + (int)lnk.SrcDevice.DP.Index * 100
                    + lnk.SrcCard.Number * 10 + lnk.SrcSocket.Number;
                dstPort = dstportbase + (int)lnk.DstDevice.DP.Type * 1000 + (int)lnk.DstDevice.DP.Index * 100
                    + lnk.DstCard.Number * 10 + lnk.DstSocket.Number;

                string serverip = ConfigurationManager.AppSettings["LocalServerIP"];

                // 本地端口
                str = "/home/lab_admin/public/CiscoIOU/iou2net.pl -u ";
                if (lnk.SrcDevice == dev)
                {
                    if (lnk.DstCard.Card_Prefix.Contains("FXP"))
                        dstPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"])
                            - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]));

                    if (lnk.DstDevice.DP.Type == DeviceType.DEVICE_TYPE_CISCOSWITCHER)
                        serverip = ConfigurationManager.AppSettings["SwitchServerIP"];

                    str += srcPort + ":" + serverip + ":" + dstPort;
                    str += " -p " + lnk.GUID + " & " + "\\n";
                }
                else
                {
                    if (lnk.SrcCard.Card_Prefix.Contains("FXP"))
                        srcPort += (Int32.Parse(ConfigurationManager.AppSettings["SerialPortBase"])
                            - Int32.Parse(ConfigurationManager.AppSettings["EthernetPortBase"]));

                    if (lnk.SrcDevice.DP.Type == DeviceType.DEVICE_TYPE_CISCOSWITCHER)
                        serverip = ConfigurationManager.AppSettings["SwitchServerIP"];
                    str += dstPort + ":" + serverip + ":" + srcPort;
                    str += " -p " + lnk.GUID + " & " + "\\n";
                }
                fileContent += str + "\\nsleep 2\\n";
                startTimeOut += 4;
            }
        }