Inheritance: MonoBehaviour
Ejemplo n.º 1
0
    public static void Main()
    {
        string ServiceURL = "http://localhost:8080";
        using (Loading xl = new Loading())
        {
            try
            {
                xl.Table = "ZSFDC_TABLE";
                xl.Procedure = "ZSFDC_TEST";
                xl.Environment = "company";

                xl.set_AddColumn(1, new LoadColumn("USERNAME", tColumnType.typeCHAR));
                xl.set_AddColumn(1, new LoadColumn("WARHS", tColumnType.typeCHAR));
                xl.set_AddColumn(1, new LoadColumn("BIN", tColumnType.typeCHAR));
                xl.set_AddColumn(1, new LoadColumn("CURDATE", tColumnType.typeDATE));
                xl.set_AddColumn(2, new LoadColumn("PART", tColumnType.typeCHAR));
                xl.set_AddColumn(2, new LoadColumn("STATUS", tColumnType.typeCHAR));
                xl.set_AddColumn(2, new LoadColumn("CQUANT", tColumnType.typeINT));

                xl.set_AddRecordType(1, new LoadRow("user", "Main", "0", DateTime.Now.ToString()));
                xl.set_AddRecordType(2, new LoadRow("PART123", "Goods", "1"));
                xl.set_AddRecordType(2, new LoadRow("PART321", "Goods", "1"));

                Exception exp = new Exception();
                if (!xl.Post(ServiceURL, ref exp)) throw exp;
            }
            catch (Exception ex)
            {
                System.Windows.Forms.MessageBox.Show(ex.Message);
            }
        }
    }
 private void LoadComplete()
 {
     if (null != view) {
         ResourceSystem.Instance.RecycleObject(view.gameObject);
     }
     view = null;
     async = null;
 }
Ejemplo n.º 3
0
	void Awake(){
		if (instance){
			Destroy(gameObject);
			hide();
			return;
		}
		instance = this;
		gameObject.AddComponent<GUITexture>().enabled = false;
		guiTexture.texture = texture;
		transform.position = new Vector3(positionX, positionY, positionZ);
		DontDestroyOnLoad(this);
	}
Ejemplo n.º 4
0
 public void button1_Click(object sender, EventArgs e)
 {
     Loading l = new Loading();
     try
     {
         button1.Enabled = false;
         button2.Enabled = false;
         this.Hide();
         l.Show();
         l.Refresh();
         readAllResourceFiles(txtBoxPath.Text.ToString());
         l.Close();
         this.Close();
     }
     catch (Exception exce)
     {
         MessageBox.Show(exce.Message);
         this.Show();
         l.Close();
         button1.Enabled = true;
         button2.Enabled = true;
     }
 }
Ejemplo n.º 5
0
 private void Death()
 {
     // death handle
     Loading.Load(LoadingScene.Menu);
 }
Ejemplo n.º 6
0
        public void UpdatePositions()
        {
            // get current positions and velocitys
            foreach (var drone in Drones)
            {
                if (drone.Location == null)
                {
                    drone.Location = new PointLatLngAlt();
                }
                drone.Location.Lat = drone.MavState.cs.lat;
                drone.Location.Lng = drone.MavState.cs.lng;
                drone.Location.Alt = drone.MavState.cs.alt;
                if (drone.Velocity == null)
                {
                    drone.Velocity = new Vector3();
                }
                drone.Velocity.x = drone.MavState.cs.vx;
                drone.Velocity.y = drone.MavState.cs.vy;
                drone.Velocity.z = drone.MavState.cs.vz;
            }

            switch (CurrentMode)
            {
            case Mode.idle:
                // request positon at 10hz
                foreach (var drone in Drones)
                {
                    var MAV = drone.MavState;

                    MAV.parent.requestDatastream(MAVLink.MAV_DATA_STREAM.POSITION, 10, MAV.sysid, MAV.compid);
                    MAV.cs.rateposition = 10;

                    drone.takeoffdone = false;
                }
                CurrentMode = Mode.takeoff;
                break;

            case Mode.takeoff:
                int g  = Drones.Count;
                int aa = -1;
                foreach (var drone in Drones)
                {
                    aa++;
                    g--;
                    var MAV = drone.MavState;
                    try
                    {
                        // guided mode
                        if (!MAV.cs.mode.ToLower().Equals("guided"))
                        {
                            MAV.parent.setMode(MAV.sysid, MAV.compid, "GUIDED");
                        }
                        // arm
                        if (!MAV.cs.armed)
                        {
                            if (!MAV.parent.doARM(MAV.sysid, MAV.compid, true))
                            {
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        Loading.ShowLoading("Communication with one of the drones is failing\n" + ex);

                        return;
                    }

                    // get base to drone dist and bearing
                    var basepos  = GetBasePosition();
                    var dronepos = drone.Location;

                    if (basepos == null)
                    {
                        return;
                    }

                    var dist    = basepos.GetDistance(dronepos);
                    var bearing = basepos.GetBearing(dronepos);

                    // set drone target position
                    drone.TargetLocation     = basepos.newpos(bearing, dist);
                    drone.TargetLocation.Alt = TakeOffAlt + g * 2;

                    try
                    {
                        // takeoff
                        if (MAV.cs.alt < drone.TargetLocation.Alt - 0.5)
                        {
                            if (MAV.parent.doCommand(MAV.sysid, MAV.compid, MAVLink.MAV_CMD.TAKEOFF, 0, 0, 0, 0, 0,
                                                     0, (float)drone.TargetLocation.Alt))
                            {
                                drone.takeoffdone = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        Loading.ShowLoading("Communication with one of the drones is failing\n" + ex);

                        return;
                    }

                    drone.MavState.GuidedMode.x = (int)(drone.TargetLocation.Lat * 1e7);
                    drone.MavState.GuidedMode.y = (int)(drone.TargetLocation.Lng * 1e7);
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    // wait for takeoff
                    if (MAV.cs.alt < drone.TargetLocation.Alt - 0.5)
                    {
                        Thread.Sleep(100);
                        // check we are still armed
                        if (!MAV.cs.armed)
                        {
                            return;
                        }


                        drone.TargetVelocity = GetBaseVelocity();

                        //drone.SendPositionVelocity(drone.TargetLocation, drone.TargetVelocity);

                        drone.MavState.GuidedMode.x = (int)((float)drone.TargetLocation.Lat * 1e7);
                        drone.MavState.GuidedMode.y = (int)((float)drone.TargetLocation.Lng * 1e7);
                        drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                        // alt target must be reached
                        return;
                    }

                    // we should only get here once takeoff alt has been archived by this drone.

                    drone.TargetLocation = GetDronePosition(drone, aa);

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    drone.MavState.GuidedMode.x = (int)((float)drone.TargetLocation.Lat * 1e7);
                    drone.MavState.GuidedMode.y = (int)((float)drone.TargetLocation.Lng * 1e7);
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;
                }
                CurrentMode = Mode.alongside;
                break;

            case Mode.alongside:
                int a = 0;
                foreach (var drone in Drones)
                {
                    // set drone target position
                    drone.TargetLocation     = GetDronePosition(drone, a);
                    drone.TargetLocation.Alt = TakeOffAlt;
                    a++;

                    drone.TargetVelocity = GetBaseVelocity();

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, drone.TargetVelocity);

                    // apply yaw
                    if (GetBasePosition()?.Heading != null)
                    {
                        drone.SendYaw(GetBasePosition().Heading);
                    }

                    drone.MavState.GuidedMode.x = (int)((float)drone.TargetLocation.Lat * 1e7);
                    drone.MavState.GuidedMode.y = (int)((float)drone.TargetLocation.Lng * 1e7);
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;
                }

                break;

            case Mode.z:
                int d = 0;
                foreach (var drone in Drones)
                {
                    // set drone target position
                    drone.TargetLocation     = GetDronePosition(drone, d);
                    drone.TargetLocation.Alt = TakeOffAlt;
                    d++;

                    drone.TargetVelocity = GetBaseVelocity();

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, drone.TargetVelocity);

                    // apply yaw
                    if (GetBasePosition()?.Heading != null)
                    {
                        drone.SendYaw(GetBasePosition().Heading);
                    }

                    drone.MavState.GuidedMode.x = (int)((float)drone.TargetLocation.Lat * 1e7);
                    drone.MavState.GuidedMode.y = (int)((float)drone.TargetLocation.Lng * 1e7);
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;
                }
                break;

            case Mode.LandAlt:
                var e = 0;
                foreach (var drone in Drones)
                {
                    drone.TargetLocation     = GetDronePosition(drone, e);
                    drone.TargetLocation.Alt = TakeOffAlt + e * 2;

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    Thread.Sleep(200);

                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    e++;
                }
                // check status
                foreach (var drone in Drones)
                {
                    // wait for alt hit
                    while (Math.Abs(drone.MavState.cs.alt - drone.TargetLocation.Alt) > 0.5)
                    {
                        if (!drone.MavState.cs.armed)
                        {
                            break;
                        }
                        Thread.Sleep(200);
                        drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);
                    }

                    Thread.Sleep(200);
                }
                CurrentMode = Mode.Land;
                break;

            case Mode.Land:
                Drone landing = null;
                foreach (var drone in Drones)
                {
                    if (drone.MavState.cs.armed)
                    {
                        landing = drone;
                        var basePosition = GetBasePosition();
                        var basevelocity = GetBaseVelocity();

                        drone.SendYaw(basePosition.Heading);

                        drone.TargetLocation = basePosition;
                        drone.TargetVelocity = basevelocity;

                        if (drone.Location.GetDistance(drone.TargetLocation) < 2)
                        {
                            drone.TargetLocation.Alt = drone.Location.Alt - 2;
                        }
                        else
                        {
                            // same alt - 0.4
                            drone.TargetLocation.Alt = drone.Location.Alt - 0.4;
                        }

                        drone.SendPositionVelocity(drone.TargetLocation, drone.TargetVelocity);

                        // one drone at a time
                        break;
                    }
                }

                int f = 0;
                foreach (var drone in Drones)
                {
                    if (drone == landing)
                    {
                        continue;
                    }

                    // set drone target position
                    drone.TargetLocation = GetDronePosition(drone, f);
                    f++;

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, drone.TargetVelocity);

                    drone.MavState.GuidedMode.x = (int)((float)drone.TargetLocation.Lat * 1e7);
                    drone.MavState.GuidedMode.y = (int)((float)drone.TargetLocation.Lng * 1e7);
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;
                }
                break;
            }
        }
 public void Show()
 {
     GameObject obj = ResourceSystem.Instance.NewObject("UI/Loading") as GameObject;
     view = obj.GetComponent<Loading>();
     view.SetProgress(0);
 }
