Exemplo n.º 1
0
        public static Horizon CreateBasicHorizon()
        {
            IFileSystem rootFs = new InMemoryFileSystem();

            var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new Keyset());

            var config = new FileSystemServerConfig();

            config.FsCreators     = defaultObjects.FsCreators;
            config.DeviceOperator = defaultObjects.DeviceOperator;
            config.ExternalKeySet = new ExternalKeySet();

            var horizon = new Horizon(new StopWatchTimeSpanGenerator(), config);

            return(horizon);
        }
Exemplo n.º 2
0
        public IHOSBinderDriver(Horizon System, IGalRenderer Renderer)
        {
            m_Commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 0, TransactParcel },
                { 1, AdjustRefcount },
                { 2, GetNativeHandle },
                { 3, TransactParcelAuto }
            };

            BinderEvent = new KEvent(System);

            BinderEvent.ReadableEvent.Signal();

            Flinger = new NvFlinger(Renderer, BinderEvent);
        }
Exemplo n.º 3
0
        public ICommonStateGetter(Horizon System)
        {
            m_Commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 0, GetEventHandle },
                { 1, ReceiveMessage },
                { 5, GetOperationMode },
                { 6, GetPerformanceMode },
                { 8, GetBootMode },
                { 9, GetCurrentFocusState },
                { 60, GetDefaultDisplayResolution },
                { 61, GetDefaultDisplayResolutionChangeEvent }
            };

            DisplayResolutionChangeEvent = new KEvent(System);
        }
Exemplo n.º 4
0
        public static Horizon CreateBasicHorizon()
        {
            IFileSystem rootFs = new InMemoryFileSystem();

            var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new KeySet());

            var config = new FileSystemServerConfig();

            config.FsCreators     = defaultObjects.FsCreators;
            config.DeviceOperator = defaultObjects.DeviceOperator;
            config.ExternalKeySet = new ExternalKeySet();

            Horizon horizon = LibHac.HorizonFactory.CreateWithFsConfig(new HorizonConfiguration(), config);

            return(horizon);
        }
Exemplo n.º 5
0
        // GET: Horizons/Details/5
        public ActionResult Details(long?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Horizon horizon = db.Horizons.Find(id);

            if (horizon == null)
            {
                return(HttpNotFound());
            }
            HorizonViewModel vm = new HorizonViewModel(horizon);

            return(View("~/Views/Agriculture/Horizons/Details.cshtml", vm));
        }
Exemplo n.º 6
0
        public INvDrvServices(Horizon System)
        {
            m_Commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 0, Open },
                { 1, Ioctl },
                { 2, Close },
                { 3, Initialize },
                { 4, QueryEvent },
                { 8, SetClientPid },
                { 11, Ioctl },
                { 13, FinishInitialize }
            };

            Event = new KEvent(System);
        }
Exemplo n.º 7
0
        public static bool UserToKernelInt32(Horizon system, ulong address, out int value)
        {
            KProcess currentProcess = system.Scheduler.GetCurrentProcess();

            if (currentProcess.CpuMemory.IsMapped((long)address) &&
                currentProcess.CpuMemory.IsMapped((long)address + 3))
            {
                value = currentProcess.CpuMemory.ReadInt32((long)address);

                return(true);
            }

            value = 0;

            return(false);
        }
Exemplo n.º 8
0
        public static bool UserToKernelString(Horizon system, ulong address, int size, out string value)
        {
            KProcess currentProcess = system.Scheduler.GetCurrentProcess();

            if (currentProcess.CpuMemory.IsMapped((long)address) &&
                currentProcess.CpuMemory.IsMapped((long)address + size - 1))
            {
                value = MemoryHelper.ReadAsciiString(currentProcess.CpuMemory, (long)address, size);

                return(true);
            }

            value = null;

            return(false);
        }
