示例#1
0
            private void DeregisterPifEvents()
            {
                if (Pif != null)
                {
                    Pif.PropertyChanged -= Server_PropertyChanged;

                    // Remove Tunnel and PIF_metrics property change listeners (CA-46103)
                    if (Pif.IsTunnelAccessPIF())
                    {
                        Tunnel tunnel = Pif.Connection.Resolve(Pif.tunnel_access_PIF_of[0]);
                        if (tunnel != null)
                        {
                            tunnel.PropertyChanged -= Pif_PropertyChanged;
                        }
                    }
                    else
                    {
                        PIF_metrics metrics = Pif.PIFMetrics();
                        if (metrics != null)
                        {
                            metrics.PropertyChanged -= Pif_PropertyChanged;
                        }
                    }
                }
            }
		protected override void OnBoundToTunnelService (Tunnel tunnel)
		{
			if(!listenForLog && tunnel != null){
				tunnel.LogEvent += WriteLine;
				listenForLog = true;
			}
		}
        public void TunnelTest()
        {
            const int    port             = 65534;
            const string listenUrl        = "http://127.0.0.1:65534/ping/";
            const string expectedResponse = "pong";

            // Create a local webserver
            using (HttpListener webserver = this.StartTestServer(listenUrl, expectedResponse))
            {
                // Create the tunnel
                Tunnel tunnel = new Tunnel(port);
                tunnel.Execute();

                // Check it is connected
                Assert.IsTrue(tunnel.IsConnected);
                Assert.IsFalse(tunnel.IsStopped);

                // Check the new host responds with the expected response.
                WebRequest request  = WebRequest.Create(string.Format("http://{0}/ping/", tunnel.TunnelHost));
                string     response = (new StreamReader(request.GetResponse().GetResponseStream())).ReadToEnd();
                Assert.AreEqual(response, expectedResponse);

                webserver.Close();
            }
        }
示例#4
0
        public static TunnelInfo GetTunnelInfo(int tunnelId)
        {
            TunnelInfo tunnelInfo = new TunnelInfo {
                //TunelInformacje
                tunnel = Tunnel.GetTunnel(tunnelId),
                //Hodowle
                cultivations = Cultivation.GetCultivationsInTunnel(tunnelId),
                //Online
                online = false,
                //Temperature
                temperature = null
            };

            try {
                tunnelInfo.online = (DateTime.Now - (DateTime)AvrDevice.GetAvrDevicesInTunnel(tunnelId)[0].last_update).TotalSeconds < 60;
                if (tunnelInfo.online)
                {
                    tunnelInfo.temperature = Measurement.GetTemperatureInTunnel(tunnelId).value;
                    tunnelInfo.isAlarm     = GetTunnelAlarmInfo(tunnelId);
                }
            } catch {
                ;
            }


            return(tunnelInfo);
        }
示例#5
0
            private void RegisterPifEvents()
            {
                if (Pif != null)
                {
                    Pif.PropertyChanged += Server_PropertyChanged;

                    // Listen for Tunnel and PIF_metrics changes which is necessary for Link Status updates (CA-46103)
                    if (Pif.IsTunnelAccessPIF())
                    {
                        Tunnel tunnel = Pif.Connection.Resolve(Pif.tunnel_access_PIF_of[0]);
                        if (tunnel != null)
                        {
                            tunnel.PropertyChanged += Pif_PropertyChanged;
                        }
                    }
                    else
                    {
                        PIF_metrics metrics = Pif.PIFMetrics();
                        if (metrics != null)
                        {
                            metrics.PropertyChanged += Pif_PropertyChanged;
                        }
                    }
                }
            }
示例#6
0
        private Dictionary <string, string> ConstructDics(Tunnel tunnel, out double hdwid)
        {
            //巷道信息赋值
            var flds = new Dictionary <string, string>
            {
                {
                    GIS_Const.FIELD_HDID,
                    tunnel.id.ToString(CultureInfo.InvariantCulture)
                }
            };
            var selobjs =
                Global.commonclss.SearchFeaturesByGeoAndText(Global.centerfdlyr, flds);

            var xh = 0;

            if (selobjs.Count > 0)
            {
                xh = Convert.ToInt16(selobjs[0].Item3[GIS_Const.FIELD_XH]) + 1;
            }
            var bid    = tunnel.bid;
            var hdname = tunnel.name;

            hdwid = tunnel.width;
            _dics.Clear();
            _dics.Add(GIS_Const.FIELD_HDID, tunnel.id.ToString(CultureInfo.InvariantCulture));
            _dics.Add(GIS_Const.FIELD_ID, "0");
            _dics.Add(GIS_Const.FIELD_BS, "1");
            _dics.Add(GIS_Const.FIELD_BID, bid);
            _dics.Add(GIS_Const.FIELD_HDNAME, hdname);
            _dics.Add(GIS_Const.FIELD_XH, (xh + 1).ToString(CultureInfo.InvariantCulture));
            return(_dics);
        }
示例#7
0
    public void GenerateTunnel()
    {
        waypoints = new List <Vector3>();

        tunnels = new Tunnel[segment];
        for (int i = 0; i < segment; i++)
        {
            GameObject tunnelObject = Instantiate(tunnelPrefab);
            Tunnel     tunnel       = tunnelObject.GetComponent <Tunnel>();
            tunnelObject.transform.SetParent(transform);
            tunnelObject.transform.localScale = Vector3.one;

            if (i == 0)
            {
                tunnelObject.transform.localPosition    = Vector3.zero;
                tunnelObject.transform.localEulerAngles = Vector3.zero;
            }
            else
            {
                tunnelObject.transform.localPosition    = tunnels[i - 1].EdgePosition;// + new Vector3(0f, 0f, tunnels[i-1].transform.localPosition.z);
                tunnelObject.transform.localEulerAngles = tunnels[i - 1].EdgeRotation;
            }

            tunnel.Generate();
            foreach (var point in tunnel.Waypoints)
            {
                waypoints.Add(point);
            }

            tunnels[i] = tunnel;
        }

        Debug.Log(waypoints.Count);
        GenerateWaypoints();
    }
示例#8
0
        private void AddTestData()
        {
            string configPath = RegistryHelper.GetString(Registry.LocalMachine, Constants.ServerRegsitryKey, "", "ConfigPath");

            var configuration = new Configuration();

            configuration.Clients.Add(new Client()
            {
                Address  = new Endpoint("127.0.0.1", 17446),
                Username = "******",
                Password = "******"
            });
            File.WriteAllText(Path.Combine(configPath, Constants.ServiceConfigFileName), JsonConvert.SerializeObject(configuration));

            var tunnels = new List <Tunnel>();
            var tunnel  = new Tunnel()
            {
                BindingProtocal      = BindingProtocal.Pv4,
                Description          = "Test tunnel #1",
                ListenPort           = 80,
                Name                 = "TestTunnel#1",
                ListenOnAllAddresses = true,
                Destination          = new Endpoint("ntdls.com", 80)
            };

            tunnels.Add(tunnel);

            File.WriteAllText(Path.Combine(configPath, Constants.TunnelConfigFileName), JsonConvert.SerializeObject(tunnels));
        }
示例#9
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        Tunnel t = (Tunnel)target;

        //DrawSettingsEditor(t.tunnel_settings, t.onSettingsChange, ref tunnel_foldout, ref tunnel_editor);

        if (t.tunnel_settings.noise_settings != null && t.tunnel_settings.chain != null)
        {
            if (curve_editors == null || curve_editors.Length != t.tunnel_settings.chain.getLength())
            {
                curve_editors  = new Editor[t.tunnel_settings.chain.getLength()];
                curve_foldouts = new bool[t.tunnel_settings.chain.getLength()];
            }

            if (curve_noise_editors == null || curve_noise_editors.Length != t.tunnel_settings.chain.getLength())
            {
                curve_noise_editors  = new Editor[t.tunnel_settings.chain.getLength()];
                curve_noise_foldouts = new bool[t.tunnel_settings.chain.getLength()];
            }


            for (int i = 0; i < t.tunnel_settings.chain.getLength(); i++)
            {
                DrawSettingsEditor(t.tunnel_settings.noise_settings[i], t.onSettingsChange, ref curve_noise_foldouts[i], ref curve_noise_editors[i]);
                DrawSettingsEditor(t.tunnel_settings.chain.getCurve(i), t.onSettingsChange, ref curve_foldouts[i], ref curve_editors[i]);
            }
        }
    }
示例#10
0
        private static float GetAngle(Tunnel tunnel, T obj)
        {
            float angle = ((float)(2 * Math.PI) / (float)tunnel.numSegments) * obj.CircularSegment;

            angle += (float)Math.PI / (float)tunnel.numSegments;
            return(angle);
        }
示例#11
0
 public void BuildGameFacilities()
 {
     Road     road     = ff.CreateRoad();
     Building building = ff.BreateBuilding();
     Tunnel   tunnel   = ff.CreateTunnel();
     Jungle   jungle   = ff.CreateJungle();
 }
 public TunnelVariableProviderTests()
 {
     TunnelExtension      = Substitute.For <ITunnelExtension>();
     BuilderConfiguration = new BuilderConfiguration();
     Message      = new Message();
     UserIdentity = new Identity("user", "msging.net");
     LazyInput    = new LazyInput(
         Message,
         UserIdentity,
         BuilderConfiguration,
         Substitute.For <IDocumentSerializer>(),
         Substitute.For <IEnvelopeSerializer>(),
         Substitute.For <IArtificialIntelligenceExtension>(),
         CancellationToken);
     Context.Input.Returns(LazyInput);
     Owner               = new Identity("owner", "msging.net");
     Originator          = new Node("originator", "msging.net", "instance");
     TunnelIdentity      = new Identity(EnvelopeId.NewId(), Take.Blip.Client.Extensions.Tunnel.TunnelExtension.TunnelAddress.Domain);
     ApplicationIdentity = new Identity("application", "msging.net");
     Message.To          = ApplicationIdentity.ToNode();
     Tunnel              = new Tunnel()
     {
         Owner       = Owner,
         Originator  = Originator,
         Destination = ApplicationIdentity
     };
 }
