public void Delete_createAndDelete_emptyList() { IInstrumBL instrumBL = new InstrumBLMock(); ITickSourceDA tickSourceDA = new TickSourceDAMock(); ITickSourceBL tickSourceBL = new TickSourceBL(instrumBL, tickSourceDA, null, null); var ts = new TickSource(instrumBL, null, null); ts.Name = "наименование"; ts.StartDate = new DateTime(2010, 1, 1); ts.EndDate = new DateTime(2010, 12, 31); ts.Timeframe = Timeframes.Hour; ts.AddInstrum(1); ts.AddInstrum(2); ts.AddInstrum(3); tickSourceBL.SaveTickSource(ts); // insert var list = tickSourceBL.GetTickSourceList().ToList(); Assert.Single(list); tickSourceBL.DeleteTickSourceByID(ts.TickSourceID); var list1 = tickSourceBL.GetTickSourceList().ToList(); Assert.Empty(list1); }
public void SaveGet_insert_getEqualTickSource() { IInstrumBL instrumBL = new InstrumBLMock(); ITickSourceDA tickSourceDA = new TickSourceDAMock(); TickSourceBL tickSourceBL = new TickSourceBL(instrumBL, tickSourceDA, null, null); var ts0 = new TickSource(instrumBL, null, null); ts0.Name = "наименование"; ts0.StartDate = new DateTime(2010, 1, 1); ts0.EndDate = new DateTime(2010, 12, 31); ts0.Timeframe = Timeframes.Hour; ts0.AddInstrum(1); ts0.AddInstrum(2); ts0.AddInstrum(3); tickSourceBL.SaveTickSource(ts0); var ts = tickSourceBL.GetTickSourceByID(ts0.TickSourceID); Assert.Equal(ts0.TickSourceID, ts.TickSourceID); Assert.Equal(ts0.Name, ts.Name); Assert.Equal(ts0.StartDate, ts.StartDate); Assert.Equal(ts0.EndDate, ts.EndDate); Assert.Equal(ts0.Timeframe, ts.Timeframe); string ids0 = string.Join(',', ts0.GetInstrums().Select(r => r.InsID.ToString()).OrderBy(r => r)); string ids = string.Join(',', ts.GetInstrums().Select(r => r.InsID.ToString()).OrderBy(r => r)); Assert.Equal(ids0, ids); }
public void TogglePauseEmulation(bool pause) { lock (KernelContext.Processes) { foreach (KProcess process in KernelContext.Processes.Values) { if (process.IsApplication) { // Only game process should be paused. process.SetActivity(pause); } } if (pause && !IsPaused) { Device.AudioDeviceDriver.GetPauseEvent().Reset(); TickSource.Suspend(); } else if (!pause && IsPaused) { Device.AudioDeviceDriver.GetPauseEvent().Set(); TickSource.Resume(); } } IsPaused = pause; }
public void SerializeInitialize_tsclone_equalCloned() { IInstrumBL instrumBL = new InstrumBLMock(); TickSource ts = new TickSource(instrumBL, null, null); ts.Name = "наименование"; ts.StartDate = new DateTime(2010, 1, 1); ts.EndDate = new DateTime(2010, 12, 31); ts.Timeframe = Timeframes.Min; ts.AddInstrum(1); ts.AddInstrum(2); ts.AddInstrum(3); var xdoc = ts.Serialize(); var ts1 = new TickSource(instrumBL, null, null); ts1.Initialize(xdoc); Assert.Equal(ts.StartDate, ts1.StartDate); Assert.Equal(ts.EndDate, ts1.EndDate); Assert.Equal(ts.Timeframe, ts1.Timeframe); var ts1_instrums = ts1.GetInstrums(); Assert.Equal(3, ts1_instrums.Count()); Assert.Contains(ts1_instrums, r => r.InsID == 1); Assert.Contains(ts1_instrums, r => r.InsID == 2); Assert.Contains(ts1_instrums, r => r.InsID == 3); }
public void InitContext(int id, IExecutor parentExecutor) { _parentExecutor = parentExecutor; if (id > 0) { _tickSource = _tickSourceBL.GetTickSourceByID(id); } if (_tickSource == null) { _tickSource = new TickSource(_instrumBL, _insStoreBL, null); } View(); }
public void SerializeInitialize_tsWithEmptyInstrums_clonedWithEmptyInstrums() { IInstrumBL instrumBL = new InstrumBLMock(); TickSource ts = new TickSource(instrumBL, null, null); ts.Name = "наименование"; ts.StartDate = new DateTime(2010, 1, 1); ts.EndDate = new DateTime(2010, 12, 31); ts.Timeframe = Timeframes.Min; var xdoc = ts.Serialize(); var ts1 = new TickSource(instrumBL, null, null); ts1.Initialize(xdoc); var ts1_instrums = ts1.GetInstrums(); Assert.Empty(ts1_instrums); }
public Horizon(Switch device) { TickSource = new TickSource(KernelConstants.CounterFrequency); CpuEngine = new JitEngine(TickSource); KernelContext = new KernelContext( TickSource, device, device.Memory, device.Configuration.MemoryConfiguration.ToKernelMemorySize(), device.Configuration.MemoryConfiguration.ToKernelMemoryArrange()); Device = device; State = new SystemStateMgr(); PerformanceState = new PerformanceState(); NfpDevices = new List <NfpDevice>(); // Note: This is not really correct, but with HLE of services, the only memory // region used that is used is Application, so we can use the other ones for anything. KMemoryRegionManager region = KernelContext.MemoryManager.MemoryRegions[(int)MemoryRegion.NvServices]; ulong hidPa = region.Address; ulong fontPa = region.Address + HidSize; ulong iirsPa = region.Address + HidSize + FontSize; ulong timePa = region.Address + HidSize + FontSize + IirsSize; ulong appletCaptureBufferPa = region.Address + HidSize + FontSize + IirsSize + TimeSize; KPageList hidPageList = new KPageList(); KPageList fontPageList = new KPageList(); KPageList iirsPageList = new KPageList(); KPageList timePageList = new KPageList(); KPageList appletCaptureBufferPageList = new KPageList(); hidPageList.AddRange(hidPa, HidSize / KPageTableBase.PageSize); fontPageList.AddRange(fontPa, FontSize / KPageTableBase.PageSize); iirsPageList.AddRange(iirsPa, IirsSize / KPageTableBase.PageSize); timePageList.AddRange(timePa, TimeSize / KPageTableBase.PageSize); appletCaptureBufferPageList.AddRange(appletCaptureBufferPa, AppletCaptureBufferSize / KPageTableBase.PageSize); var hidStorage = new SharedMemoryStorage(KernelContext, hidPageList); var fontStorage = new SharedMemoryStorage(KernelContext, fontPageList); var iirsStorage = new SharedMemoryStorage(KernelContext, iirsPageList); var timeStorage = new SharedMemoryStorage(KernelContext, timePageList); var appletCaptureBufferStorage = new SharedMemoryStorage(KernelContext, appletCaptureBufferPageList); HidStorage = hidStorage; HidSharedMem = new KSharedMemory(KernelContext, hidStorage, 0, 0, KMemoryPermission.Read); FontSharedMem = new KSharedMemory(KernelContext, fontStorage, 0, 0, KMemoryPermission.Read); IirsSharedMem = new KSharedMemory(KernelContext, iirsStorage, 0, 0, KMemoryPermission.Read); KSharedMemory timeSharedMemory = new KSharedMemory(KernelContext, timeStorage, 0, 0, KMemoryPermission.Read); TimeServiceManager.Instance.Initialize(device, this, timeSharedMemory, timeStorage, TimeSize); AppletCaptureBufferTransfer = new KTransferMemory(KernelContext, appletCaptureBufferStorage); AppletState = new AppletStateMgr(this); AppletState.SetFocus(true); VsyncEvent = new KEvent(KernelContext); DisplayResolutionChangeEvent = new KEvent(KernelContext); SharedFontManager = new SharedFontManager(device, fontStorage); AccountManager = device.Configuration.AccountManager; ContentManager = device.Configuration.ContentManager; CaptureManager = new CaptureManager(device); LibHacHorizonManager = device.Configuration.LibHacHorizonManager; // TODO: use set:sys (and get external clock source id from settings) // TODO: use "time!standard_steady_clock_rtc_update_interval_minutes" and implement a worker thread to be accurate. UInt128 clockSourceId = new UInt128(Guid.NewGuid().ToByteArray()); IRtcManager.GetExternalRtcValue(out ulong rtcValue); // We assume the rtc is system time. TimeSpanType systemTime = TimeSpanType.FromSeconds((long)rtcValue); // Configure and setup internal offset TimeSpanType internalOffset = TimeSpanType.FromSeconds(device.Configuration.SystemTimeOffset); TimeSpanType systemTimeOffset = new TimeSpanType(systemTime.NanoSeconds + internalOffset.NanoSeconds); if (systemTime.IsDaylightSavingTime() && !systemTimeOffset.IsDaylightSavingTime()) { internalOffset = internalOffset.AddSeconds(3600L); } else if (!systemTime.IsDaylightSavingTime() && systemTimeOffset.IsDaylightSavingTime()) { internalOffset = internalOffset.AddSeconds(-3600L); } internalOffset = new TimeSpanType(-internalOffset.NanoSeconds); // First init the standard steady clock TimeServiceManager.Instance.SetupStandardSteadyClock(TickSource, clockSourceId, systemTime, internalOffset, TimeSpanType.Zero, false); TimeServiceManager.Instance.SetupStandardLocalSystemClock(TickSource, new SystemClockContext(), systemTime.ToSeconds()); if (NxSettings.Settings.TryGetValue("time!standard_network_clock_sufficient_accuracy_minutes", out object standardNetworkClockSufficientAccuracyMinutes)) { TimeSpanType standardNetworkClockSufficientAccuracy = new TimeSpanType((int)standardNetworkClockSufficientAccuracyMinutes * 60000000000); // The network system clock needs a valid system clock, as such we setup this system clock using the local system clock. TimeServiceManager.Instance.StandardLocalSystemClock.GetClockContext(TickSource, out SystemClockContext localSytemClockContext); TimeServiceManager.Instance.SetupStandardNetworkSystemClock(localSytemClockContext, standardNetworkClockSufficientAccuracy); } TimeServiceManager.Instance.SetupStandardUserSystemClock(TickSource, false, SteadyClockTimePoint.GetRandom()); // FIXME: TimeZone should be init here but it's actually done in ContentManager TimeServiceManager.Instance.SetupEphemeralNetworkSystemClock(); DatabaseImpl.Instance.InitializeDatabase(TickSource, LibHacHorizonManager.SdbClient); HostSyncpoint = new NvHostSyncpt(device); SurfaceFlinger = new SurfaceFlinger(device); InitializeAudioRenderer(TickSource); InitializeServices(); }