Exemplo n.º 9
0
        public IhosBinderDriver(Horizon system, IGalRenderer renderer)
        {
            _commands = new Dictionary <int, ServiceProcessRequest>
            {
                { 0, TransactParcel },
                { 1, AdjustRefcount },
                { 2, GetNativeHandle },
                { 3, TransactParcelAuto }
            };

            _binderEvent = new KEvent(system);

            _binderEvent.ReadableEvent.Signal();

            _flinger = new NvFlinger(renderer, _binderEvent);
        }
Exemplo n.º 10
0
 public HorizonViewModel(Horizon horizon)
 {
     this.HorizonId         = horizon.HorizonId;
     this.Name              = horizon.Name;
     this.BulkDensitySoil   = horizon.BulkDensitySoil;
     this.Clay              = horizon.Clay;
     this.HorizonLayer      = horizon.HorizonLayer;
     this.HorizonLayerDepth = horizon.HorizonLayerDepth;
     this.Limo              = horizon.Limo;
     this.NitrogenAnalysis  = horizon.NitrogenAnalysis;
     this.Order             = horizon.Order;
     this.OrganicMatter     = horizon.OrganicMatter;
     this.Sand              = horizon.Sand;
     this.SoilId            = horizon.SoilId;
     this.Soil              = horizon.Soil;
     this.Soils             = new List <System.Web.Mvc.SelectListItem>();
 }
Exemplo n.º 11
0
        public IUser(Horizon system)
        {
            _commands = new Dictionary <int, ServiceProcessRequest>
            {
                { 0, Initialize },
                { 17, AttachActivateEvent },
                { 18, AttachDeactivateEvent },
                { 19, GetState },
                { 20, GetDeviceState },
                { 21, GetNpadId },
                { 23, AttachAvailabilityChangeEvent }
            };

            _activateEvent           = new KEvent(system);
            _deactivateEvent         = new KEvent(system);
            _availabilityChangeEvent = new KEvent(system);
        }
Exemplo n.º 12
0
        public ILibraryAppletAccessor(AppletId appletId, Horizon system)
        {
            _stateChangedEvent       = new KEvent(system.KernelContext);
            _normalOutDataEvent      = new KEvent(system.KernelContext);
            _interactiveOutDataEvent = new KEvent(system.KernelContext);

            _applet = AppletManager.Create(appletId, system);

            _normalSession      = new AppletSession();
            _interactiveSession = new AppletSession();

            _applet.AppletStateChanged        += OnAppletStateChanged;
            _normalSession.DataAvailable      += OnNormalOutData;
            _interactiveSession.DataAvailable += OnInteractiveOutData;

            Logger.PrintInfo(LogClass.ServiceAm, $"Applet '{appletId}' created.");
        }
Exemplo n.º 13
0
        public INvDrvServices(Horizon system)
        {
            _commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 0, Open },
                { 1, Ioctl },
                { 2, Close },
                { 3, Initialize },
                { 4, QueryEvent },
                { 8, SetClientPid },
                { 9, DumpGraphicsMemoryInfo },
                { 11, Ioctl },
                { 13, FinishInitialize }
            };

            _event = new KEvent(system);
        }
Exemplo n.º 14
0
        private float HorizonDifference(Horizon horizon1, Horizon horizon2)
        {
            var b1 = horizon1.Buffer;
            var b2 = horizon2.Buffer;

            System.Diagnostics.Debug.Assert(b1.Length == b2.Length);
            var sum = 0d;

            for (var i = 0; i < b1.Length; i++)
            {
                var d = b1[i] - b2[i];
                //sum += d * d;
                sum = Math.Max(sum, Math.Abs(d));
            }
            //return (float)Math.Sqrt(sum);
            return((float)sum);
        }