示例#13
0
    /// <summary>
    /// Return a vector of points that specifies the path created
    /// </summary>
    /// <returns>The tunnel points.</returns>
    private Vector2[] UpdateThenReturnNewTunnelPositions(float deltatime)
    {
        GameObject tunnel          = tunnelInBack;
        Tunnel     tunnelComponent = tunnel != null?tunnel.GetComponent <Tunnel>() : null;

        List <Vector2> leftSide  = new List <Vector2>();
        List <Vector2> rightSide = new List <Vector2>();

        // if tunnel is not null and if tunnel is still in view
        while (tunnel != null && !tunnelComponent.IsTunnelOutOfBounds())
        {
            tunnelComponent.UpdateTunnelPosition(deltatime);
            leftSide.Add(tunnelComponent.GetLeftSide());
            rightSide.Add(tunnelComponent.GetRightSide());

            tunnel          = tunnelComponent.GetTunnelInFront();
            tunnelComponent = tunnel != null?tunnel.GetComponent <Tunnel>() : null;
        }

        // create an array of vertices, we will these all together
        rightSide.Reverse();
        leftSide.AddRange(rightSide);

        return(leftSide.ToArray());
    }
        internal static void CreateTunnelNodeFacade(Tunnel tunnel)
        {
            AutoBorrowNodeFacade nodeFacade      = AutoBorrowNodeFacade.GetNodeFacade(tunnel);
            TypeVariableSet      typeVariableSet = tunnel.DfirRoot.GetTypeVariableSet();

            TypeVariableReference typeVariable;

            bool executesConditionally = tunnel.ParentStructure.DoesStructureExecuteConditionally();

            if (executesConditionally && tunnel.Direction == Direction.Output)
            {
                Terminal valueInput  = tunnel.InputTerminals.ElementAt(0),
                         valueOutput = tunnel.OutputTerminals.ElementAt(0);

                typeVariable            = typeVariableSet.CreateReferenceToNewTypeVariable();
                nodeFacade[valueOutput] = new SimpleTerminalFacade(valueOutput, typeVariable);
                nodeFacade[valueInput]  = new TunnelTerminalFacade(valueInput, nodeFacade[valueOutput]);
            }
            else
            {
                List <Constraint> constraints = new List <Constraint>();
                if (tunnel.Direction == Direction.Output)
                {
                    // TODO: for multi-diagram structures, each diagram should share a lifetime related to the entire structure
                    LifetimeGraphIdentifier parentLifetimeGraph = tunnel.InputTerminals[0].ParentDiagram.GetLifetimeGraphIdentifier();
                    constraints.Add(new OutlastsLifetimeGraphConstraint(parentLifetimeGraph));
                }
                typeVariable = typeVariableSet.CreateReferenceToNewTypeVariable(constraints);
                foreach (Terminal terminal in tunnel.Terminals)
                {
                    nodeFacade[terminal] = new SimpleTerminalFacade(terminal, typeVariable);
                }
            }
        }
示例#15
0
        /// <summary>
        /// Removes the tunnel from the server and closes all connections.
        /// </summary>
        /// <param name="tunnel">The tunnel to be removed.</param>
        /// <param name="notifyClient">if set to <c>true</c> then notify the client of the closure.</param>
        protected virtual async Task RemoveTunnelAsync(Tunnel tunnel, bool notifyClient)
        {
            var connections = Connections.Values.Where(a => a.TunnelId == tunnel.Id).ToList();

            foreach (var connection in connections)
            {
                try
                {
                    if (Connections.TryRemove(connection.Id, out var _))
                    {
                        await connection.CloseLocalAsync();
                    }
                }
                catch
                {
                    /* Intentionally ignored so that we close all connections. */
                }
            }

            await tunnel.CloseLocalAsync();

            if (notifyClient)
            {
                var message = new Message
                {
                    Type = MessageType.Notification,
                    Code = MessageCode.TunnelClosedNotification
                };

                message.Values["tunnel_id"] = tunnel.Id;

                SendNotification(message);
            }
        }
示例#16
0
 private void RemoveTunnelUnderReplacement(Tunnel tunnel)
 {
     lock ( RunningReplacements )
     {
         RunningReplacements.Remove(tunnel);
     }
 }
示例#17
0
        internal void TunnelEstablished(Tunnel tunnel)
        {
            TunnelUnderReplacement replace = null;

            ClientDestination client = FindClient(tunnel);

            if (client == null)
            {
                return;
            }

            client.TunnelEstablished(tunnel);

            lock ( RunningReplacements )
            {
                replace = RunningReplacements.Where(p => p.Value.NewTunnels.Any(t => t.Equals(tunnel))).
                          Select(p => p.Value).SingleOrDefault();
                if (replace != null)
                {
                    RunningReplacements.Remove(replace.OldTunnel);
                }
            }

            if (replace != null)
            {
                DebugUtils.LogDebug("ClientTunnelProvider: TunnelEstablished: Successfully replaced old tunnel " + replace.OldTunnel.ToString() +
                                    " with new tunnel " + tunnel.ToString());

                RemoveTunnelUnderReplacement(replace.OldTunnel);
                //client.RemoveTunnel( replace.OldTunnel );
                //TunnelMgr.RemoveTunnel( replace.OldTunnel );
                //replace.OldTunnel.Shutdown();
                return;
            }
        }
示例#18
0
    IEnumerator CameraCoroutine()
    {
        updateCameraPosition(camRefInFrontOfPlayer, true);
        transform.GetChild(0).GetComponent <Animator>().SetTrigger("FadeIn");
        yield return(new WaitForSeconds(3.5f));

        updateCameraPosition(camRefBehindPlayer, true);
        yield return(new WaitForSeconds(4.0f));

        transform.GetChild(0).GetComponent <Animator>().SetTrigger("FadeOut");
        yield return(new WaitForSeconds(1.0f));

        updateCameraPosition(camRefAboveHole, false);
        transform.GetChild(0).GetComponent <Animator>().SetTrigger("FadeIn");
        yield return(new WaitForSeconds(1.0f));

        rotateCamera = true;
        yield return(new WaitForSeconds(3.0f));

        transform.GetChild(0).GetComponent <Animator>().SetTrigger("FadeOut");
        yield return(new WaitForSeconds(3.0f));

        MainCamera.GetComponent <Cam>().ResetPosition();
        transform.GetChild(0).GetComponent <Animator>().SetTrigger("FadeIn");
        player.transform.GetComponent <Player>().enabled     = true;
        player.transform.GetComponent <Collider2D>().enabled = true;
        MovingParts.movingparts.gamePlaying = true;

        foreach (Transform Tunnel in Tunnels)
        {
            Tunnel.GetComponent <TranslateDestroy>().enabled = true;
        }
    }
示例#19
0
 public void BuildGameFacilities()
 {
     road     = abstractFactory.CreateRoad();
     building = abstractFactory.CreateBuilding();
     tunnel   = abstractFactory.CreateTunnel();
     jungle   = abstractFactory.CreateJungle();
 }
示例#20
0
        /// <summary>
        /// Creates a TunnelExit object out of a CSV file string
        /// </summary>
        private TunnelExit CreateTunnelExitObject(string tunnelExitString)
        {
            TunnelExit tunnelExit = new TunnelExit();

            try
            {
                string[] tunnelExitStringData = tunnelExitString.Split(Devider);
                CheckAndCorrectInputStringData(tunnelExitStringData);

                tunnelExit = new TunnelExit
                {
                    ID        = long.Parse(tunnelExitStringData[IDIndex]),
                    RowNum    = int.Parse(tunnelExitStringData[RowNumIndex]),
                    Name      = tunnelExitStringData[NameIndex],
                    Tunnel    = Tunnel.Parse(tunnelExitStringData[TunnelIndex]),
                    AdmArea   = tunnelExitStringData[AdmAreaIndex],
                    District  = tunnelExitStringData[DistrictIndex],
                    Latitude  = double.Parse(tunnelExitStringData[LatitudeIndex].Replace('.', ',')),
                    Longitude = double.Parse(tunnelExitStringData[LongitudeIndex].Replace('.', ',')),
                    IsDamaged = "OK"
                };
                return(tunnelExit);
            }
            catch (ArgumentNullException)
            {
                tunnelExit.IsDamaged = "Damaged";
                return(tunnelExit);
            }
            catch (Exception)
            {
                tunnelExit.IsDamaged = "Damaged";
                return(tunnelExit);
            }
        }
示例#21
0
    public void ProcessHits()
    {
        float[]      PressValues = Tunnel.GetPressValues();
        RaycastHit[] Hits;
        Hits = Physics.RaycastAll(LaserPointer.transform.position, transform.forward, 100.0f);

        GameObject Obj;
        RaycastHit Hit;

        if (Hits.Length > 0)
        {
            EventLog now = new EventLog(
                PressValues[0],
                Ballistic,
                NewController.transform.position,
                NewController.transform.rotation.eulerAngles,
                Hits[0].point,
                State
                );

            now.SetType(EventType);

            EventType = ActualTask.GetCircle().GetTarget().AddEvent(now);

            if (Contains(Hits, "Sphere", out Obj, out Hit))
            {
                HandleSphereHit();
            }
            else if (Contains(Hits, "TargetPanel", out Obj, out Hit))
            {
                HandlePanelHit();
            }
        }
    }