Ejemplo n.º 8
0
 internal static void HideLoading(Loading loading)
 {
     loading.Visibility = Visibility.Collapsed;
 }
Ejemplo n.º 9
0
        private async void JournalsForm_Load(object sender, EventArgs e)
        {
            await Loading?.Invoke();

            DGV_Journal.Focus();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Loads the surface from bytes. Clears the surface before and uses context source data as a surface bytes source.
        /// </summary>
        /// <remarks>
        /// Assume this method does not throw exceptions but uses return value as a error code.
        /// </remarks>
        /// <returns>True if failed, otherwise false.</returns>
        public bool Load()
        {
            if (_surface != null)
            {
                _surface._isUpdatingBoxTypes++;
            }

            try
            {
                // Prepare
                Clear();

                Loading?.Invoke(this);

                // Load bytes
                var bytes = Context.SurfaceData;
                if (bytes == null)
                {
                    throw new Exception("Failed to load surface data.");
                }

                // Load graph (empty bytes data means empty graph for simplicity when using subgraphs)
                if (bytes.Length > 0)
                {
                    using (var stream = new MemoryStream(bytes))
                        using (var reader = new BinaryReader(stream))
                        {
                            LoadGraph(reader);
                        }
                }

                // Load surface meta
                var meta = _meta.GetEntry(10);
                if (meta.Data != null)
                {
                    Utils.ByteArrayToStructure(meta.Data, out CachedSurfaceMeta);
                }
                else
                {
                    // Reset view
                    CachedSurfaceMeta.ViewCenterPosition = Float2.Zero;
                    CachedSurfaceMeta.Scale = 1.0f;
                }

                // [Deprecated on 04.07.2019] Load surface comments
                var commentsData = _meta.GetEntry(666);
                if (commentsData.Data != null)
                {
                    using (var stream = new MemoryStream(commentsData.Data))
                        using (var reader = new BinaryReader(stream))
                        {
                            var commentsCount = reader.ReadInt32();

                            for (int i = 0; i < commentsCount; i++)
                            {
                                var title  = reader.ReadStr(71);
                                var color  = new Color(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
                                var bounds = new Rectangle(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());

                                var comment = SpawnComment(ref bounds, title, color);
                                if (comment == null)
                                {
                                    throw new InvalidOperationException("Failed to create comment.");
                                }

                                OnControlLoaded(comment);
                            }
                        }
                }

                // Post load
                for (int i = 0; i < RootControl.Children.Count; i++)
                {
                    if (RootControl.Children[i] is SurfaceControl control)
                    {
                        control.OnSurfaceLoaded();
                    }
                }

                RootControl.UnlockChildrenRecursive();

                // Update boxes types for nodes that dependant box types based on incoming connections
                {
                    bool keepUpdating = false;
                    int  updateLimit  = 100;
                    do
                    {
                        for (int i = 0; i < RootControl.Children.Count; i++)
                        {
                            if (RootControl.Children[i] is SurfaceNode node && !node.HasDependentBoxesSetup)
                            {
                                node.UpdateBoxesTypes();
                                keepUpdating = true;
                            }
                        }
                    } while (keepUpdating && updateLimit-- > 0);
                }

                Loaded?.Invoke(this);

                // Clear modification flag
                _isModified = false;
            }
            catch (Exception ex)
            {
                // Error
                Editor.LogWarning("Loading Visject Surface data failed.");
                Editor.LogWarning(ex);
                return(true);
            }
            finally
            {
                if (_surface != null)
                {
                    _surface._isUpdatingBoxTypes--;
                }
            }

            return(false);
        }
Ejemplo n.º 11
0
        public void UpdatePositions()
        {
            if (airmaster == null || groundmaster == null)
            {
                return;
            }

            // get current positions and velocitys
            foreach (var drone in Drones)
            {
                if (drone.Location == null)
                {
                    drone.Location = new PointLatLngAlt();
                }
                drone.Location.Lat = drone.MavState.cs.lat;
                drone.Location.Lng = drone.MavState.cs.lng;
                drone.Location.Alt = drone.MavState.cs.alt;
                if (drone.Velocity == null)
                {
                    drone.Velocity = new Vector3();
                }
                drone.Velocity.x = Math.Cos(drone.MavState.cs.groundcourse * deg2rad) * drone.MavState.cs.groundspeed;
                drone.Velocity.y = Math.Sin(drone.MavState.cs.groundcourse * deg2rad) * drone.MavState.cs.groundspeed;
                drone.Velocity.z = drone.MavState.cs.verticalspeed;

                // set default target as ground reference
                drone.TargetVelocity = GroundMasterDrone.Velocity;
            }


            // generate a new list including the airmaster first
            List <Drone> newlist = new List <Drone>();

            newlist.Add(AirMasterDrone);
            // get list to remove airmaster and groundmaster
            List <Drone> newlist2 = new List <Drone>();

            newlist2.AddRange(Drones);
            newlist2.Remove(AirMasterDrone);
            newlist2.Remove(GroundMasterDrone);
            // add modified list back
            newlist.AddRange(newlist2);

            // collision check
            foreach (var drone1 in newlist)
            {
                // ground drone is not part of the check
                if (drone1 == GroundMasterDrone)
                {
                    continue;
                }

                if (!drone1.MavState.cs.armed)
                {
                    continue;
                }

                foreach (var drone2 in newlist)
                {
                    if (drone1 == drone2)
                    {
                        continue;
                    }

                    if (drone2 == GroundMasterDrone)
                    {
                        continue;
                    }

                    if (!drone2.MavState.cs.armed)
                    {
                        continue;
                    }

                    // check how close they are based on current position
                    if (drone1.Location.GetDistance(drone2.Location) < Seperation / 2)
                    {
                        // check if the alt seperation is less than 1m
                        if (Math.Abs(drone1.Location.Alt - drone2.Location.Alt) < 1)
                        {
                            // check which is higher already, and seperate further
                            if (drone1.Location.Alt > drone2.Location.Alt)
                            {
                                drone1.SendPositionVelocity(new PointLatLngAlt(drone1.Location)
                                {
                                    Alt = drone1.Location.Alt + Takeoff_Land_alt_sep
                                }, Vector3.Zero);
                                return;
                            }
                            else
                            {
                                drone2.SendPositionVelocity(new PointLatLngAlt(drone2.Location)
                                {
                                    Alt = drone2.Location.Alt + Takeoff_Land_alt_sep
                                }, Vector3.Zero);
                                return;
                            }
                        }
                    }

                    // check how close they are based on a 1 second projection
                    if (drone1.ProjectedLocation.GetDistance(drone2.ProjectedLocation) < Seperation / 2)
                    {
                        // check if they are heading the same direction
                        if (((Math.Abs(drone1.Heading - drone2.Heading) + 360) % 360) < 45 && drone1.MavState.cs.groundspeed > 0.5)
                        {
                            // check if the alt seperation is less than 1m
                            if (Math.Abs(drone1.Location.Alt - drone2.Location.Alt) < 1)
                            {
                                // they are heading within 45 degrees of each other
                                // return here to let them settle themselfs, as the target position will be correct
                                // ie the ground refrence is moving faster than the drones can maintain
                                Console.WriteLine("1 drone, to close");
                                drone1.SendPositionVelocity(drone1.Location, Vector3.Zero);
                                return;
                            }
                        }

                        // check if the are heading are at each other
                        if (((Math.Abs(drone1.Heading - drone2.Heading) + 360) % 360) > 135)
                        {
                            // check if the alt seperation is less than 1m
                            if (Math.Abs(drone1.Location.Alt - drone2.Location.Alt) < 1)
                            {
                                // stop the drones
                                drone1.SendPositionVelocity(new PointLatLngAlt(drone1.Location)
                                {
                                    Alt = drone1.Location.Alt + Takeoff_Land_alt_sep
                                }, Vector3.Zero);
                                drone2.SendPositionVelocity(drone2.Location, Vector3.Zero);
                                Console.WriteLine("2 stopping drone, to close and heading towards each other");
                                return;
                            }
                        }
                    }
                }
            }

            // convert wp path to 0.1m path increments
            var path = Path.GeneratePath(AirMasterDrone.MavState);

            if (path.Count == 0)
            {
                return;
            }

            // update the graph to show location along path
            if (pathcount != path.Count)
            {
                path_to_fly.Clear();
                double inc = 0;
                path.ForEach(i =>
                {
                    path_to_fly.Add(inc, i.Alt);
                    inc += 0.1;
                });
            }
            pathcount = path.Count;

            foreach (var drone in Drones)
            {
                var locs = GetLocations(path, drone.Location, 0, 0);
                if (locs.Count == 0)
                {
                    continue;
                }
                drone.PathIndex = path.IndexOf(locs[0]);
            }


            switch (CurrentMode)
            {
            case Mode.idle:
                CurrentMode = Mode.takeoff;
                // request positon at 5hz
                foreach (var drone in Drones)
                {
                    var MAV = drone.MavState;

                    MAV.parent.requestDatastream(MAVLink.MAV_DATA_STREAM.POSITION, 5, MAV.sysid, MAV.compid);
                    MAV.cs.rateposition = 5;

                    drone.takeoffdone = false;

                    if (drone != GroundMasterDrone)
                    {
                        try
                        {
                            // get param
                            MAV.parent.GetParam(MAV.sysid, MAV.compid, "RTL_ALT");
                            // set param
                            MAV.parent.setParam(MAV.sysid, MAV.compid, "RTL_ALT", 0);     // cms - rtl at current alt
                        }
                        catch
                        {
                        }
                        try
                        {
                            // get param
                            MAV.parent.GetParam(MAV.sysid, MAV.compid, "WPNAV_ACCEL");
                            // set param to default 100cm/s
                            MAV.parent.setParam(MAV.sysid, MAV.compid, "WPNAV_ACCEL", 100);
                        }
                        catch
                        {
                        }
                    }
                }
                break;

            case Mode.takeoff:
                // newposition index
                int a = 0;
                // calc new positions based on lead and seperation
                var lead = Drones.Count * Seperation;
                // get locations based on position of the airmaster with a negative lead
                var newpositions = GetLocations(path, AirMasterDrone.MavState.cs.HomeLocation, lead, Seperation);
                if (newpositions.Count == 0)
                {
                    return;
                }

                // from here airmaster will be first, all other drones will be in order they will fly in (could sort based on sysid?)
                foreach (var drone in newlist)
                {
                    var MAV = drone.MavState;
                    try
                    {
                        // guided mode
                        if (!MAV.cs.mode.ToLower().Equals("guided"))
                        {
                            MAV.parent.setMode(MAV.sysid, MAV.compid, "GUIDED");
                        }
                        // arm
                        if (!MAV.cs.armed)
                        {
                            if (!MAV.parent.doARM(MAV.sysid, MAV.compid, true))
                            {
                                return;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        Loading.ShowLoading("Communication with one of the drones is failing\n" + ex.ToString());

                        return;
                    }
                    // set drone target position
                    drone.TargetLocation = newpositions[a];
                    // setup seperation (0=0,1=1,2=2,3=0)
                    drone.TargetLocation.Alt += Takeoff_Land_alt_sep * (a % 3);

                    float takeoffalt = (float)drone.TargetLocation.Alt;

                    try
                    {
                        // takeoff
                        if (MAV.cs.alt < (takeoffalt - 0.5) && !drone.takeoffdone)
                        {
                            if (MAV.parent.doCommand(MAV.sysid, MAV.compid, MAVLink.MAV_CMD.TAKEOFF, 0, 0, 0, 0, 0,
                                                     0, takeoffalt))
                            {
                                drone.takeoffdone = true;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        log.Error(ex);
                        Loading.ShowLoading("Communication with one of the drones is failing\n" + ex.ToString());

                        return;
                    }

                    drone.MavState.GuidedMode.x = 0;
                    drone.MavState.GuidedMode.y = 0;
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    // wait for takeoff
                    if (MAV.cs.alt < (takeoffalt - 0.5))
                    {
                        System.Threading.Thread.Sleep(100);
                        // check we are still armed
                        if (!MAV.cs.armed)
                        {
                            return;
                        }

                        a++;
                        // move on to next drone
                        continue;
                    }

                    // we should only get here once takeoff alt has been archived by this drone.

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    drone.MavState.GuidedMode.x = (float)drone.TargetLocation.Lat;
                    drone.MavState.GuidedMode.y = (float)drone.TargetLocation.Lng;
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    // check how far off target we are
                    if (drone.TargetLocation.GetDistance(drone.Location) > Seperation)
                    {
                        // only return if this is the third drone without seperation
                        if (a % 3 == 2)
                        {
                            //if we are off target, we have already sent the command to this drone,
                            //but skip the one behind it untill this one is within the seperation range
                            return;
                        }
                    }

                    a++;
                }
                // wait for all to get within seperation distance
                foreach (var drone in newlist)
                {
                    // check how far off target we are
                    if (drone.TargetLocation.GetDistance(drone.Location) > Seperation)
                    {
                        // position control
                        drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                        //if we are off target, we have already sent the command to this drone,
                        //but skip the one behind it untill this one is within the seperation range
                        return;
                    }
                }
                CurrentMode = Mode.flytouser;
                break;

            case Mode.flytouser:
                // get locations based on position of the airmaster
                var newpositions2 = GetLocations(path, AirMasterDrone.Location, Seperation, Seperation);
                if (newpositions2.Count == 0)
                {
                    // check if we are within 5m of the end of our flightplan
                    if (path.Last().GetDistance(AirMasterDrone.Location) < Seperation)
                    {
                        CurrentMode = Mode.RTH;
                    }
                    return;
                }

                int b = 0;
                foreach (var drone in newlist)
                {
                    if (newpositions2.Count == b)
                    {
                        break;
                    }
                    // set drone target position
                    drone.TargetLocation = newpositions2[b];

                    if (AltInterleave)
                    {
                        drone.TargetLocation.Alt += Takeoff_Land_alt_sep * (b % 2);
                    }

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    drone.MavState.GuidedMode.x = (float)drone.TargetLocation.Lat;
                    drone.MavState.GuidedMode.y = (float)drone.TargetLocation.Lng;
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    b++;
                }

                // this is the same as used in the next step, to prevent a jump
                var newpositionsfollowuser = GetLocations(path, GroundMasterDrone.Location, Lead, Seperation);
                // check how far off target we are
                if (newpositionsfollowuser.Count > 0 && AirMasterDrone.Location.GetDistance(newpositionsfollowuser.First()) < Seperation)
                {
                    // update speed as we are changing to a high dynamic mode
                    foreach (var drone in newlist)
                    {
                        if (drone == GroundMasterDrone)
                        {
                            continue;
                        }
                        var MAV = drone.MavState;
                        // update to faster speed
                        MAV.parent.setParam(MAV.sysid, MAV.compid, "WPNAV_ACCEL", (float)WPNAV_ACCEL * 100.0f);

                        MAV.parent.setMode(MAV.sysid, MAV.compid, "GUIDED");
                    }
                    //if we are off target, we have already sent the command to this drone,
                    //but skip the one behind it untill this one is within the seperation range
                    CurrentMode = Mode.followuser;
                    return;
                }

                break;

            case Mode.followuser:
                // calc new positions based on lead and seperation
                List <PointLatLngAlt> newpositions3 = new List <PointLatLngAlt>();
                if (V)
                {
                    newpositions3 = GetLocationsV(path, GroundMasterDrone.Location, Lead, Seperation);
                }
                else
                {
                    newpositions3 = GetLocations(path, GroundMasterDrone.Location, Lead, Seperation);
                }

                if (newpositions3.Count == 0)
                {
                    return;
                }

                //  check if the user is offpath
                var wps = new List <PointLatLngAlt>();
                AirMasterDrone.MavState.wps.Values.ForEach(i => { wps.Add(new PointLatLngAlt((Locationwp)i)); });

                if (GetOffPathDistance(wps, GroundMasterDrone.Location) > OffPathTrigger)
                {
                    CurrentMode = Mode.RTH;
                }

                int c = 0;
                // send position and velocity
                foreach (var drone in newlist)
                {
                    if (drone.MavState == groundmaster)
                    {
                        continue;
                    }

                    if (c > (newpositions3.Count - 1))
                    {
                        break;
                    }

                    drone.TargetLocation = newpositions3[c];

                    if (AltInterleave)
                    {
                        drone.TargetLocation.Alt += Takeoff_Land_alt_sep * (c % 2);
                    }

                    // spline control
                    drone.SendPositionVelocity(drone.TargetLocation, drone.TargetVelocity / 3);

                    drone.MavState.GuidedMode.x = (float)drone.TargetLocation.Lat;
                    drone.MavState.GuidedMode.y = (float)drone.TargetLocation.Lng;
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    // vel only
                    //drone.SendVelocity(drone.TargetVelocity);

                    // check how far off target we are
                    if (drone.TargetLocation.GetDistance(drone.Location) > Seperation * 2)
                    {
                        //if we are off target, we have already sent the command to this drone,
                        //but skip the one behind it untill this one is within the seperation range

                        //break;
                    }

                    c++;
                }
                break;

            case Mode.RTH:
                // get locations based on position of the airmaster
                var newpositions4 = GetLocations(path, AirMasterDrone.Location, Seperation, Seperation);
                if (newpositions4.Count == 0)
                {
                    if (AirMasterDrone.Location.GetDistance(path.Last()) < Seperation)
                    {
                        CurrentMode = Mode.LandAlt;
                    }
                    return;
                }

                int d = 0;
                foreach (var drone in newlist)
                {
                    if (d > (newpositions4.Count - 1))
                    {
                        break;
                    }

                    try
                    {
                        var MAV = drone.MavState;
                        // set param to default 100cm/s
                        if (MAV.param["WPNAV_ACCEL"].Value != 100)
                        {
                            MAV.parent.setParam(MAV.sysid, MAV.compid, "WPNAV_ACCEL", 100);
                        }
                    }
                    catch
                    {
                    }

                    // set drone target position
                    drone.TargetLocation = newpositions4[d];

                    // used in next step
                    double prevalt = drone.TargetLocation.Alt;

                    if (AltInterleave)
                    {
                        drone.TargetLocation.Alt += Takeoff_Land_alt_sep * (d % 2);
                    }

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    drone.MavState.GuidedMode.x = (float)drone.TargetLocation.Lat;
                    drone.MavState.GuidedMode.y = (float)drone.TargetLocation.Lng;
                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    // used for next step
                    drone.TargetLocation.Alt = prevalt;

                    d++;
                }
                break;

            case Mode.LandAlt:
                int e = 0;
                foreach (var drone in newlist)
                {
                    drone.TargetLocation.Alt += Takeoff_Land_alt_sep * e;

                    try
                    {
                        var MAV = drone.MavState;
                        // set param to default 100cm/s
                        if (MAV.param["WPNAV_ACCEL"].Value != 100)
                        {
                            MAV.parent.setParam(MAV.sysid, MAV.compid, "WPNAV_ACCEL", 100);
                        }
                    }
                    catch
                    {
                    }

                    // position control
                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    drone.MavState.GuidedMode.z = (float)drone.TargetLocation.Alt;

                    System.Threading.Thread.Sleep(200);

                    drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);

                    e++;
                }
                // check status
                foreach (var drone in newlist)
                {
                    // wait for alt hit
                    while (drone.MavState.cs.alt < (drone.TargetLocation.Alt - 0.5))
                    {
                        if (!drone.MavState.cs.armed)
                        {
                            break;
                        }
                        System.Threading.Thread.Sleep(200);
                        drone.SendPositionVelocity(drone.TargetLocation, Vector3.Zero);
                    }

                    System.Threading.Thread.Sleep(200);

                    log.Info(drone.MavState.sysid + " " + drone.MavState.cs.alt + " at alt " + drone.TargetLocation.Alt);

                    // set mode rtl
                    drone.MavState.parent.setMode(drone.MavState.sysid, drone.MavState.compid, "RTL");
                }
                CurrentMode = Mode.Land;
                break;

            case Mode.Land:
                Drone closest = new Drone()
                {
                    Location = PointLatLngAlt.Zero
                };
                var lastpnt = path.Last();
                foreach (var drone in newlist)
                {
                    if (!drone.MavState.cs.armed)
                    {
                        continue;
                    }

                    // low flying filter, move onto next drone
                    if (drone.MavState.cs.alt < lastpnt.Alt - 1)
                    {
                        continue;
                    }

                    if (AirMasterDrone.MavState.cs.HomeLocation.GetDistance(drone.Location) < AirMasterDrone.MavState.cs.HomeLocation.GetDistance(closest.Location))
                    {
                        closest = drone;
                    }
                }

                if (closest.MavState != null && !closest.MavState.cs.mode.ToLower().Equals("rtl"))
                {
                    closest.MavState.parent.setMode(closest.MavState.sysid, closest.MavState.compid, "RTL");
                }
                break;
            }
        }
Ejemplo n.º 12
0
 private void Awake()
 {
     Singleton = this;
 }
 private async void view_Loaded()
 {
     this.Dispatcher.Invoke(new Action(() => view.BestFitColumns()));
     ServicesVM.SetStartValue();
     await Loading.Hide();
 }
Ejemplo n.º 14
0
 private void Start()
 {
     loading = LoadingObject.GetComponent <Loading>();
 }
        protected internal async void ScheduleLoad()
        {
            await Loading.Show();

            await ViewLoad(new Func <UserControl>(() => new Views.Schedule.Schedule()), new Views.Global.StockVerticalMenuItem());
        }
        protected virtual void OnLoading()
        {
            Loading?.Invoke(this, null);

            ApplyCompiledBindings();
        }
Ejemplo n.º 17
0
        public static void Execute(string host, Handler h, bool makelive)
        {
            bool truncated = false, numtext = false, dateoob = false;

            object[,] cids = new object[Useful.EXCEL_MAX_ROWS, 1];
            DateTime timestamp;
            Stream   input;
            int      max;

            #region External API Calls

            if (!new Api.GetNumRecords(host, h).ExecuteLoggedIn(out max) ||
                !new Api.GetTimestamp(host, h.dataSourceId).ExecuteLoggedIn(out timestamp))
            {
                Useful.Error(Resources.UnableToGetRemoteDataAmbiguous, Resources.Error);
                return;
            }

            try
            {
                new Api.Handler(host, h, maxrows: max).ExecuteLoggedIn(out input);
            }
            catch
            {
                Useful.Error(Resources.UnableToContinue, Resources.Error);
                return;
            }

            #endregion
            #region Null/Empty Workbook/Worksheet Checks

            if (Useful.ActiveWorkbook is null)
            {
                // Adding a workbook implies adding a worksheet
                Useful.Workbooks.Add();
            }
            else if (!Useful.ActiveSheet.UsedRange.IsEmpty())
            {
                // Adding a worksheet gives that worksheet focus
                Useful.Worksheets.Add();
            }

            #endregion

            void FinalizeWorksheet(bool addANewWorksheet = true)
            {
                // This method cleans out the system columns we pulled down and sets up
                // information for live worksheet functionality if desired. Optionally
                // creates a new worksheet (Used in the rest of the import process).
                cids = Useful.ActiveSheet.CleanSystemColumns();
                if (makelive)
                {
                    string cid_ws_name = Convert.ToBase64String(Guid.NewGuid().ToByteArray());
                    Useful.ActiveSheet.MarkSynchronized(h, host, timestamp, cid_ws_name);
                    Useful.Worksheets.Add();
                    Useful.ActiveSheet.Cell(1, 1).Resize[cids.GetLength(0), cids.GetLength(1)].Value2 = cids;
                    Useful.ActiveSheet.Name    = cid_ws_name;
                    Useful.ActiveSheet.Visible = XlSheetVisibility.xlSheetVeryHidden;
                }
                if (addANewWorksheet)
                {
                    Useful.Worksheets.Add();
                }
            }

            Underway = true;
            using (Loading progress = new Loading(max))
                using (TextFieldParser parser = new TextFieldParser(input))
                    using (new ExcelNoScreenUpdate())
                    {
                        parser.TextFieldType = FieldType.Delimited;
                        parser.SetDelimiters(",");
                        progress.Show(new ParentHwnd(Useful.Hwnd));

                        string[] headers = parser.ReadFields();

                        if (headers.Length > Useful.EXCEL_MAX_COLS)
                        {
                            throw new InternalBufferOverflowException(string.Format(Resources.ErrTooManyColumns, Useful.EXCEL_MAX_COLS));
                        }

                        while (parser.HasMoreData())
                        {
                            if (!Underway)
                            {
                                return;
                            }
                            object[,] objs = new object[Useful.EXCEL_MAX_ROWS / DIVISION_FACTOR, headers.Length];

                            for (int i = 0; i < headers.Length; i++)
                            {
                                objs[0, i] = headers[i];
                            }

                            int row;
                            for (row = 1; parser.HasMoreData() && row < Useful.EXCEL_MAX_ROWS; row++, progress.Value++)
                            {
                                if (!Underway)
                                {
                                    return;
                                }

                                string[] data = parser.ReadFields();

                                if (row % (Useful.EXCEL_MAX_ROWS / (DIVISION_FACTOR * 4)) == 0)
                                {
                                    System.Windows.Forms.Application.DoEvents();
                                }

                                if (row % (Useful.EXCEL_MAX_ROWS / DIVISION_FACTOR) == 0)
                                {
                                    Useful.ActiveSheet.Cell(1 + row - (Useful.EXCEL_MAX_ROWS / DIVISION_FACTOR), 1).Resize[objs.GetUpperBound(0) + 1, objs.GetUpperBound(1) + 1].Value2 = objs;
                                }

                                for (int col = 0; col < data.Length; col++)                // [string -> *] type conversion
                                {
                                    if (!Underway)
                                    {
                                        return;
                                    }

                                    object InterpretType(string tgt)
                                    {
                                        if (long.TryParse(tgt, out long _long) && headers[col] != "_version_")
                                        {
                                            if (_long > Useful.EXCEL_MAX_INT_AS_DOUBLE)
                                            {
                                                numtext = true;
                                                tgt     = '\'' + tgt;

                                                if (tgt.Length > Useful.EXCEL_MAX_STR_LEN)
                                                {
                                                    truncated = true;
                                                }

                                                return(tgt);
                                            }
                                            return(_long);
                                        }
                                        else if (double.TryParse(tgt, out double _double))
                                        {
                                            return(_double);
                                        }
                                        else
                                        {
                                            if (tgt.StartsWith("="))
                                            {
                                                tgt = '\'' + tgt;
                                            }

                                            if (tgt.Length > Useful.EXCEL_MAX_STR_LEN)
                                            {
                                                truncated = true;
                                            }

                                            return(tgt);
                                        }
                                    }

                                    objs[row % (Useful.EXCEL_MAX_ROWS / DIVISION_FACTOR), col] = InterpretType(data[col]);
                                }
                            }

                            Useful.ActiveSheet.Cell(row < (Useful.EXCEL_MAX_ROWS / DIVISION_FACTOR) ? 1 : 1 + row - (Useful.EXCEL_MAX_ROWS / DIVISION_FACTOR), 1).Resize[objs.GetUpperBound(0) + 1, objs.GetUpperBound(1) + 1].Value2 = objs;
                            FinalizeWorksheet(parser.HasMoreData());
                        }
                    }

            Underway = false;
            if (truncated)
            {
                Useful.Error(Resources.TruncationWarning, Resources.TruncationWarningCaption, MessageBoxIcon.Information);
            }
            if (numtext)
            {
                Useful.Error(Resources.NumTextWarning, Resources.NumTextWarningCaption, MessageBoxIcon.Information);
            }
            if (dateoob)
            {
                Useful.Error(Resources.DateOOBWarning, Resources.DateOOBWarningCaption, MessageBoxIcon.Information);
            }
        }
Ejemplo n.º 18
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            string username = textBox1.Text.ToString();
            string password = textBox2.Text.ToString();

            if (username == "" || username == "Username")
            {
                MessageBox.Show("Username Harus Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (password == "" || password == "Password")
            {
                MessageBox.Show("Password Harus Diisi.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(this.setting.IPAddressServer))
            {
                MessageBox.Show("Invalid IP Address Server.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(this.setting.IPAddressLiveCamera))
            {
                MessageBox.Show("Invalid IP Address Live Camera.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            // validate TID & Settlement MID for further transaction
            if (string.IsNullOrEmpty(this.tmid.TID))
            {
                MessageBox.Show("Invalid 'TID' value.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
            if (string.IsNullOrEmpty(this.tmid.MID))
            {
                MessageBox.Show("Invalid 'Settlement MID' value.", "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            using (Loading loading = new Loading(SignIn))
            {
                loading.ShowDialog(this);

                // check local database connection
                DBConnect database = new DBConnect();
                if (!database.CheckMySQLConnection())
                {
                    MessageBox.Show("Error : Can't Establish Connection to Local Database.\nPlease setup properly.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // check reader connection
                BNI bni = new BNI();
                if (!bni.CheckReaderConn())
                {
                    MessageBox.Show("Error : Contactless Reader not available.\nPlease plug it and then try again.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                // remember me feature
                if (checkBox1.Checked)
                {
                    Properties.Settings.Default.Username   = username;
                    Properties.Settings.Default.Password   = password;
                    Properties.Settings.Default.RememberMe = "yes";
                }
                else
                {
                    Properties.Settings.Default.Username   = username;
                    Properties.Settings.Default.Password   = "";
                    Properties.Settings.Default.RememberMe = "no";
                }
                Properties.Settings.Default.Save();

                string ip_address_server = "http://" + this.setting.IPAddressServer;

                // pull some data from server e.g. Vehicle Types
                string       APIPullData  = Properties.Resources.RequestVehicleTypeAPIURL;
                RESTAPI      pull         = new RESTAPI();
                DataResponse receivedData = pull.API_Get(ip_address_server, APIPullData);
                if (receivedData != null)
                {
                    switch (receivedData.Status)
                    {
                    case 206:
                        JArray  receivedVehicleTypes = receivedData.Data;
                        JObject vehicleTypes         = new JObject();
                        vehicleTypes.Add(new JProperty("VehicleTypes", receivedVehicleTypes));

                        // write into a file called 'master-data.json'
                        try
                        {
                            string savedDir = tk.GetApplicationExecutableDirectoryName() + "\\src\\master-data.json";
                            string json     = JsonConvert.SerializeObject(vehicleTypes);
                            System.IO.File.WriteAllText(@savedDir, json);
                            //MessageBox.Show("Pull Master Data is Success.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                            MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        break;

                    default:
                        MessageBox.Show(receivedData.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Error : Can't establish connection to server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }

                // send data API
                var     APIUrl = Properties.Resources.LoginAPIURL;
                JObject param  = new JObject();
                param["username"] = username;
                param["password"] = password;
                var sent_param = JsonConvert.SerializeObject(param);

                RESTAPI      api      = new RESTAPI();
                DataResponse response = api.API_Post(ip_address_server, APIUrl, sent_param);
                if (response != null)
                {
                    switch (response.Status)
                    {
                    case 201:
                        //MessageBox.Show(response.Message, "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
                        try
                        {
                            this.cashier = new Cashier(this);
                            this.cashier.Show();
                            Hide();
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show("Error : Can't Connect to Webcam.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                            return;
                        }
                        break;

                    default:
                        MessageBox.Show(response.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        break;
                    }
                }
                else
                {
                    MessageBox.Show("Error : Can't establish connection to server.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
            }
        }
Ejemplo n.º 19
0
 /// <summary>
 /// Shows the main window</summary>
 public void ShowMainWindow()
 {
     Loading.Raise(this, EventArgs.Empty);
     MainWindow.Show();
 }
Ejemplo n.º 20
0
 private void GDAL_OnProgress(double percent, string message)
 {
     Loading.ShowLoading((percent).ToString("0.0%") + " " + message, this);
 }
        public static string CheckLogFile(string FileName)
        {
            if (Program.WindowsStoreApp)
            {
                CustomMessageBox.Show(Strings.Not_available_when_used_as_a_windows_store_app);
                return("");
            }

            var dir = Settings.GetDataDirectory() + "LogAnalyzer" +
                      Path.DirectorySeparatorChar;

            var runner = dir + "runner.exe";

            var zip = dir + "LogAnalyzer.zip";

            if (!Directory.Exists(dir))
            {
                Directory.CreateDirectory(dir);
            }

            //if (!File.Exists(runner))
            {
                Loading.ShowLoading("Downloading LogAnalyzer");
                bool gotit = false;
                if (Environment.Is64BitOperatingSystem)
                {
                    gotit = Download.getFilefromNet(
                        "http://firmware.ardupilot.org/Tools/MissionPlanner/LogAnalyzer/LogAnalyzer64.zip",
                        zip);
                }
                else
                {
                    gotit = Download.getFilefromNet(
                        "http://firmware.ardupilot.org/Tools/MissionPlanner/LogAnalyzer/LogAnalyzer.zip",
                        zip);
                }

                // download zip
                if (gotit)
                {
                    Loading.ShowLoading("Extracting zip file");
                    // extract zip
                    FastZip fzip = new FastZip();
                    fzip.ExtractZip(zip, dir, "");
                }
                else
                {
                    if (!File.Exists(runner))
                    {
                        CustomMessageBox.Show("Failed to download LogAnalyzer");
                        return("");
                    }
                }
            }

            if (!File.Exists(runner))
            {
                CustomMessageBox.Show("Failed to download LogAnalyzer");
                return("");
            }

            var sb = new StringBuilder();

            Process P = new Process();

            P.StartInfo.FileName  = runner;
            P.StartInfo.Arguments = @" -x """ + FileName + @".xml"" -s """ + FileName + @"""";

            P.StartInfo.UseShellExecute  = false;
            P.StartInfo.WorkingDirectory = dir;

            P.StartInfo.RedirectStandardOutput = true;
            P.StartInfo.RedirectStandardError  = true;

            P.OutputDataReceived += (sender, args) => sb.AppendLine(args.Data);
            P.ErrorDataReceived  += (sender, args) => sb.AppendLine(args.Data);

            try
            {
                Loading.ShowLoading("Running LogAnalyzer");

                P.Start();

                P.BeginOutputReadLine();
                P.BeginErrorReadLine();

                // until we are done
                P.WaitForExit();

                log.Info(sb.ToString());
            }
            catch
            {
                CustomMessageBox.Show("Failed to start LogAnalyzer");
            }

            Loading.Close();

            return(FileName + ".xml");
        }
Ejemplo n.º 22
0
 void Start()
 {
     load            = new Loading();
     anim            = GetComponent <Animator>();
     clockfield.text = "09:00";
 }
Ejemplo n.º 23
0
 void Start()
 {
     Debug.Log("Menu OK");
     PhotonNetwork.JoinOrCreateRoom("TestrAena", new RoomOptions(), TypedLobby.Default);
     Loading.Load(LoadingScane.Game);
 }
Ejemplo n.º 24
0
 // Start is called before the first frame update
 void Start()
 {
     loadCheck = GameObject.FindObjectOfType <Loading>();
 }
Ejemplo n.º 25
0
 /// <summary>
 /// The loading options control the appearance of the loading screen that covers the plot area on chart operations.
 /// This screen only appears after an explicit call to chart.showLoading(). It is a utility for developers to
 /// communicate to the end user that something is going on, for example while retrieving new data via an XHR connection.
 /// The "Loading..." text itself is not part of this configuration object, but part of the lang object.
 /// </summary>
 /// <param name="loading"></param>
 /// <returns></returns>
 public Highcharts SetLoading(Loading loading)
 {
     _Loading = loading;
     return(this);
 }
Ejemplo n.º 26
0
 void OnConnectedToMaster()
 {
     Loading.Load(LoadingScene.Menu);
 }
Ejemplo n.º 27
0
 public static void HideLoading(this Dispatcher dp, Loading loading)
 {
     dp.BeginInvoke(DispatcherPriority.Normal, new Action(() => { HideLoading(loading); }));
 }
Ejemplo n.º 28
0
        // Runs the given Action on the background worker
        private void runTaskWithLoadingScreen(string loadingMessage, string loadingTitle, Action work)
        {

            // Create variables used in loading (maz load value, background worker, and loading screen)
                int maxLoadValue = mazeWidth * mazeHeight;
                worker = new BackgroundWorker();
                loading = new Loading();

            // Set the background worker to run the given method
                worker.DoWork += (sender, e) => work();

            // Se the background worker to return the cursor and close the loading screen when it's done
                worker.RunWorkerCompleted += (sender, e) =>
                {
                    loading.Close();
                    Mouse.OverrideCursor = null;
                };

            // Set the background worker to increment the loading value and update time remaining on update
                    worker.ProgressChanged += (sender, e) =>
                    {
                        loading.LoadingValue+=e.ProgressPercentage/100.0;
                        if ((int)loading.LoadingValue % 200 == 0)
                        {
                            if ((int)loading.LoadingValue / 200 % 3 == 0)
                                loading.LoadingMessage = loadingMessage + "..";
                            else if ((int)loading.LoadingValue / 200 % 3 == 1)
                                loading.LoadingMessage = loadingMessage + "...";
                            else if ((int)loading.LoadingValue / 200 % 3 == 2)
                                loading.LoadingMessage = loadingMessage + ".";
                        }
                    };
                        worker.WorkerReportsProgress = true;


                        // Show the loading screen, change the cursour, and run the background worker
                        loading.Show(this, loadingMessage+"...", loadingTitle, maxLoadValue);
                        Mouse.OverrideCursor = Cursors.Wait;
                        worker.RunWorkerAsync();

                    }
Ejemplo n.º 29
0
        private async void Start()
        {
            await SelectQuery();

            await Loading.Hide();
        }
Ejemplo n.º 30
0
        /// <summary>
        ///     菜单项“启动模块”(扫描)单击时的事件。
        /// </summary>
        /// <param name="sender">触发事件的控件对象。</param>
        /// <param name="e">事件的参数。</param>
        private void 启动扫描模块ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 判断工作模式
            if (启动扫描模块ToolStripMenuItem.Text == "启动模块")
            {
                if (!StartupModels(new[] { Scanner }))
                {
                    MessageBox.Show("模块未能成功初始化,请检查。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else if (Scanner.CurDevName != "")
                {
                    MessageBox.Show("模块已成功设置。", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    启动所有模块ToolStripMenuItem.Text  = "重启所有模块";
                    启动扫描模块ToolStripMenuItem.Text  = "停止模块";
                    扫描主机ToolStripMenuItem.Enabled = true;
                    侦测主机ToolStripMenuItem.Enabled = true;
                }
            }
            else
            {
                // 创建载入界面
                var task = new Thread(stop => {
                    Scanner.Reset();
                    Scanner.CurDevName = "";
                })
                {
                    Name = RegisteredThreadName.StopScanner.ToString()
                };
                MessagePipe.SendInMessage(new KeyValuePair <Message, Thread>(Message.TaskIn, task));
                var loading = new Loading("正在停止,请稍候", task);
                loading.ShowDialog();

                // 等待结果
                new WaitTimeoutChecker(30000).ThreadSleep(500, () => {
                    var msg = MessagePipe.GetNextOutMessage(task);
                    switch (msg)
                    {
                    case Message.NoAvailableMessage:
                        return(true);

                    case Message.TaskOut:
                        return(false);

                    default:
                        throw new Exception($"无效的消息类型:{msg}");
                    }
                });

                // 模块已停止
                MessagePipe.ClearAllMessage(task);
                MessageBox.Show("模块已停止。", "消息", MessageBoxButtons.OK, MessageBoxIcon.Information);
                启动扫描模块ToolStripMenuItem.Text  = "启动模块";
                扫描主机ToolStripMenuItem.Enabled = false;
                侦测主机ToolStripMenuItem.Enabled = false;
                HostList.Rows.Clear();

                // TODO:新增模块时请更新此处的代码
                if (启动毒化模块ToolStripMenuItem.Text == "启动模块" &&
                    启动监视模块ToolStripMenuItem.Text == "启动模块")
                {
                    启动所有模块ToolStripMenuItem.Text = "启动所有模块";
                }
            }
        }
Ejemplo n.º 31
0
        private async void EditingWorkForm_Load(object sender, EventArgs e)
        {
            await Loading?.Invoke();

            LL_Work.Focus();
        }
Ejemplo n.º 32
0
        public void Save()
        {
            int     result  = 0;
            decimal result2 = 0;

            hotForm.myConfig.userid = MyUserInfo.currentUserId;
            ConfigSendTimeModel cfgTime = string.IsNullOrEmpty(hotForm.myConfig.send_time_config) ? new ConfigSendTimeModel() : JsonConvert.DeserializeObject <ConfigSendTimeModel>(hotForm.myConfig.send_time_config);

            cfgTime = cfgTime == null ? new ConfigSendTimeModel() : cfgTime;


            //淘宝API
            cfgTime.appkey    = txtTaoAppKey.Text;
            cfgTime.appsecret = txtTaoAppSecret.Text;

            //发视频
            cfgTime.enable_sendvideo = ckbSendVideo.Checked;

            //通知邮箱
            //cfgTime.notity_email = txtNotifyMobile.Text;


            //商品间隔
            int.TryParse(txtgoodsinterval.Text, out result);
            cfgTime.goodsinterval = result < 0 ? 35 : result;

            //操作间隔
            decimal result3 = 0;

            decimal.TryParse(txthandleInterval.Text, out result3);
            cfgTime.hdInterval = result3 == 0 ? 1 : result3;

            //任务间隔
            int.TryParse(txtTaskInterval.Text, out result);
            cfgTime.taskinterval = result == 0 ? 30 : result;
            //图文顺序
            cfgTime.imagetextsort = rbTwSort.Checked ? 0 : 1;

            //发送模式
            cfgTime.sendmode = rdSendWindows.Checked ? 0 : 1;

            MyUserInfo.sendmode = cfgTime.sendmode;

            //过滤条件
            ConfigWhereModel cfgWhere = string.IsNullOrEmpty(hotForm.myConfig.where_config) ? new ConfigWhereModel() : JsonConvert.DeserializeObject <ConfigWhereModel>(hotForm.myConfig.where_config);

            cfgWhere = cfgWhere == null ? new ConfigWhereModel() : cfgWhere;

            //优惠券过期
            cfgWhere.minCouponDateDayCountEnable = ckbminCouponDayCount.Checked ? 1 : 0;
            int.TryParse(txtminCouponDateDayCount.Text, out result);
            cfgWhere.minCouponDateDayCount = result;

            //优惠券数量
            cfgWhere.minCouponAmountEnable = ckbCoupon.Checked ? 1 : 0;
            int.TryParse(txtminCouponAmount.Text, out result);
            cfgWhere.minCouponAmount = result;

            //月销量
            cfgWhere.minMonthSalesAmountEnable = ckbMonthSales.Checked ? 1 : 0;
            int.TryParse(txtminMonthSalesAmount.Text, out result);
            cfgWhere.minMonthSalesAmount = result;


            //佣金比率
            cfgWhere.minCmsRateAmountEnable = ckbCmsRate.Checked ? 1 : 0;
            decimal.TryParse(txtminCmsRateAmount.Text, out result2);
            cfgWhere.minCmsRateAmount = result2;

            //商品价格
            cfgWhere.GoodsPriceEnable = ckbGoodsPrice.Checked ? 1 : 0;
            decimal.TryParse(txtminGoodsPrice.Text, out result2);
            cfgWhere.minGoodsPrice = result2;
            decimal.TryParse(txtmaxGoodsPrice.Text, out result2);
            cfgWhere.maxGoodsPrice = result2;

            //过滤今日重复商品
            cfgWhere.filterGoodsEnable = ckbfilterGoods.Checked ? 1 : 0;

            ConfigModel myConfig = hotForm.myConfig;

            myConfig.send_time_config = JsonConvert.SerializeObject(cfgTime);
            myConfig.where_config     = JsonConvert.SerializeObject(cfgWhere);

            MessageAlert alert = new MessageAlert();
            Loading      ld    = new Loading();

            ((Action)(delegate()
            {
                if (LogicUser.Instance.AddUserConfigModel(MyUserInfo.LoginToken, hotForm.myConfig) > 0)
                {
                    alert.Message = "保存成功";
                }
                else
                {
                    alert.Message = "保存失败,请重试";
                }
                ld.CloseForm();
                this.BeginInvoke((Action)(delegate()
                {
                    hotForm.myConfig = myConfig;
                    alert.ShowDialog(this);
                }));
            })).BeginInvoke(null, null);
            ld.ShowDialog(this);
        }
Ejemplo n.º 33
0
 void OnMouseDown()
 {
     Loading.Load(levelName);
 }
        void processbg(string file)
        {
            a++;
            Loading.ShowLoading(a+"/"+files.Count + " " + file, this);

            if (!File.Exists(file + ".jpg"))
            {
                LogMap.MapLogs(new string[] {file});
            }

            var loginfo = new loginfo();

            loginfo.fullname = file;

            try
            {
                // file not found exception even though it passes the exists check above.
                loginfo.Size = new FileInfo(file).Length;
            }
            catch
            {
                
            }

            if (File.Exists(file + ".jpg"))
            {
                loginfo.imgfile = file + ".jpg";
            }

            if (file.ToLower().EndsWith(".tlog"))
            {
                using (MAVLinkInterface mine = new MAVLinkInterface())
                {
                    try
                    {
                        mine.logplaybackfile =
                            new BinaryReader(File.Open(file, FileMode.Open, FileAccess.Read, FileShare.Read));
                    }
                    catch (Exception ex)
                    {
                        log.Debug(ex.ToString());
                        CustomMessageBox.Show("Log Can not be opened. Are you still connected?");
                        return;
                    }
                    mine.logreadmode = true;
                    mine.speechenabled = false;

                    // file is to small
                    if (mine.logplaybackfile.BaseStream.Length < 1024*4)
                        return;

                    mine.getHeartBeat();

                    loginfo.Date = mine.lastlogread;
                    loginfo.Aircraft = mine.sysidcurrent;

                    loginfo.Frame = mine.MAV.aptype.ToString();

                    var start = mine.lastlogread;

                    try
                    {
                        mine.logplaybackfile.BaseStream.Seek(0, SeekOrigin.Begin);
                    }
                    catch
                    {
                    }

                    var end = mine.lastlogread;

                    var length = mine.logplaybackfile.BaseStream.Length;

                    var a = 0;

                    // abandon last 100 bytes
                    while (mine.logplaybackfile.BaseStream.Position < (length-100))
                    {
                        var packet = mine.readPacket();

                        // gcs
                        if(packet.sysid == 255)
                            continue;

                        if (packet.msgid == (uint)MAVLink.MAVLINK_MSG_ID.CAMERA_FEEDBACK)
                            loginfo.CamMSG++;

                        if (a % 10 == 0)
                            mine.MAV.cs.UpdateCurrentSettings(null, true, mine);

                        a++;

                        if (mine.lastlogread > end)
                            end = mine.lastlogread;
                    }

                    loginfo.Home = mine.MAV.cs.Location;

                    loginfo.TimeInAir = mine.MAV.cs.timeInAir;

                    loginfo.DistTraveled = mine.MAV.cs.distTraveled;

                    loginfo.Duration = (end - start).ToString();
                }
            }
            else if (file.ToLower().EndsWith(".bin") || file.ToLower().EndsWith(".log"))
            {
                using (CollectionBuffer colbuf = new CollectionBuffer(File.OpenRead(file)))
                {
                    PointLatLngAlt lastpos = null;
                    DateTime start = DateTime.MinValue;
                    DateTime end = DateTime.MinValue;
                    DateTime tia = DateTime.MinValue;
                    // set time in air/home/distancetraveled
                    foreach (var dfItem in colbuf.GetEnumeratorType("GPS"))
                    {
                        if (dfItem["Status"] != null)
                        {
                            var status = int.Parse(dfItem["Status"]);
                            if (status >= 3)
                            {
                                var pos = new PointLatLngAlt(
                                    double.Parse(dfItem["Lat"], CultureInfo.InvariantCulture),
                                    double.Parse(dfItem["Lng"], CultureInfo.InvariantCulture),
                                    double.Parse(dfItem["Alt"], CultureInfo.InvariantCulture));

                                if (lastpos == null)
                                    lastpos = pos;

                                if (start == DateTime.MinValue)
                                {
                                    loginfo.Date = dfItem.time;
                                    start = dfItem.time;
                                }

                                end = dfItem.time;

                                // add distance
                                loginfo.DistTraveled += (float)lastpos.GetDistance(pos);

                                // set home
                                if (loginfo.Home == null)
                                    loginfo.Home = pos;

                                if (dfItem.time > tia.AddSeconds(1))
                                {
                                    // ground speed  > 0.2 or  alt > homelat+2
                                    if (double.Parse(dfItem["Spd"], CultureInfo.InvariantCulture) > 0.2 ||
                                        pos.Alt > (loginfo.Home.Alt + 2))
                                    {
                                        loginfo.TimeInAir++;
                                    }
                                    tia = dfItem.time;
                                }
                            }
                        }
                    }

                    loginfo.Duration = (end - start).ToString();

                    loginfo.CamMSG = colbuf.GetEnumeratorType("CAM").Count();

                    loginfo.Aircraft = 0;//colbuf.dflog.param[""];

                    loginfo.Frame = "Unknown";//mine.MAV.aptype.ToString();
                }
            }

            logs.Add(loginfo);
        }
Ejemplo n.º 35
0
 protected virtual void OnLoading(EventArgs e)
 {
     Loading?.Invoke(this, e);
 }
Ejemplo n.º 36
0
        /// <summary>
        ///     菜单项“侦测主机”单击时的事件。
        /// </summary>
        /// <param name="sender">触发事件的控件对象。</param>
        /// <param name="e">事件的参数。</param>
        private void 侦测主机ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            // 清空历史纪录
            HostList.Rows.Clear();

            // 创建载入界面
            var task = new Thread(spy => {
                try {
                    Scanner.SpyForTarget();
                }
                catch (ThreadAbortException) { }
            })
            {
                Name = RegisteredThreadName.SpyForTarget.ToString()
            };

            MessagePipe.SendInMessage(new KeyValuePair <Message, Thread>(Message.TaskIn, task));
            var loading = new Loading("正在侦测,取消以停止", task);

            loading.ShowDialog();

            // 等待结果
            new WaitTimeoutChecker(30000).ThreadSleep(500, () => MessagePipe.GetNextOutMessage(task) != Message.UserCancel);

            // 用户取消
            MessagePipe.SendInMessage(new KeyValuePair <Message, Thread>(Message.TaskCancel, task));
            var result = Message.NoAvailableMessage;

            new WaitTimeoutChecker(30000).ThreadSleep(500, () => (result = MessagePipe.GetNextOutMessage(task)) == Message.NoAvailableMessage);
            MessagePipe.ClearAllMessage(task);

            // 检查是否正确结束
            if (result != Message.TaskAborted)
            {
                MessageBox.Show("线程异常结束。", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            // 输出侦测结果
            foreach (var host in Scanner.HostList)
            {
                // 格式化MAC地址
                var temp = new StringBuilder(host.PhysicalAddress.ToString());
                if (temp.Length == 12)
                {
                    temp = temp.Insert(2, '-').Insert(5, '-').Insert(8, '-').Insert(11, '-').Insert(14, '-');
                }

                if (Scanner.GatewayAddresses.Contains(host.IPAddress))
                {
                    HostList.Rows.Add(host.IPAddress.ToString(), temp.ToString(), "网关地址");
                    Poisoner.Gateway = host;
                }
                else if (Equals(host.IPAddress, Scanner.Ipv4Address))
                {
                    HostList.Rows.Add(host.IPAddress.ToString(), temp.ToString(), "当前设备地址");
                }
                else
                {
                    HostList.Rows.Add(host.IPAddress.ToString(), temp.ToString(), "");
                }

                HostList.Rows[HostList.Rows.Count - 1].ContextMenuStrip = HostListMenuStrip;
            }
        }