Exemplo n.º 15
0
        public void soilTest()
        {
            double  sand          = 17.3;
            double  limo          = 53.9;
            double  clay          = 28.8;
            double  organicMatter = 4.4;
            Horizon lHorizon      = new Horizon();

            lHorizon.Sand              = sand;
            lHorizon.Limo              = limo;
            lHorizon.Clay              = clay;
            lHorizon.OrganicMatter     = organicMatter;
            lHorizon.HorizonLayer      = "A";
            lHorizon.Order             = 0;
            lHorizon.HorizonLayerDepth = 5.3;

            Soil lSoil = new Soil();

            lSoil.HorizonList.Add(lHorizon);

            double pmp = lSoil.GetPermanentWiltingPoint(5);
            double cc  = lSoil.GetFieldCapacity(5);
            double ad  = lSoil.GetAvailableWaterCapacity(5);

            //double pmp10 = testSoil.GetPermanentWiltingPoint(10);
            double cc10 = lSoil.GetFieldCapacity(10);
            //double ad10 = testSoil.GetAvailableWaterCapacity(10);

            double pmp0 = lSoil.GetPermanentWiltingPoint(0);
            double cc0  = lSoil.GetFieldCapacity(0);
            double ad0  = lSoil.GetAvailableWaterCapacity(0);

            //RootDeepth between the border (0) and the HorizonDepth
            Assert.AreEqual(pmp, 16.002069999999989);
            Assert.AreEqual(cc, 34.1726);
            Assert.AreEqual(ad, 18.170530000000014);
            //RootDeepth outside the horizon
            //           Assert.AreEqual(pmp10, 0);
            Assert.AreEqual(cc10, 34.1726);
            //          Assert.AreEqual(ad10, 0);
            //RootDeepth = 0
            Assert.AreEqual(pmp0, 16.002069999999989);
            Assert.AreEqual(cc0, 34.1726);
            Assert.AreEqual(ad0, 18.170530000000014);
        }
Exemplo n.º 16
0
        public Switch(HLEConfiguration configuration)
        {
            if (configuration.GpuRenderer == null)
            {
                throw new ArgumentNullException(nameof(configuration.GpuRenderer));
            }

            if (configuration.AudioDeviceDriver == null)
            {
                throw new ArgumentNullException(nameof(configuration.AudioDeviceDriver));
            }

            if (configuration.UserChannelPersistence == null)
            {
                throw new ArgumentNullException(nameof(configuration.UserChannelPersistence));
            }

            Configuration = configuration;
            FileSystem    = Configuration.VirtualFileSystem;
            UiHandler     = Configuration.HostUiHandler;

            MemoryAllocationFlags memoryAllocationFlags = configuration.MemoryManagerMode == MemoryManagerMode.SoftwarePageTable
                ? MemoryAllocationFlags.Reserve
                : MemoryAllocationFlags.Reserve | MemoryAllocationFlags.Mirrorable;

            AudioDeviceDriver = new CompatLayerHardwareDeviceDriver(Configuration.AudioDeviceDriver);
            Memory            = new MemoryBlock(Configuration.MemoryConfiguration.ToDramSize(), memoryAllocationFlags);
            Gpu           = new GpuContext(Configuration.GpuRenderer);
            System        = new Horizon(this);
            Statistics    = new PerformanceStatistics();
            Hid           = new Hid(this, System.HidStorage);
            Application   = new ApplicationLoader(this);
            TamperMachine = new TamperMachine();

            System.State.SetLanguage(Configuration.SystemLanguage);
            System.State.SetRegion(Configuration.Region);

            EnableDeviceVsync       = Configuration.EnableVsync;
            System.State.DockedMode = Configuration.EnableDockedMode;
            System.PerformanceState.PerformanceMode = System.State.DockedMode ? PerformanceMode.Boost : PerformanceMode.Default;
            System.EnablePtc             = Configuration.EnablePtc;
            System.FsIntegrityCheckLevel = Configuration.FsIntegrityCheckLevel;
            System.GlobalAccessLogMode   = Configuration.FsGlobalAccessLogMode;
        }