示例#22
0
    void OnEnable()
    {
        Index = 0;

        Config.init();
        Debug.Log("UserID: " + Config.UserId);
        Session.Initalize();

        LaserPointer = GetComponent <SteamVR_LaserPointer>();

        Rounds = 0;

        LTC = new LatinSquare(8);
        LTT = new LatinSquare(Config.TargetAmplitudes.Length * Config.TargetWidths.Length);

        Tasks = CreateTasks(LTC, LTT);

        UpdateTask();
        HideTimer();

        State = State.START;

        ShowCommand("Start");
        Tunnel.IsInitalized();
    }
示例#23
0
 private void destroyPIFs()
 {
     foreach (PIF pif in PIFs)
     {
         if (pif.IsTunnelAccessPIF)
         {
             // A tunnel access PIF is destroyed by destroying its tunnel.
             // (Actually each network will have either all tunnel access PIFs (if
             // it is a CHIN) or all regular PIFs (if it isn't), but we don't use
             // that: we do it PIF-by-PIF).
             foreach (Tunnel tunnel in Connection.ResolveAll(pif.tunnel_access_PIF_of))  // actually there will only ever be one
             {
                 Tunnel.destroy(Session, tunnel.opaque_ref);
             }
         }
         else
         {
             if (!pif.physical)
             {
                 VLAN.destroy(Session, pif.VLAN_master_of);
             }
             else
             {
                 // do we ever destroy physical pifs anyway? not sure this is something we need but here for completeness
                 PIF.forget(Session, pif.opaque_ref);
             }
         }
     }
     PIFs = null;
 }
示例#24
0
            private void InitializeMiningRun()
            {
                MyIni config = Drone.GetConfig();

                string rawValue = config.Get(Name(), "mining_site").ToString();

                if (!Vector3D.TryParse(rawValue, out MiningSite))
                {
                    throw new Exception($"Unable to parse: {rawValue} as mining site");
                }

                rawValue = config.Get(Name(), "tunnel_end").ToString();
                if (!Vector3D.TryParse(rawValue, out TunnelEnd))
                {
                    throw new Exception($"Unable to parse: {rawValue} as tunnel end");
                }

                int index;

                if (!config.Get(Name(), "index").TryGetInt32(out index))
                {
                    throw new Exception("index is missing");
                }

                Tunnel = new Tunnel(Drone, MiningSite, TunnelEnd, index, ForemanAddress);
            }
示例#25
0
        private void GenerateNodes(Tunnel tunnel, StandardDef Standard)
        {
            List <TreeNode> nodes = new List <TreeNode>();
            int             index = 0;

            foreach (Stage stage in tunnel.Stages)
            {
                TreeNode stageTreeNode = new TreeNode()
                {
                    NodeID = index++, Level = 1, Context = stage.LangStr, isExpanded = true
                };
                foreach (Category category in stage.Categories)
                {
                    TreeNode categoryTreeNode = new TreeNode()
                    {
                        NodeID = index++, Level = 2, Context = category.LangStr, isExpanded = true
                    };
                    foreach (string obj in category.objList)
                    {
                        DGObjectDef dGObject = Standard.GetDGObjectDefByCode(obj);

                        TreeNode objTreeNode = new TreeNode()
                        {
                            NodeID = index++, Level = 3, Context = dGObject.LangStr
                        };
                        categoryTreeNode.ChildNodes.Add(objTreeNode);
                    }
                    stageTreeNode.ChildNodes.Add(categoryTreeNode);
                }
                nodes.Add(stageTreeNode);
            }
            TreeNodes = nodes;
        }
示例#26
0
        private void ReplaceTunnel(Tunnel tunnel, ClientDestination client, TunnelUnderReplacement replace)
        {
            if (tunnel != replace.OldTunnel)
            {
                replace.NewTunnels.RemoveAll(t => t.Equals(tunnel));
            }

            while (replace.NewTunnels.Count < NewTunnelCreationFactor)
            {
                switch (tunnel.Config.Direction)
                {
                case TunnelConfig.TunnelDirection.Outbound:
                    var newouttunnel = CreateOutboundTunnel(client, null);
                    replace.NewTunnels.Add(newouttunnel);
                    DebugUtils.LogDebug(() => string.Format("ClientTunnelProvider: ReplaceTunnel: Started to replace {0} with {1}.",
                                                            tunnel, newouttunnel));
                    break;

                case TunnelConfig.TunnelDirection.Inbound:
                    var newintunnel = CreateInboundTunnel(client, null);
                    replace.NewTunnels.Add(newintunnel);
                    DebugUtils.LogDebug(() => string.Format("ClientTunnelProvider: ReplaceTunnel: Started to replace {0} with {1}.",
                                                            tunnel, newintunnel));
                    break;

                default:
                    throw new NotImplementedException("Only out and inbound tunnels should be reported here.");
                }
            }
        }
示例#27
0
 public TunnelControl(Tunnel model)
 {
     _tunnel = model;
     InitializeComponent();
     _tunnel = model;
     loadTunnelData();
 }
示例#28
0
        internal void TunnelTimeout(Tunnel tunnel)
        {
            ClientDestination client = FindClient(tunnel);

            if (client == null)
            {
                return;
            }

            var replace = FindReplaceRecord(tunnel);

            if (replace != null)
            {
                DebugUtils.LogDebug("ClientTunnelProvider: TunnelTimeout: Failed replacing " + replace.OldTunnel.ToString() +
                                    " with " + tunnel.ToString());

                /*
                 * if ( replace.OldTunnel.Expired )
                 * {
                 *  DebugUtils.LogDebug( "ClientTunnelProvider: TunnelTimeout: Old tunnel expired. " + replace.OldTunnel.ToString() );
                 *
                 *  client.RemovePoolTunnel( replace.OldTunnel );
                 * }*/

                ReplaceTunnel(tunnel, client, replace);
            }

            client.RemoveTunnel(tunnel);
        }
示例#29
0
        private void Run(string[] args)
        {
            try
            {
                LoadConfiguration(args);

                Log(string.Format(Strings.SERVER_TITLE, GetType().Assembly.GetName().Version.ToString(3)), ESeverity.INFO);
                Log(FrameworkVersion(), ESeverity.INFO);

                Tunnel.Configuration = Configuration;
                Tunnel.Logger        = GlobalLogger;
                Protocol.ConfigureServer(typeof(Tunnel));
                Log(Strings.SERVER_STARTED, ESeverity.INFO);
                Console.ReadLine();
                Tunnel.DisableChecking();
                Protocol.UnConfigureServer();

                UnLoadConfiguration();
            }
            catch (Exception ex)
            {
                if (GlobalLogger != null)
                {
                    Log(ex.Message, ESeverity.ERROR);
                    Log(ex.ToString(), ESeverity.DEBUG);
                }
                else
                {
                    Console.WriteLine(ex.Message);
                }
            }
        }
        public static async Task Show(Tunnel tunnel, BaseConfiguration configuration, CancellationToken cancellationToken = default)
        {
            var connectionHistory = new Stack <TunnelConnection>();
            var stringBuilder     = new StringBuilder();
            var version           = Assembly.GetExecutingAssembly().GetName().Version;
            var startTime         = DateTimeOffset.UtcNow;
            var previousWidth     = -1;

            Console.CursorVisible = false;
            Console.Clear();

            while (!cancellationToken.IsCancellationRequested)
            {
                if (previousWidth != Console.WindowWidth)
                {
                    // console resized or started, perform repaint
                    Console.Clear();
                    SetStatus(ConsoleColor.Green, $"({Resources.TunnelOnline} {version!.ToString(3)})", 0);
                    SetStatus(ConsoleColor.Blue, $"https://github.com/angelobreuer/localtunnel-client", 1);
                    previousWidth = Console.WindowWidth;
                }

                Update(tunnel, stringBuilder, connectionHistory, configuration, startTime);
                UpdateConnections(tunnel, connectionHistory, configuration);
                await Task.Delay(100, CancellationToken.None);
            }

            // update status and run last update
            Console.Clear();
            SetStatus(ConsoleColor.Red, Resources.TunnelOffline, 0);
            Update(tunnel, stringBuilder, connectionHistory, configuration, startTime);

            Console.CursorVisible = true;
        }
示例#31
0
        public override void Distribute(Tunnel tunnel)
        {
            tunnel.MessageReceived(Message, Message.CreateHeader16.HeaderAndPayload.Length);
#if LOG_ALL_TUNNEL_TRANSFER
            Logging.LogDebug($"{this}: Local dist to {tunnel}: {Message}");
#endif
        }
 public void LoadData(Tunnel tunnel)
 {
     LoadData();
     lstMineName.SelectedValue = tunnel.workingface.mining_area.horizontal.mine.id;
     lstHorizontalName.SelectedValue = tunnel.workingface.mining_area.horizontal.id;
     lstMiningAreaName.SelectedValue = tunnel.workingface.mining_area.id;
     lstWorkingFaceName.SelectedValue = tunnel.workingface.id;
     lstTunnelName.SelectedValue = tunnel.id;
 }
		public TunnelService(){
			//handler = new Handler();
			tunnel = new Tunnel();
			streamingSettings = new StreamingSettings();
			rtspServer = new RtspServer ();
			tunnelBinder = new TunnelBinder(tunnel,streamingSettings,rtspServer);
			tunnel.Started += OnTunnelStated;
			tunnel.Stopped += OnTunnelStoped;
			tunnel.ClientConnected += OnClientConnected;
			tunnel.ClientDisConnected += OnClientDisconnected;
		}
 public void SetTunnel(Tunnel tunnel)
 {
     selected_tunnel = tunnel;
     foreach (Tunnel i in from Tunnel i in cbxTunnel.Items where i.id == tunnel.id select i)
     {
         cbxTunnel.SelectedItem = i;
         return;
     }
     cbxTunnel.Items.Add(tunnel);
     cbxTunnel.SelectedItem = tunnel;
 }
示例#35
0
        protected override void ProcessRecord()
        {
            Runspace runspace = System.Management.Automation.Runspaces.Runspace.DefaultRunspace;

            for (int i = 0; i < HostAddress.Length; i++)
            {
                Binding binding = ((Binding != null) && (i < Binding.Length)) ? Binding[i] : CreateDefaultBinding();
                Tunnel tunnel = new Tunnel(runspace, binding, new EndpointAddress(HostAddress[i]));
                if (!NoSelect.IsPresent)
                    tunnel.SetAsCurrent();
                this.WriteObject(tunnel);
            }

            base.ProcessRecord();
        }
		protected override void OnCreate (Bundle bundle)
		{
			base.OnCreate (bundle);
			serviceConnection = new TunnelServiceConnection(
				delegate(TunnelService.TunnelBinder binder){//On connect
					tunnel = binder.Tunnel;
					OnBoundToTunnelService(tunnel);
					//isBound = true;
				},
				delegate(TunnelService.TunnelBinder binder){//On disconnect
					//isBound = false;
				}
			);
			ApplicationContext.BindService (new Intent (this, typeof (TunnelService)), serviceConnection, Bind.AutoCreate);
		}
		protected void OnClientDisconnected(Tunnel.Client client){
			RunOnUiThread(delegate() {
			SetDisableLight(connectLight);
				connectText.Text = "Client is not connected";
				if(tunnel.IsRunning)
					EnableButton(connectButton);
				else
					DisableButton(connectButton);
			});
		}
		public void OnClientDisconnected(Tunnel.Client client){
			client.TunnelCommandReceived -= OnTunnelCommand;
		}
		public void OnClientConnected(Tunnel.Client client){
			client.TunnelCommandReceived += OnTunnelCommand;
			clientIpAddress = client.Address;
			Console.WriteLine(clientIpAddress);
		}
示例#40
0
    // Creation function
    //public GridTunnelSearch(Stack<DefaultAction> plan, float startTime, float idealGoalTime, GridTimeDomain gtd, int MaxNumberOfNodes, float MaxTime, float T_x, float T_z, float T_t)
    public GridTunnelSearch(Stack<DefaultAction> plan, Vector3 startPos, float startTime, float idealGoalTime, GridTimeDomain gtd, int MaxNumberOfNodes, float MaxTime, float T_d, float T_t, float startSpeed = 0)
    {
        currentPlan = new DefaultAction[plan.Count];
        plan.CopyTo(currentPlan,0);

        this.T_d = T_d;
        //this.T_x = T_x;
        //this.T_z = T_z;
        this.T_t = T_t;

        this.maxTime = MaxTime;

        int startIndex = 0;
        //GridPlanningState startPlanningState = currentPlan[startIndex].state as GridPlanningState;
        //while (startPlanningState == null)
        //{
        //	startIndex++;
        //	startPlanningState = currentPlan[startIndex].state as GridPlanningState;
        //}

        //startState = new GridTimeState(startPlanningState.currentPosition, startTime, startSpeed);
        startState = new GridTimeState(startPos, startTime, startSpeed);
        lastState = new GridTimeState((currentPlan[currentPlan.Length-1].state as GridPlanningState).currentPosition, idealGoalTime);

        gridTimeDomain = gtd;

        float dist = (startState.currentPosition - lastState.currentPosition).magnitude;
        // TODO: what to do if there is no time???
        float minSpeed = dist / (idealGoalTime-startTime);
        if (minSpeed < 0)
            minSpeed = GridTimeDomain.MIN_SPEED;

        //tunnel = ConvertPlan(gtd.minSpeed, gtd.midSpeed, gtd.maxSpeed);
        tunnel = ConvertPlan(startTime, minSpeed, GridTimeDomain.MID_SPEED, GridTimeDomain.MAX_SPEED);

        //for(int aux = 0; aux < tunnel.tunnelMinVelocity.Length; aux++)
        //	Debug.Log("Tunnel "+aux+":"+tunnel.tunnelMinVelocity[aux]);

         	tunnelPlanner = new BestFirstSearchPlanner();

        List<PlanningDomainBase> domainList = new List<PlanningDomainBase>();
        domainList.Add(gridTimeDomain);

        tunnelPlanner.init(ref domainList, MaxNumberOfNodes);

        // MUBBASIR TESTING ARA STAR PLANNER HERE
        araStarPlanner = new ARAstarPlanner ();
        araStarPlanner.init(ref domainList, MaxNumberOfNodes);

        goalReached = false;

        ComputeTunnelSearch();

        //ComputeTunnelSearchStatePlan ();
    }
			public TunnelBinder(Tunnel tunnel, StreamingSettings settings, RtspServer rtspServer){
				this.tunnel = tunnel;
				this.settings = settings;
				this.rtspServer = rtspServer;
			}
		protected void OnBoundToTunnelService(TunnelService.TunnelBinder binder){
			Console.WriteLine("Bound to tunnel service");
			if(tunnel == null || !tunnel.Equals(binder.Tunnel)){
				tunnel = binder.Tunnel;
				rtspServer = binder.RtspServer;
				streamingSettings = binder.StreamingSettings;
				tunnel.Started += OnTunnelStarted;
				tunnel.Stopped += OnTunnelStopped;
				tunnel.ClientConnected += OnClientConnected;
				tunnel.ClientDisConnected += OnClientDisconnected;
				tunnel.LogEvent += WriteLine;
				rtspServer.StreamingStarted += OnStreamStarted;
				rtspServer.StreamingStoped += OnStreamStopped;
			}
			if (tunnel.IsRunning) {
				OnTunnelStarted();
				if(tunnel.ClientsConnected != 0){
					OnClientConnected(null);
				}
				else{
					OnClientDisconnected(null);
				}
				SetStreamStatus(rtspServer.IsStreaming);
			}
			else{
				OnTunnelStopped();
				OnClientDisconnected(null);
				SetStreamStatus(false);
			}
			//Do something here
		}