Exemplo n.º 17
0
        public static void NotifyAll(Horizon System, LinkedList <KThread> ThreadList)
        {
            System.CriticalSection.Enter();

            LinkedListNode <KThread> Node = ThreadList.First;

            for (; Node != null; Node = ThreadList.First)
            {
                KThread Thread = Node.Value;

                ThreadList.Remove(Thread.WithholderNode);

                Thread.Withholder = null;

                Thread.Reschedule(ThreadSchedState.Running);
            }

            System.CriticalSection.Leave();
        }
        private async void Land(object sender, RoutedEventArgs e)
        {
            // Only start if it is not running.
            if (scriptTask != null && scriptTask.Status.Equals(TaskStatus.Running))
            {
                Console.WriteLine("Script can't be run while another script has already been started.");
                return;
            }
            // Ask user for confirmation.
            MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("Are you sure you want to launch the landing sequence?", "Launch Confirmation", System.Windows.MessageBoxButton.YesNo);

            if (messageBoxResult == MessageBoxResult.Yes)
            {
                Console.WriteLine("Starting Horizon...");
                scriptTask = Task.Run(() => Horizon.Start(true, lbResult, progress));
                await scriptTask;
                Console.WriteLine("Exiting Horizon.");
            }
        }
Exemplo n.º 19
0
        public static void NotifyAll(Horizon system, LinkedList <KThread> threadList)
        {
            system.CriticalSection.Enter();

            LinkedListNode <KThread> node = threadList.First;

            for (; node != null; node = threadList.First)
            {
                KThread thread = node.Value;

                threadList.Remove(thread.WithholderNode);

                thread.Withholder = null;

                thread.Reschedule(ThreadSchedState.Running);
            }

            system.CriticalSection.Leave();
        }
Exemplo n.º 20
0
        public NvHostEvent(NvHostSyncpt syncpointManager, uint eventId, Horizon system)
        {
            Fence.Id = 0;

            State = NvHostEventState.Available;

            Event = new KEvent(system.KernelContext);

            if (KernelStatic.GetCurrentProcess().HandleTable.GenerateHandle(Event.ReadableEvent, out EventHandle) != KernelResult.Success)
            {
                throw new InvalidOperationException("Out of handles!");
            }

            _eventId = eventId;

            _syncpointManager = syncpointManager;

            ResetFailingState();
        }
Exemplo n.º 21
0
        public void CalculateVolumeOneCubicMeter()
        {
            //Setup
            var topHorizon = new Horizon(
                new List <int>()
            {
                0
            }.AsReadOnly(),
                LengthUnit.Meter,
                new GridCell(1, 1));

            //Act
            var reservoir = new Reservoir(topHorizon);

            reservoir.CalculateVolume(1, 1, LengthUnit.Meter);

            //Assert
            Assert.AreEqual(1, reservoir.CalculatedVolume, Reservoir.Tolerance);
        }
Exemplo n.º 22
0
        public static bool UserToKernelInt32Array(Horizon system, ulong address, int[] values)
        {
            KProcess currentProcess = system.Scheduler.GetCurrentProcess();

            for (int index = 0; index < values.Length; index++, address += 4)
            {
                if (currentProcess.CpuMemory.IsMapped((long)address) &&
                    currentProcess.CpuMemory.IsMapped((long)address + 3))
                {
                    values[index] = currentProcess.CpuMemory.ReadInt32((long)address);
                }
                else
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 23
0
        public static void Wait(Horizon system, LinkedList <KThread> threadList, object mutex, long timeout)
        {
            KThread currentThread = system.Scheduler.GetCurrentThread();

            system.CriticalSection.Enter();

            Monitor.Exit(mutex);

            currentThread.Withholder = threadList;

            currentThread.Reschedule(ThreadSchedState.Paused);

            currentThread.WithholderNode = threadList.AddLast(currentThread);

            if (currentThread.ShallBeTerminated ||
                currentThread.SchedFlags == ThreadSchedState.TerminationPending)
            {
                threadList.Remove(currentThread.WithholderNode);

                currentThread.Reschedule(ThreadSchedState.Running);

                currentThread.Withholder = null;

                system.CriticalSection.Leave();
            }
            else
            {
                if (timeout > 0)
                {
                    system.TimeManager.ScheduleFutureInvocation(currentThread, timeout);
                }

                system.CriticalSection.Leave();

                if (timeout > 0)
                {
                    system.TimeManager.UnscheduleFutureInvocation(currentThread);
                }
            }

            Monitor.Enter(mutex);
        }
Exemplo n.º 24
0
        public static void Wait(Horizon System, LinkedList <KThread> ThreadList, object Mutex, long Timeout)
        {
            KThread CurrentThread = System.Scheduler.GetCurrentThread();

            System.CriticalSection.Enter();

            Monitor.Exit(Mutex);

            CurrentThread.Withholder = ThreadList;

            CurrentThread.Reschedule(ThreadSchedState.Paused);

            CurrentThread.WithholderNode = ThreadList.AddLast(CurrentThread);

            if (CurrentThread.ShallBeTerminated ||
                CurrentThread.SchedFlags == ThreadSchedState.TerminationPending)
            {
                ThreadList.Remove(CurrentThread.WithholderNode);

                CurrentThread.Reschedule(ThreadSchedState.Running);

                CurrentThread.Withholder = null;

                System.CriticalSection.Leave();
            }
            else
            {
                if (Timeout > 0)
                {
                    System.TimeManager.ScheduleFutureInvocation(CurrentThread, Timeout);
                }

                System.CriticalSection.Leave();

                if (Timeout > 0)
                {
                    System.TimeManager.UnscheduleFutureInvocation(CurrentThread);
                }
            }

            Monitor.Enter(Mutex);
        }
Exemplo n.º 25
0
        public ISelfController(Horizon System)
        {
            m_Commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 0, Exit },
                { 1, LockExit },
                { 2, UnlockExit },
                { 9, GetLibraryAppletLaunchableEvent },
                { 10, SetScreenShotPermission },
                { 11, SetOperationModeChangedNotification },
                { 12, SetPerformanceModeChangedNotification },
                { 13, SetFocusHandlingMode },
                { 14, SetRestartMessageEnabled },
                { 16, SetOutOfFocusSuspendingEnabled },
                { 19, SetScreenShotImageOrientation },
                { 50, SetHandlesRequestToDisplay }
            };

            LaunchableEvent = new KEvent(System);
        }
Exemplo n.º 26
0
        private static FileSystemClient CreateClientImpl(bool sdCardInserted, out IFileSystem rootFs)
        {
            rootFs = new InMemoryFileSystem();

            var defaultObjects = DefaultFsServerObjects.GetDefaultEmulatedCreators(rootFs, new KeySet());

            defaultObjects.SdCard.SetSdCardInsertionStatus(sdCardInserted);

            var config = new FileSystemServerConfig();

            config.FsCreators     = defaultObjects.FsCreators;
            config.DeviceOperator = defaultObjects.DeviceOperator;
            config.ExternalKeySet = new ExternalKeySet();

            Horizon horizon = LibHac.HorizonFactory.CreateWithFsConfig(new HorizonConfiguration(), config);

            HorizonClient horizonClient = horizon.CreatePrivilegedHorizonClient();

            return(horizonClient.Fs);
        }