示例#43
0
        /// <summary>
        /// ��o�d��~�n��ܪ��]�ƦW��
        /// </summary>
        /// <param name="maxSegId">�̻�����q</param>
        /// <param name="devsMeg">�զX�]�ưT��</param>
        /// <param name="mile">�}�l���{</param>
        /// <param name="lineid">��u�s��</param>
        /// <param name="direction">��V</param>
        /// <returns>�]�ƦW�ٶ��X</returns>
        protected virtual RemoteInterface.HC.FetchDeviceData[] getOutDeviceName(ref int maxSegId, ref string devsMeg, int mile, string lineid, string direction)
        {
            RemoteInterface.HC.FetchDeviceData[] fetchDevs = null;
            //try
            //{
                RemoteInterface.HC.I_HC_FWIS hobj = EasyClient.getHost();

                if (!string.IsNullOrEmpty(ht["INC_INTERCHANGE"].ToString()) && !ht["INC_INTERCHANGE"].ToString().Contains("�t�Υ�y�D"))  //�`�D�J�f
                {
                    string tmpStr = (string)ht["INC_INTERCHANGE"];
                    if (tmpStr.Length > 1 && tmpStr.Substring(tmpStr.Length - 2).Equals("�J�f"))
                    {
                        if (devType != DeviceType.CMS)
                        {
                            return new RemoteInterface.HC.FetchDeviceData[0];
                        }
                        else
                        {
                            fetchDevs = LoadNearLCMS(lineid, mile);
                        }
                    }
                }
                else if (!string.IsNullOrEmpty(ht["BLOCKTYPEID"].ToString()))
                {
                    int blocktypeID = Convert.ToInt32(ht["BLOCKTYPEID"]);
                    if (blocktypeID == 6)
                    {
                        if (devType != DeviceType.CMS)
                        {
                            return new RemoteInterface.HC.FetchDeviceData[0];
                        }
                        else
                        {
                            fetchDevs = LoadNearLCMS(lineid, mile);
                        }
                    }
                }

                switch (devType)
                {
                    case DeviceType.LCS:
                        tunnel = TunnelData.getBuilder().tunList.Find(new EventObj(lineid, direction, mile));
                        if (tunnel != null)
                        {
                            int startMileage = 0;
                            //if (tunnel.UpstreamLocation != null)
                            //    startMileage = tunnel.UpstreamLocation.EndMileage;
                            //else
                            //{
                            if (tunnel.Direction == "E" || tunnel.Direction == "S")
                            {
                                startMileage = tunnel.Line.StartMileage;
                            }
                            else
                            {
                                startMileage = tunnel.Line.EndMileage;
                            }
                            //}

                            //Host fuction
                            fetchDevs = hobj.Fetch(new string[] { devType.ToString() }, lineid, direction, startMileage, tunnel.EndMileage);
                        }
                        break;
                    case DeviceType.CMS:
                        {
                            if (fetchDevs != null) //�w���J�J�fCMS
                                break;

                            string DevDir = string.Empty;
                            bool isExtend = Convert.ToInt32(DevRange["ISEXTEND"]) == 1 ? true : false;
                            //Host fuction
                            if ((int)DevRange["NORMAL"] == 0 && !isNear)
                            {
                                fetchDevs = new RemoteInterface.HC.FetchDeviceData[0];
                            }
                            else
                            {
                                if (lineid != "T74��" || direction != "W")
                                {
                                    fetchDevs = hobj.Fetch(new string[] { devType.ToString(), DeviceType.RGS.ToString() }, lineid, direction, mile, Convert.ToInt32(DevRange["NORMAL"]), Convert.ToInt32(DevRange["SYSTEM"]), isExtend);
                                }
                                else
                                    fetchDevs = new RemoteInterface.HC.FetchDeviceData[0];
                            }

                            System.Data.DataTable DT = RSPGlobal.GetDeviceDT();
                            for (int i = 0; i < fetchDevs.Length; i++)
                            {
                                System.Data.DataRow dr = DT.Rows.Find(fetchDevs[i].DevName);
                                if (dr != null)
                                {
                                    fetchDevs[i].Location = dr[RSPGlobal.Location].ToString();
                                }
                            }

                            List<RemoteInterface.HC.FetchDeviceData> oldFetchDevs = new List<RemoteInterface.HC.FetchDeviceData>();
                            int MaxSeg = 0;
                            foreach (RemoteInterface.HC.FetchDeviceData dev in fetchDevs)
                            {
                                if (dev.SegId > MaxSeg)
                                {
                                    MaxSeg = dev.SegId;
                                }
                            }

                            #region RGS�Ƨ�
                            foreach (RemoteInterface.HC.FetchDeviceData Dev in fetchDevs) //RGS�Ƨ�
                            {
                                if (Dev.DeviceType == "CMS")
                                {
                                    oldFetchDevs.Add(Dev);
                                }
                                else
                                {
                                    if (Dev.SegId == (int)DevRange["NORMAL"] || Dev.SegId == (int)DevRange["SYSTEM"])
                                    {
                                        for (int j = 0; j < oldFetchDevs.Count; j++)
                                        {
                                            if (oldFetchDevs[j].LineId == Dev.LineId && Dev.SegId == oldFetchDevs[j].SegId && Dev.Direction == oldFetchDevs[j].Direction)
                                            {
                                                if (Dev.Direction == "S" || Dev.Direction == "E")
                                                {
                                                    if (Dev.Mileage < oldFetchDevs[j].Mileage)
                                                    {
                                                        oldFetchDevs.Insert(j, Dev);
                                                        break;
                                                    }
                                                }
                                                else
                                                {
                                                    if (Dev.Mileage > oldFetchDevs[j].Mileage)
                                                    {
                                                        oldFetchDevs.Insert(j, Dev);
                                                        break;
                                                    }
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            fetchDevs = oldFetchDevs.ToArray();
                            #endregion

                            oldFetchDevs.Clear();
                            string DevDirN = string.Empty;
                            string DevLine = string.Empty;
                            DevDir = string.Empty;

                            string DevDirNS = string.Empty, DevLineS = string.Empty;
                            int DevSeg = 0;

                            for (int i = 0; i < fetchDevs.Length; i++)
                            {
                                //if (fetchDevs[i].Location != "L") //���������D�� || fetchDevs[i].LineId == lineid) //�����D�D�u�����D��
                                //{
                                if ((int)DevRange["SYSTEM"] > 0)
                                {
                                    if (fetchDevs[i].SegId <= (int)DevRange["NORMAL"])
                                    {
                                        if (fetchDevs[i].SegId == (int)DevRange["NORMAL"])
                                        {
                                            if (DevDirN != fetchDevs[i].Direction || DevLine != fetchDevs[i].LineId)
                                            {
                                                if (fetchDevs[i].Location != "L")
                                                {
                                                    oldFetchDevs.Add(fetchDevs[i]);
                                                    DevDirN = fetchDevs[i].Direction;
                                                    DevLine = fetchDevs[i].LineId;
                                                }
                                                if (DevDirNS != fetchDevs[i].Direction || DevLineS != fetchDevs[i].LineId || DevSeg != fetchDevs[i].SegId)
                                                {
                                                    oldFetchDevs.AddRange(LoadLCMS(fetchDevs[i].LineId, fetchDevs[i].Direction, fetchDevs[i].Mileage));
                                                    DevDirNS = fetchDevs[i].Direction;
                                                    DevLineS = fetchDevs[i].LineId;
                                                    DevSeg = fetchDevs[i].SegId;
                                                }
                                            }
                                        }
                                        else
                                        {
                                            oldFetchDevs.Add(fetchDevs[i]);
                                            if (DevDirNS != fetchDevs[i].Direction || DevLineS != fetchDevs[i].LineId || DevSeg != fetchDevs[i].SegId)
                                            {
                                                oldFetchDevs.AddRange(LoadLCMS(fetchDevs[i].LineId, fetchDevs[i].Direction, fetchDevs[i].Mileage));
                                                DevDirNS = fetchDevs[i].Direction;
                                                DevLineS = fetchDevs[i].LineId;
                                                DevSeg = fetchDevs[i].SegId;
                                            }
                                        }
                                    }
                                    else if (fetchDevs[i].SegId == MaxSeg)  // �t�Τ��ݸ��J����
                                    {
                                        if ((DevDir != fetchDevs[i].Direction || DevLine != fetchDevs[i].LineId) && fetchDevs[i].Location != "L")
                                        {
                                            oldFetchDevs.Add(fetchDevs[i]);
                                            DevDir = fetchDevs[i].Direction;
                                            DevLine = fetchDevs[i].LineId;
                                        }
                                    }
                                }
                                else
                                {
                                    if (fetchDevs[i].SegId < (int)DevRange["NORMAL"])
                                    {
                                        oldFetchDevs.Add(fetchDevs[i]);
                                        //for add LCMS 2011.03.14
                                        //DevDir = fetchDevs[i].Direction;
                                        //DevLine = fetchDevs[i].LineId;
                                        //
                                        if (DevDirNS != fetchDevs[i].Direction || DevLineS != fetchDevs[i].LineId || DevSeg != fetchDevs[i].SegId)
                                        {
                                            oldFetchDevs.AddRange(LoadLCMS(fetchDevs[i].LineId, fetchDevs[i].Direction, fetchDevs[i].Mileage));
                                            DevDirNS = fetchDevs[i].Direction;
                                            DevLineS = fetchDevs[i].LineId;
                                            DevSeg = fetchDevs[i].SegId;
                                        }
                                    }
                                    else
                                    {
                                        if (DevDir != fetchDevs[i].Direction || DevLine != fetchDevs[i].LineId)
                                        {
                                            if (fetchDevs[i].Location != "L")
                                            {
                                                oldFetchDevs.Add(fetchDevs[i]);
                                                DevDir = fetchDevs[i].Direction;
                                                DevLine = fetchDevs[i].LineId;
                                            }
                                            if (DevDirNS != fetchDevs[i].Direction || DevLineS != fetchDevs[i].LineId || DevSeg != fetchDevs[i].SegId)
                                            {
                                                oldFetchDevs.AddRange(LoadLCMS(fetchDevs[i].LineId, fetchDevs[i].Direction, fetchDevs[i].Mileage));
                                                DevDirNS = fetchDevs[i].Direction;
                                                DevLineS = fetchDevs[i].LineId;
                                                DevSeg = fetchDevs[i].SegId;
                                            }
                                        }
                                    }
                                }
                                //}
                            }

                            for (int i = 0; i < oldFetchDevs.Count; ) //�L�oCMS�H�~�]��
                            {
                                if (oldFetchDevs[i].DeviceType != "CMS")
                                {
                                    oldFetchDevs.Remove(oldFetchDevs[i]);
                                }
                                else
                                {
                                    i++;
                                }
                            }

                            try     //�A�Ȱ�
                            {
                                string cmd = string.Format("Select s.divisionid,div.lineid,div.mileage from {0}.{1} s,{0}.{5} div Where s.LineID = '{2}' and s.Direction = '{3}' and "
                                    + " ((s.Start_mile >= {4} and s.END_Mile <= {4}) or (s.Start_mile <= {4} and s.End_Mile >= {4})) and s.divisionid = div.divisionid;"
                                    , RSPGlobal.GlobaSchema, DBConnect.DB2TableName.tblRSPServiceRange, lineid, direction, mile, DBConnect.DB2TableName.tblGroupDivision);
                                DT = com.Select(cmd);
                                foreach (System.Data.DataRow dr in DT.Rows)
                                {
                                    if ((string)dr[1] == "N1") //LineID
                                    {
                                        int N1_Mile;
                                        if (lineid == "N1")
                                        {
                                            N1_Mile = mile;
                                        }
                                        else
                                        {
                                            cmd = string.Format("Select mileage1 from {0}.{1} where LineID1 = 'N1' and LineID2 = '{2}';"
                                                , RSPGlobal.GlobaSchema, DBConnect.DB2TableName.tblCloverleaf, lineid);
                                            System.Data.DataTable TmpDT = com.Select(cmd);
                                            N1_Mile = (int)TmpDT.Rows[0][0];
                                        }

                                        string EventDir;
                                        if ((int)dr[2] > N1_Mile)
                                        {
                                            EventDir = "N";
                                        }
                                        else
                                        {
                                            EventDir = "S";
                                        }
                                        if (lineid == "N1" && EventDir != direction)
                                        {
                                            continue;
                                        }

                                        cmd = string.Format("select cfg.DeviceName,cfg.LineID,cfg.Direction,cfg.mile_M from {0}.{1} cfg , {0}.{2} sec "
                                         + " where (sec.START_DIVISIONID = '{3}' or sec.END_DIVISIONID = '{3}') "
                                         + " and sec.SECTIONID = cfg.SECTIONID and cfg.LOCATION = 'S' and cfg.Device_Type = 'CMSRST' and cfg.Direction = '{4}';"
                                         , RSPGlobal.GlobaSchema, DBConnect.DB2TableName.tblDeviceConfig, DBConnect.DB2TableName.tblGroupSection, dr[0], EventDir);

                                    }
                                    else
                                    {
                                        cmd = string.Format("select cfg.DeviceName,cfg.LineID,cfg.Direction,cfg.mile_M from {0}.{1} cfg , {0}.{2} sec "
                                            + " where (sec.START_DIVISIONID = '{3}' or sec.END_DIVISIONID = '{3}') "
                                            + " and sec.SECTIONID = cfg.SECTIONID and cfg.LOCATION = 'S' and cfg.Device_Type = 'CMSRST';", RSPGlobal.GlobaSchema
                                            , DBConnect.DB2TableName.tblDeviceConfig, DBConnect.DB2TableName.tblGroupSection, dr[0]);
                                    }
                                    System.Data.DataTable CMSDT = com.Select(cmd);
                                    foreach (System.Data.DataRow CMSdr in CMSDT.Rows)
                                    {
                                        RemoteInterface.HC.FetchDeviceData newDev
                                            = new RemoteInterface.HC.FetchDeviceData((string)CMSdr[0], 0, (string)CMSdr[1], (string)CMSdr[2], (int)CMSdr[3], 90, 30, "CMS");
                                        newDev.Location = "S";
                                        oldFetchDevs.Add(newDev);
                                    }
                                }
                            }
                            catch
                            {
                                //���J�A�Ȱ�CMS�ɵo�ͨҥ~
                            }

                            if (ht["INC_NAME"].Equals(43))
                            {
                                fetchDevs = LoadNearLCMS(lineid, mile);
                                foreach (RemoteInterface.HC.FetchDeviceData dev in fetchDevs)
                                {
                                    for (int k = 0; k < oldFetchDevs.Count; k++)
                                    {
                                        if (oldFetchDevs[k].DevName == dev.DevName)
                                        {
                                            oldFetchDevs.RemoveAt(k);
                                            k--;
                                            break;
                                        }
                                    }
                                }
                            }
                            else if (!string.IsNullOrEmpty(ht["INC_INTERCHANGE"].ToString()))  //�`�D�X�f
                            {
                                string tmpStr = (string)ht["INC_INTERCHANGE"];
                                if (tmpStr.Length > 1 && tmpStr.Substring(tmpStr.Length - 2).Equals("�X�f"))
                                {
                                    fetchDevs = LoadNearLCMS(lineid, mile);
                                    foreach (RemoteInterface.HC.FetchDeviceData dev in fetchDevs)
                                    {
                                        for (int k = 0; k < oldFetchDevs.Count; k++)
                                        {
                                            if (oldFetchDevs[k].DevName == dev.DevName)
                                            {
                                                oldFetchDevs.RemoveAt(k);
                                                k--;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }
                            else if (!string.IsNullOrEmpty(ht["BLOCKTYPEID"].ToString()))
                            {
                                int blocktypeID = Convert.ToInt32(ht["BLOCKTYPEID"]);
                                if ( blocktypeID == 5)
                                {
                                    fetchDevs = LoadNearLCMS(lineid, mile);
                                    foreach (RemoteInterface.HC.FetchDeviceData dev in fetchDevs)
                                    {
                                        for (int k = 0; k < oldFetchDevs.Count; k++)
                                        {
                                            if (oldFetchDevs[k].DevName == dev.DevName)
                                            {
                                                oldFetchDevs.RemoveAt(k);
                                                k--;
                                                break;
                                            }
                                        }
                                    }
                                }
                            }

                            if (lineid == "N1" && direction == "N" && ((mile > 174200 && mile < 192800) || ((int)ht["TO_MILEPOST1"] > 174200 && (int)ht["TO_MILEPOST1"] < 192800)))
                            {
                                oldFetchDevs.Add(new RemoteInterface.HC.FetchDeviceData("CMS-N3-S-196.7", 5, "N3", "S", 196700, 100, 60, "CMS"));
                                oldFetchDevs.Add(new RemoteInterface.HC.FetchDeviceData("CMS-N3-S-196.8", 5, "N3", "S", 196850, 100, 60, "CMS"));
                            }
                            else
                            {
                                for (int i = 0; i < oldFetchDevs.Count;i++ )
                                {
                                    if (oldFetchDevs[i].DevName == "CMS-N3-S-196.7" || oldFetchDevs[i].DevName == "CMS-N3-S-196.8")
                                    {
                                        oldFetchDevs.RemoveAt(i);
                                        i--;
                                        continue;
                                    }
                                }
                            }

                            //for (int i = 0; i < oldFetchDevs.Count; ) //�L�oCMS�H�~�]��
                            //{
                            //    System.Data.DataRow dr = DT.Rows.Find(oldFetchDevs[i].DevName);
                            //    if (dr == null)
                            //    {
                            //        oldFetchDevs.Remove(oldFetchDevs[i]);
                            //    }
                            //    else
                            //    {
                            //        if (((string)dr[2]) != "CMS")
                            //        {
                            //            oldFetchDevs.Remove(oldFetchDevs[i]);
                            //        }
                            //        else
                            //        {
                            //            i++;
                            //        }
                            //    }
                            //}
                            fetchDevs = oldFetchDevs.ToArray();
                            /////
                            //�W�奭���D����ݩҦ�CMS
                            //try
                            //{
                            //string where;
                            //if (direction == "S" || direction == "E")
                            //{
                            //    where = string.Format(" mileage <= {0} order by mileage desc", mile);
                            //}
                            //else
                            //{
                            //    where = " mileage >= " + mile.ToString() + " order by mileage asc ";
                            //}

                            //string cmd = string.Format("Select mileage From {0}.{1} where LineID = '{2}' and {3} fetch first 1 rows only; "
                            //    , RSPGlobal.GlobaSchema, DBConnect.DB2TableName.tblGroupDivision, lineid, where);

                            //DT = com.Select(cmd);
                            //int DivMile = (int)DT.Rows[0][0];

                            //cmd = string.Format("Select cfg.DeviceName,cfg.Mile_M,section.MaxSpeed,section.MinSpeed From {0}.{1} cfg ,{0}.{4} section "
                            //    + " where cfg.LineID = '{2}' and cfg.device_Type = 'CMS'  and cfg.Location = 'L' "
                            //    + " and cfg.mile_m > ({3} - 200) and cfg.mile_m < ({3} + 200) and cfg.sectionID = section.sectionID;"
                            //    , RSPGlobal.GlobaSchema,DBConnect.DB2TableName.tblDeviceConfig,lineid,DivMile,DBConnect.DB2TableName.tblGroupSection);
                            //DT = com.Select(cmd);

                            //fetchDevs = new RemoteInterface.HC.FetchDeviceData[oldFetchDevs.Count + DT.Rows.Count];
                            //for (int i = 0; i < oldFetchDevs.Count; i++)
                            //{
                            //    fetchDevs[i] = oldFetchDevs[i];
                            //}

                            //int j = 0;
                            //foreach (System.Data.DataRow dr in DT.Rows)
                            //{
                            //    fetchDevs[oldFetchDevs.Count + j] = new RemoteInterface.HC.FetchDeviceData((string)dr[0], 0, lineid, direction, (int)dr[1], (int)dr[2], (int)dr[3]);
                            //    fetchDevs[oldFetchDevs.Count + j].Location = "L";
                            //    j++;
                            //}
                            //    fetchDevs = oldFetchDevs.ToArray();

                            //}
                            //catch(Exception ex)
                            //{
                            //    throw ex;
                            //}
                            /////

                        }
                        break;
                    case DeviceType.CSLS:
                    case DeviceType.MAS:
                        List<RemoteInterface.HC.FetchDeviceData> Devs = new List<RemoteInterface.HC.FetchDeviceData>();
                        fetchDevs = hobj.Fetch(new string[] { devType.ToString() }, lineid, direction, mile, 5, 0, false);
                        Devs.AddRange(fetchDevs);

                        int mile_e = (int)ht["TO_MILEPOST1"];
                        int mile_o = mile_e;
                        switch (direction) // �ݧ�אּŪ����Ʈw
                        {
                            case "N":
                            case "W":
                                mile_o = mile_e - 2000;
                                break;
                            case "S":
                            case "E":
                                mile_o = mile_e + 2000;
                                break;
                        }
                        fetchDevs = hobj.Fetch(new string[] { devType.ToString() }, lineid, direction, mile_e, mile_o);
                        if (fetchDevs.Length > 0)
                        {
                            fetchDevs[0].Location = "D";
                            Devs.Insert(0, fetchDevs[0]);
                        }
                        fetchDevs = Devs.ToArray();
                        break;
                    //case DeviceType.FS:  �L�v�T�ϰ�~�]��
                    //    break;
                    case DeviceType.RGS:
                        {
                            if (type == CategoryType.RGS)
                            {
                                fetchDevs
                                    = new RemoteInterface.HC.FetchDeviceData[] { new RemoteInterface.HC.FetchDeviceData(ht["INC_NOTIFY_PLANT"].ToString(), 0, lineid, direction, mile, 100, 40, "RGS") };
                            }
                            else
                            {
                                bool isExtend = Convert.ToInt32(DevRange["ISEXTEND"]) == 1 ? true : false;
                                if ((int)DevRange["NORMAL"] == 0)
                                {
                                    fetchDevs = new RemoteInterface.HC.FetchDeviceData[0];
                                }
                                else
                                {
                                    fetchDevs = hobj.Fetch(new string[] { devType.ToString() }, lineid, direction, mile, Convert.ToInt32(DevRange["NORMAL"]), Convert.ToInt32(DevRange["SYSTEM"]), isExtend);
                                }
                                int MaxSeg = 0;
                                foreach (RemoteInterface.HC.FetchDeviceData dev in fetchDevs)
                                {
                                    if (dev.SegId > MaxSeg)
                                    {
                                        MaxSeg = dev.SegId;
                                    }
                                }
                                if ((int)DevRange["SYSTEM"] > 0)
                                {
                                    string DevDir = string.Empty;
                                    string DevLine = string.Empty;
                                    List<RemoteInterface.HC.FetchDeviceData> FiltDevs = new List<RemoteInterface.HC.FetchDeviceData>(fetchDevs.Length);
                                    for (int i = 0; i < fetchDevs.Length; i++)
                                    {
                                        if (fetchDevs[i].SegId < (int)DevRange["NORMAL"])
                                        {
                                            FiltDevs.Add(fetchDevs[i]);
                                        }
                                        else
                                        {
                                            if (fetchDevs[i].SegId == MaxSeg && (fetchDevs[i].Direction != DevDir || fetchDevs[i].LineId != DevLine))
                                            {
                                                FiltDevs.Add(fetchDevs[i]);
                                                DevDir = fetchDevs[i].Direction;
                                                DevLine = fetchDevs[i].LineId;
                                            }
                                        }
                                    }
                                    fetchDevs = FiltDevs.ToArray();
                                }
                            }
                        }
                        break;
                    case DeviceType.RMS:
                        fetchDevs = hobj.Fetch(new string[] { devType.ToString() }, lineid, direction, mile, 1, 0, false);//
                        if (fetchDevs.Length > 1)
                        {
                            fetchDevs = new RemoteInterface.HC.FetchDeviceData[1] { fetchDevs[0] };
                        }
                        break;
                    //case DeviceType.WIS: �L�v�T�ϰ�~�]��
                    //    break;
                    case DeviceType.CCTV:
                        {
                            //List<RemoteInterface.HC.FetchDeviceData> CCTVList = new List<RemoteInterface.HC.FetchDeviceData>(2);
                            //string cmd = string.Format("select Top 1 camera_name,cast(milepost as int) as mile from vw_user_CCTV "
                            //    + " where category_name = '{0}' and cast(milepost as int) >= {1} and cast(milepost as int) < {2} order by cast(milepost as int)", lineid, mile,mile + 3000);
                            //DBConnect.ODBC_SQLServerConnect SQLconn = new DBConnect.ODBC_SQLServerConnect();
                            //System.Data.DataTable DT = SQLconn.Select(cmd);
                            //if (DT != null && DT.Rows.Count > 0)
                            //{
                            //    CCTVList.Add(new RemoteInterface.HC.FetchDeviceData((string)DT.Rows[0][0], 0, lineid, direction, (int)DT.Rows[0][1], 90, 30, "CCTV"));
                            //}
                            //cmd = string.Format("select Top 1 camera_name,cast(milepost as int) as mile from vw_user_CCTV "
                            //    + " where category_name = '{0}' and cast(milepost as int) <= {1} and cast(milepost as int) > {2} order by cast(milepost as int) desc", lineid, mile,mile - 3000);
                            //DT = SQLconn.Select(cmd);
                            //if (DT != null && DT.Rows.Count > 0)
                            //{
                            //    CCTVList.Add(new RemoteInterface.HC.FetchDeviceData((string)DT.Rows[0][0], 0, lineid, direction, (int)DT.Rows[0][1], 90, 30, "CCTV"));
                            //}

                            //fetchDevs = CCTVList.ToArray();

                            List<RemoteInterface.HC.FetchDeviceData> CCTVList = new List<RemoteInterface.HC.FetchDeviceData>(2);

                            string cmd = string.Format("Select Camera_Name,mile_m from {0}.{1} where category_name = '{2}' and mile_m > {3} and mile_m <{4} order by mile_m fetch first 1 rows only;"
                                , RSPGlobal.GlobaSchema, "TBLCCTVCONFIG", lineid, mile, mile + 3000);
                            System.Data.DataTable DT = com.Select(cmd);
                            if (DT != null && DT.Rows.Count > 0)
                            {
                                CCTVList.Add(new RemoteInterface.HC.FetchDeviceData((string)DT.Rows[0][0], 0, lineid, direction, (int)DT.Rows[0][1], 90, 30, "CCTV"));
                            }
                            cmd = string.Format("Select Camera_Name,mile_m from {0}.{1} where category_name = '{2}' and mile_m > {3} and mile_m <{4} order by mile_m desc fetch first 1 rows only;"
                            , RSPGlobal.GlobaSchema, "TBLCCTVCONFIG", lineid, mile - 3000, mile);
                            DT = com.Select(cmd);
                            if (DT != null && DT.Rows.Count > 0)
                            {
                                CCTVList.Add(new RemoteInterface.HC.FetchDeviceData((string)DT.Rows[0][0], 0, lineid, direction, (int)DT.Rows[0][1], 90, 30, "CCTV"));
                            }

                            //System.Data.DataRow dr = RSPGlobal.GetLineNameDT().Rows.Find(lineid);
                            //int StartMile = (int)dr[2];
                            //int EndMile = (int)dr[3];

                            //StartMile = StartMile > mile - 3000 ? StartMile : mile - 3000;
                            //EndMile = EndMile < mile + 3000 ? EndMile : mile + 3000;

                            //fetchDevs = hobj.Fetch(new string[] { "CCTV" }, lineid, mile, StartMile);
                            //if (fetchDevs.Length > 0)
                            //    CCTVList.Add(fetchDevs[0]);
                            //fetchDevs = hobj.Fetch(new string[] { "CCTV" }, lineid, mile, EndMile);
                            //if (fetchDevs.Length > 0)
                            //    CCTVList.Add(fetchDevs[0]);
                            fetchDevs = CCTVList.ToArray();
                        }
                        break;
                }

                if (fetchDevs == null) return fetchDevs;
                foreach (RemoteInterface.HC.FetchDeviceData fetchDev in fetchDevs)
                {
                    devsMeg += fetchDev.DevName + "<<==";
                    if (maxSegId < fetchDev.SegId) maxSegId = fetchDev.SegId;
                }
            //}
            //catch (Exception ex)
            //{
            //    throw ex;
            //}
            return fetchDevs;
        }
        private void AddTunnelInfo()
        {
            // 验证
            if (!Check())
            {
                DialogResult = DialogResult.None;
                return;
            }
            DialogResult = DialogResult.OK;
            //创建巷道实体

            var workingFace = selectWorkingFaceControl1.SelectedWorkingFace;
            using (new SessionScope())
            {
                workingFace = Workingface.Find(workingFace.id);
                if (workingFace.tunnels.FirstOrDefault(u => u.name == txtTunnelName.Text) != null)
                {
                    Alert.AlertMsg("该工作面下已有同名巷道!");
                    return;
                }
            }

            var tunnel = new Tunnel
            {
                name = txtTunnelName.Text,
                support_pattern = cboSupportPattern.Text,
                workingface = selectWorkingFaceControl1.SelectedWorkingFace,
                lithology = cboLithology.SelectedValue.ToString(),
                type = (TunnelTypeEnum)cboTunnelType.SelectedValue,
                coal_or_stone = cboCoalOrStone.Text,
                coal_seam = ConfigHelper.current_seam.name,
                bid = IdGenerator.NewBindingId(),
                width = 5
            };

            //设计长度
            if (txtDesignLength.Text != "")
            {
                tunnel.design_length = Convert.ToInt32(txtDesignLength.Text);
            }
            if (txtDesignArea.Text != "")
            {
                tunnel.design_area = Convert.ToInt32(txtDesignLength.Text);
            }
            //巷道信息登录

            tunnel.Save();
            Alert.AlertMsg("提交成功!");
        }
 private void cbxTunnel_SelectedIndexChanged(object sender, EventArgs e)
 {
     selected_tunnel = cbxTunnel.SelectedItem as Tunnel;
 }
 /// <summary>
 ///     修改
 /// </summary>
 public TunnelInfoEntering(Tunnel tunnel)
 {
     InitializeComponent();
     tunnel = tunnel;
 }
 public void RemoveTunnel(Tunnel tunnel)
 {
     Tunnels.Remove(tunnel);
 }
示例#48
0
 private Ship autoShip(Tunnel t, Ship s)
 {
     s.x = towards(t.x, s.x);
     return s;
 }
示例#49
0
    public static float ComputeDistanceToTunnel(GridTimeState state, Tunnel t)
    {
        int startIndexMaxV = -1;
        int endIndexMaxV = -1;
        int startIndexMinV = -1;
        int endIndexMinV = -1;
        SearchTimeRanges(t,state,ref startIndexMinV, ref endIndexMinV, ref startIndexMaxV, ref endIndexMaxV);

        Vector3 statePos = state.currentPosition;

        float minDistance = float.MaxValue;

        if (
            (startIndexMinV >=0 && startIndexMinV < t.tunnelMidVelocity.Length) ||
            (endIndexMinV >=0 && endIndexMinV < t.tunnelMidVelocity.Length)
        )
        {
            if (startIndexMinV >=0 || startIndexMinV < t.tunnelMidVelocity.Length)
                startIndexMinV = 0;
            if (endIndexMinV >=0 || endIndexMinV < t.tunnelMidVelocity.Length)
                endIndexMaxV = t.tunnelMidVelocity.Length-1;

            for (int i = startIndexMinV; i < endIndexMinV; i++)
            {
                GridTimeState s1 = t.tunnelMidVelocity[i];
                GridTimeState s2 = t.tunnelMidVelocity[i+1];

                float distance = float.MaxValue;
                if (s1 != null && s2 != null)
                    distance = ComputeDistance(state,s1,s2);

                if (distance < minDistance)
                    minDistance = distance;
            }
        }

        if (
            (startIndexMaxV >=0 && startIndexMaxV < t.tunnelMidVelocity.Length) ||
            (endIndexMaxV >=0 && endIndexMaxV < t.tunnelMidVelocity.Length)
        )
        {
            if (startIndexMaxV >=0 || startIndexMaxV < t.tunnelMidVelocity.Length)
                startIndexMaxV = 0;
            if (endIndexMaxV >=0 || endIndexMaxV < t.tunnelMidVelocity.Length)
                endIndexMaxV = t.tunnelMidVelocity.Length-1;

            for (int i = startIndexMaxV; i < endIndexMaxV; i++)
            {
                GridTimeState s1 = t.tunnelMidVelocity[i];
                GridTimeState s2 = t.tunnelMidVelocity[i+1];

                float distance = float.MaxValue;
                if (s1 != null && s2 != null)
                    distance = ComputeDistance(state,s1,s2);

                if (distance < minDistance)
                    minDistance = distance;
            }
        }

        return minDistance;
    }
示例#50
0
    // Performs a binary search for the indexes in the tunnel t corresponding to the portion of the path
    // where the time values are in the valid range of the state we are looking at
    private static void SearchTimeRanges(Tunnel t, GridTimeState state, 
		ref int startIndexMinV, ref int endIndexMinV,
		ref int startIndexMaxV, ref int endIndexMaxV)
    {
        startIndexMinV = -1;
        endIndexMinV = -1;
        startIndexMaxV = -1;
        endIndexMaxV = -1;

        float minTime = state.time - t.thresholdT;
        if (minTime < 0 ) minTime = 0;
        float maxTime = state.time + t.thresholdT;

        int i = 0;
        int j = t.tunnelMidVelocity.Length-1;
        int k = -1;
        while (i < j)
        {
            k = i + (int)(( j - i ) / 2);

            float minTimeK = t.tunnelMaxVelocity[k];

            if (minTime == minTimeK)
            {
                i = k;
                j = k;
            }
            else
            {
                if (minTime < minTimeK)
                {
                    k--;
                    j = k;
                }
                else // minTim > minTimeK
                {
                    k++;
                    i = k;
                }
            }
        }
        startIndexMaxV = k;

        float aux;

        if (k >= 0 && k < t.tunnelMidVelocity.Length)
        {
            aux = t.tunnelMaxVelocity[k];
            if (aux < minTime)
                startIndexMaxV++;
        }

        i = 0;
        j = t.tunnelMidVelocity.Length-1;
        k = -1;
        while (i < j)
        {
            k = i + (int)(( j - i ) / 2);

            float minTimeK = t.tunnelMaxVelocity[k];

            if (maxTime == minTimeK)
            {
                i = k;
                j = k;
            }
            else
            {
                if (maxTime < minTimeK)
                {
                    k--;
                    j = k;
                }
                else // maxTim > minTimeK
                {
                    k++;
                    i = k;
                }
            }
        }
        endIndexMaxV = k;

        if (k >= 0 && k < t.tunnelMidVelocity.Length)
        {
            aux = t.tunnelMaxVelocity[k];
            if (aux > maxTime)
                endIndexMaxV--;
        }

        i = 0;
        j = t.tunnelMidVelocity.Length-1;
        k = -1;
        while (i < j)
        {
            k = i + (int)(( j - i ) / 2);

            float maxTimeK = t.tunnelMinVelocity[k];

            if (minTime == maxTimeK)
            {
                i = k;
                j = k;
            }
            else
            {
                if (minTime < maxTimeK)
                {
                    k--;
                    j = k;
                }
                else // minTim > maxTimeK
                {
                    k++;
                    i = k;
                }
            }
        }
        startIndexMinV = k;

        if (k >= 0 && k < t.tunnelMidVelocity.Length)
        {
            aux = t.tunnelMaxVelocity[k];
            if (aux < minTime)
                startIndexMinV--;
        }

        i = 0;
        j = t.tunnelMidVelocity.Length-1;
        k = -1;
        while (i < j)
        {
            k = i + (int)(( j - i ) / 2);

            float maxTimeK = t.tunnelMinVelocity[k];

            if (maxTime == maxTimeK)
            {
                i = k;
                j = k;
            }
            else
            {
                if (maxTime < maxTimeK)
                {
                    k--;
                    j = k;
                }
                else // maxTim > maxTimeK
                {
                    k++;
                    i = k;
                }
            }
        }
        endIndexMinV = k;

        if (k >= 0 && k < t.tunnelMidVelocity.Length)
        {
            aux = t.tunnelMaxVelocity[k];
            if (aux > maxTime)
                endIndexMinV--;
        }

        /*
        for(int aux2 = 0; aux2 < t.tunnelMaxVelocity.Length; aux2++)
            Debug.Log("Tunnel "+aux2+":"+t.tunnelMaxVelocity[aux2]+ " y "+t.tunnelMinVelocity[aux2]);
        Debug.Log("minTime = "+minTime);
        Debug.Log("maxTime = "+maxTime);
        Debug.Log("startIndexMaxV = "+startIndexMaxV);
        Debug.Log("endIndexMaxV= "+endIndexMaxV);
        Debug.Log("startIndexMinV = "+startIndexMinV);
        Debug.Log("endIndexMinV= "+endIndexMinV);
        */
    }
示例#51
0
	public void UseTunnelSearch(Tunnel t)
	{
		tunnel = t;	
		useTunnel = true;
	}
		protected void OnClientConnected(Tunnel.Client client){
			if (client != null) {
				client.LogId = false;
			}
			RunOnUiThread(delegate() {
				SetEnableLight(connectLight);
				connectText.Text = "Client is connected";
				DisableButton(connectButton);
			});
		}
 /// <summary>
 /// 构造方法
 /// </summary>
 /// <params name="tunnel"></params>
 public SelectTunnelDlg(Tunnel tunnel)
 {
     InitializeComponent();
     selected_tunnel = tunnel;
 }
 /// <summary>
 /// 提交
 /// </summary>
 /// <params name="sender"></params>
 /// <params name="e"></params>
 private void btnSubmit_Click(object sender, EventArgs e)
 {
     selected_tunnel = selectTunnelUserControl1.selected_tunnel;
     DialogResult = DialogResult.OK;
 }
		private void OnClientDisconnected(Tunnel.Client client){
			listAdapter.Remove(client);
			RunOnUiThread(delegate() {
				listAdapter.NotifyDataSetChanged();
			});
		}
		protected virtual void OnBoundToTunnelService(Tunnel tunnel){

		}
		public void Remove(Tunnel.Client client){
			items.Remove(client);
		}		
		public static void Main2 (string[] args)
		{
				string connectToClient = "";	

				ConsoleKeyInfo cki;
				
			    TunnelSettings inConfig = new TunnelSettings();
				try
    			{
					inConfig = inConfig.LoadFromXML("settings.xml");
				}
				catch(Exception){
					ScreenPrint("Failed to read settings. Using default settings");
				}
				Arguments CommandLine = new Arguments(args);
				
			    if(CommandLine["connect"] != null){ 
					connectToClient = CommandLine["connect"];
				}				
				tunnel = new Tunnel();
				tunnel.LogEvent += ScreenPrint;
				try
    			{
					if(tunnel.Start(inConfig)){
					    Console.WriteLine("Press Q to quit");						
						Console.WriteLine("Press C to connect to client");
						Console.WriteLine("Press T to throw off all clients");
						if(connectToClient != "")
							tunnel.ConnectToClient(connectToClient);
						do 
	      				{
					        cki = Console.ReadKey(true);
					        if(cki.Key == ConsoleKey.C){
								tunnel.LogEvent -= ScreenPrint;
								Console.Write("Enter client IP-Address: ");
								tunnel.ConnectToClient(Console.ReadLine());
								tunnel.LogEvent += ScreenPrint;
							}
							if(cki.Key == ConsoleKey.T){
								tunnel.ThrowOffAllClients();
							}
	       				} while (cki.Key != ConsoleKey.Q);
						tunnel.Stop();
					}
 				}
			    catch(Exception e)
				{
					Console.WriteLine(e.Message);
				}
				finally
				{
					if(tunnel.IsRunning)
						tunnel.Stop();
				}
				TunnelSettings outConfig = inConfig;
				try{
					outConfig.SaveToXML("settings.xml");
				}
				catch{
				}
		}
 private void lstTunnelName_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (lstTunnelName.SelectedItems.Count <= 0)
         selected_tunnel = null;
     else
         selected_tunnel = (Tunnel)lstTunnelName.SelectedItem;
 }
		public void Add(Tunnel.Client client){
			items.Add(client);
		}