Exemplo n.º 27
0
        public Switch(HLEConfiguration configuration)
        {
            if (configuration.GpuRenderer == null)
            {
                throw new ArgumentNullException(nameof(configuration.GpuRenderer));
            }

            if (configuration.AudioDeviceDriver == null)
            {
                throw new ArgumentNullException(nameof(configuration.AudioDeviceDriver));
            }

            if (configuration.UserChannelPersistence == null)
            {
                throw new ArgumentNullException(nameof(configuration.UserChannelPersistence));
            }

            Configuration = configuration;

            UiHandler = configuration.HostUiHandler;

            AudioDeviceDriver = new CompatLayerHardwareDeviceDriver(configuration.AudioDeviceDriver);

            Memory = new MemoryBlock(configuration.MemoryConfiguration.ToDramSize(), MemoryAllocationFlags.Reserve);

            Gpu = new GpuContext(configuration.GpuRenderer);

            System = new Horizon(this);
            System.InitializeServices();

            Statistics = new PerformanceStatistics();

            Hid = new Hid(this, System.HidStorage);
            Hid.InitDevices();

            Application = new ApplicationLoader(this);

            TamperMachine = new TamperMachine();

            Initialize();
        }
Exemplo n.º 28
0
        public KProcess(Horizon system) : base(system)
        {
            _processLock   = new object();
            _threadingLock = new object();

            _system = system;

            AddressArbiter = new KAddressArbiter(system);

            _fullTlsPages = new SortedDictionary <ulong, KTlsPageInfo>();
            _freeTlsPages = new SortedDictionary <ulong, KTlsPageInfo>();

            Capabilities = new KProcessCapabilities();

            RandomEntropy = new long[KScheduler.CpuCoresCount];

            _threads = new LinkedList <KThread>();

            _svcHandler = new SvcHandler(system.Device, this);

            Debugger = new HleProcessDebugger(this);
        }
Exemplo n.º 29
0
        public IAudioDevice(Horizon System)
        {
            m_Commands = new Dictionary <int, ServiceProcessRequest>()
            {
                { 0, ListAudioDeviceName },
                { 1, SetAudioDeviceOutputVolume },
                { 3, GetActiveAudioDeviceName },
                { 4, QueryAudioDeviceSystemEvent },
                { 5, GetActiveChannelCount },
                { 6, ListAudioDeviceNameAuto },
                { 7, SetAudioDeviceOutputVolumeAuto },
                { 8, GetAudioDeviceOutputVolumeAuto },
                { 10, GetActiveAudioDeviceNameAuto },
                { 11, QueryAudioDeviceInputEvent },
                { 12, QueryAudioDeviceOutputEvent }
            };

            SystemEvent = new KEvent(System);

            //TODO: We shouldn't be signaling this here.
            SystemEvent.ReadableEvent.Signal();
        }
        private void CheckTransmitShowParticalDistance(ref PoolObjHandle <ActorRoot> srcObj, ref PoolObjHandle <ActorRoot> targetObj)
        {
            if (!srcObj && !targetObj)
            {
                return;
            }
            if (targetObj.handle.Visible)
            {
                this.bCheckFilter = true;
                return;
            }
            Player hostPlayer = Singleton <GamePlayerCenter> .GetInstance().GetHostPlayer();

            if (hostPlayer == null || !hostPlayer.Captain)
            {
                return;
            }
            int   num      = Horizon.QueryGlobalSight();
            VInt3 worldLoc = new VInt3(targetObj.handle.location.x, targetObj.handle.location.z, 0);
            bool  flag     = Singleton <GameFowManager> .instance.IsVisible(worldLoc, hostPlayer.PlayerCamp);

            if (flag)
            {
                this.bCheckFilter = true;
                return;
            }
            int count = Singleton <GameObjMgr> .instance.HeroActors.get_Count();

            for (int i = 0; i < count; i++)
            {
                PoolObjHandle <ActorRoot> ptr = Singleton <GameObjMgr> .instance.HeroActors.get_Item(i);

                if (ptr && !ptr.handle.ActorControl.IsDeadState && !ActorHelper.IsHostEnemyActor(ref ptr) && (targetObj.handle.location - hostPlayer.Captain.handle.location).sqrMagnitudeLong2D < (long)(num * num))
                {
                    this.bCheckFilter = true;
                    break;
                }
            }
        }