private void BtnSaveSpider_Click(object sender, EventArgs e) { if (!_spiderInitialized) { MetroMessageBox.Show(this, "You should spider something first!", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } try { var remoteProc = RemoteProc.Instance(); if (remoteProc == null) { return; } var address = Defs.PointerByName("inventory").GetAddress(remoteProc); foreach (var item in _inventory) { remoteProc.Write(address, item.SekiroItem); address += 16; } } catch (Exception ex) { Diag.WriteLine(ex.Message); MessageBox.Show($"Failed to save inventory :( \n{ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } MetroMessageBox.Show(this, "Inventory saved! Do something that forces the game to reparse your inventory such as warping or saving and loading", ":o", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void SendHttpRequest() { // Tie the transport method to the ControlChannelTrigger object to push enable it. // Note that if the transport's TCP connection is broken at a later point of time, // the ControlChannelTrigger object can be reused to plug in a new transport by // calling UsingTransport again. Diag.DebugPrint("Calling UsingTransport() ..."); channel.UsingTransport(httpRequest); // Call the SendRequestAsync function to kick start the TCP connection establishment // process for this HTTP request. Diag.DebugPrint("Calling SendRequestAsync() ..."); sendRequestOperation = httpClient.SendRequestAsync(httpRequest, HttpCompletionOption.ResponseHeadersRead); sendRequestOperation.Completed += OnSendRequestCompleted; // Call WaitForPushEnabled API to make sure the TCP connection has been established, // which will mean that the OS will have allocated any hardware or software slot for this TCP connection. ControlChannelTriggerStatus status = channel.WaitForPushEnabled(); Diag.DebugPrint("WaitForPushEnabled() completed with status: " + status); if (status != ControlChannelTriggerStatus.HardwareSlotAllocated && status != ControlChannelTriggerStatus.SoftwareSlotAllocated) { throw new Exception("Hardware/Software slot not allocated"); } Diag.DebugPrint("Transport is ready to read response from server."); }
private static List <Customer> LoadCustomers(string customerDataFile) { // In a real application, the data would come from an external source, // but for this demo let's keep things simple and use a resource file. using (Stream stream = GetResourceStream(customerDataFile)) using (XmlReader xmlRdr = new XmlTextReader(stream)) { { try { Diag.UpdateLog("(3) CustomerRepository; " + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t"); } catch (Exception ex) { Diag.UpdateLog("(3) CustomerRepository; " + System.Reflection.MethodBase.GetCurrentMethod().Name + ";\t" + ex.Message); } return ((from customerElem in XDocument.Load(xmlRdr).Element("customers").Elements("customer") select Customer.CreateCustomer( (double)customerElem.Attribute("totalSales"), (string)customerElem.Attribute("firstName"), (string)customerElem.Attribute("lastName"), (bool)customerElem.Attribute("isCompany"), (string)customerElem.Attribute("email") )).ToList()); } } }
private static void LogDiagnostics(IEnumerable <Diagnostic> Diagnostics) { foreach (Diagnostic Diag in Diagnostics) { switch (Diag.Severity) { case DiagnosticSeverity.Error: { Log.TraceError(Diag.ToString()); break; } case DiagnosticSeverity.Hidden: { break; } case DiagnosticSeverity.Warning: { Log.TraceWarning(Diag.ToString()); break; } case DiagnosticSeverity.Info: { Log.TraceInformation(Diag.ToString()); break; } } } }
private void FlagToggle() { foreach (var item in flagToggleList.Items) { Diag.WriteLine(item.ToString()); } }
private void SetupHttpRequestAndSendToHttpServer() { try { Diag.DebugPrint("SetupHttpRequestAndSendToHttpServer started with uri: " + serverUri); // IMPORTANT: // For HTTP based transports that use the RTC broker, whenever we send next request, we will abort the earlier // outstanding http request and start new one. // For example in case when http server is taking longer to reply, and keep alive trigger is fired in-between // then keep alive task will abort outstanding http request and start a new request which should be finished // before next keep alive task is triggered. if (httpRequest != null) { httpRequest.Dispose(); } httpRequest = RtcRequestFactory.Create(HttpMethod.Get, serverUri); SendHttpRequest(); } catch (Exception e) { Diag.DebugPrint("Connect failed with: " + e.ToString()); throw; } }
public async Task <ActionResult <Diag> > PostDiag(Diag diag) { _context.Diags.Add(diag); await _context.SaveChangesAsync(); return(CreatedAtAction("GetDiag", new { id = diag.DiagId }, diag)); }
private async Task PhotoFromGallery() { if (!CrossMedia.Current.IsPickPhotoSupported) { await Diag.AlertAsync(new AlertConfig() { Message = "No se puede accesar la galeria", OkText = "Ok" }); return; } var file = await Plugin.Media.CrossMedia.Current.PickPhotoAsync(new Plugin.Media.Abstractions.PickMediaOptions { PhotoSize = Plugin.Media.Abstractions.PhotoSize.Medium, }); if (file == null) { return; } contact.Photo = Base64Photo(file.GetStream()); sourceuserpic = ImageSource.FromStream(() => { var stream = file.GetStream(); file.Dispose(); return(stream); }); OnPropertyChanged("sourceuserpic"); }
public static async Task AcceptConnection(string serviceName, CommModule myCommModule) { // Create and store a streamsocketlistener in the class. This way, new connections // can be automatically accepted. if (myCommModule.serverListener == null) { myCommModule.serverListener = new StreamSocketListener(); } myCommModule.serverListener.ConnectionReceived += (op, evt) => { // For simplicity, the server can talk to only one client at a time. myCommModule.serverSocket = evt.Socket; if (myCommModule.writePacket != null) { myCommModule.writePacket.DetachStream(); myCommModule.writePacket = null; } Diag.DebugPrint("Connection Received!"); }; await myCommModule.serverListener.BindServiceNameAsync(serviceName); return; }
public async Task <IActionResult> PutDiag(short id, Diag diag) { if (id != diag.DiagId) { return(BadRequest()); } if (diag.NameDiag == "deleted") { diag = _context.Diags.Where(p => p.DiagId == id).FirstOrDefault(); diag.Deleted = true; } _context.Entry(diag).State = EntityState.Modified; try { await _context.SaveChangesAsync(); } catch (DbUpdateConcurrencyException) { if (!DiagExists(id)) { return(NotFound()); } else { throw; } } return(Ok(diag)); }
public static async Task Aggregator( FPGA.InputSignal <bool> RXD, FPGA.OutputSignal <bool> TXD ) { uint clockCounter = 0; Diag.ClockCounter(clockCounter); Sequential handler = () => { FPU.FPUScopeNoSync(); const int width = 10; const int baud = 115200; ComplexFloat[] source = new ComplexFloat[GeneratorTools.ArrayLength(width)]; ComplexFloat[] target = new ComplexFloat[GeneratorTools.ArrayLength(width)]; FPGA.Config.NoSync(source); while (true) { RTX.ReadData(baud, RXD, source); uint start = clockCounter; FFT.Transform(width, source, target, Direction.Forward); uint end = clockCounter; RTX.WriteData(baud, TXD, target, end - start); } }; FPGA.Config.OnStartup(handler); }
private async void ListenButton_Click(object sender, RoutedEventArgs e) { if (listenState == listeningStates.notListening) { string serverPort = GetServerPort(); bool result = await Task <bool> .Factory.StartNew(() => { return(commModule.SetupTransport(null, serverPort)); }); Diag.DebugPrint("CommModule setup result: " + result); if (result == true) { ListenButton.Content = "Stop Listening"; listenState = listeningStates.listening; } else { ListenButton.Content = "failed to listen. click to retry"; listenState = listeningStates.notListening; } } else { await ResetTransportTaskAsync(); listenState = listeningStates.notListening; ListenButton.Content = "Listen"; } }
private async Task PhotoFromCamera() { if (!CrossMedia.Current.IsCameraAvailable || !CrossMedia.Current.IsTakePhotoSupported) { await Diag.AlertAsync(new AlertConfig() { Message = "No hay camara", OkText = "Ok" }); return; } var file = await CrossMedia.Current.TakePhotoAsync(new Plugin.Media.Abstractions.StoreCameraMediaOptions { Directory = "Test", SaveToAlbum = true, CompressionQuality = 75, CustomPhotoSize = 50, PhotoSize = PhotoSize.MaxWidthHeight, MaxWidthHeight = 2000, DefaultCamera = CameraDevice.Front }); if (file == null) { return; } contact.Photo = Base64Photo(file.GetStream()); sourceuserpic = ImageSource.FromStream(() => { var stream = file.GetStream(); file.Dispose(); return(stream); }); OnPropertyChanged("sourceuserpic"); }
private void OnSendRequestCompleted(IAsyncOperationWithProgress <HttpResponseMessage, HttpProgress> asyncInfo, AsyncStatus asyncStatus) { try { if (asyncStatus == AsyncStatus.Canceled) { Diag.DebugPrint("HttpRequestMessage.SendRequestAsync was canceled."); return; } if (asyncStatus == AsyncStatus.Error) { Diag.DebugPrint("HttpRequestMessage.SendRequestAsync failed: " + asyncInfo.ErrorCode); return; } Diag.DebugPrint("HttpRequestMessage.SendRequestAsync succeeded."); HttpResponseMessage response = asyncInfo.GetResults(); readAsInputStreamOperation = response.Content.ReadAsInputStreamAsync(); readAsInputStreamOperation.Completed = OnReadAsInputStreamCompleted; } catch (Exception ex) { Diag.DebugPrint("Error in OnSendRequestCompleted: " + ex.ToString()); } }
private async void Reload() { Diag.ThreadPrint("Reload start"); await LoadBankAccounts(); Diag.ThreadPrint("Reload end"); }
private void OnReadAsInputStreamCompleted(IAsyncOperationWithProgress <IInputStream, ulong> asyncInfo, AsyncStatus asyncStatus) { try { if (asyncStatus == AsyncStatus.Canceled) { Diag.DebugPrint("IHttpContent.ReadAsInputStreamAsync was canceled."); return; } if (asyncStatus == AsyncStatus.Error) { Diag.DebugPrint("IHttpContent.ReadAsInputStreamAsync failed: " + asyncInfo.ErrorCode); return; } Diag.DebugPrint("IHttpContent.ReadAsInputStreamAsync succeeded."); inputStream = asyncInfo.GetResults(); ReadMore(); } catch (Exception ex) { Diag.DebugPrint("Error in OnReadAsInputStreamCompleted: " + ex.ToString()); } }
private async Task LoadBankAccounts_ok() { Diag.ThreadPrint("Load start"); base.IsBusy = true; var target = new ActionBlock <BankAccount>(a => { bankAccounts.GetOrAdd(a.BankAccountId, a); Diag.ThreadPrint("In target. Account={0}", a.Name); }, new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 4 }); bankAccounts.Clear(); Diag.ThreadPrint("Load - before repo"); await this.bankAccountRepository.PostList(target); Diag.ThreadPrint("Load - after repo. qty={0}", bankAccounts.Count); base.DataList.Clear(); Diag.ThreadPrint("Load - after clear"); if (bankAccounts != null) { Diag.ThreadPrint("Load - before populate"); bankAccounts.Values.ToList().ForEach(a => { base.DataList.Add(new BankAccountItemViewModel(a)); }); Diag.ThreadPrint("Load - after populate"); } base.IsBusy = false; Diag.ThreadPrint("Load end"); }
protected ToggleButtonViewModel() { Diag.DataBindingPresentation(); ToggleButtonPosition = _leftAlignment; ToggleButtonMargins = _leftThickness; ToggleButtonColor = _leftColor; }
public async void Open() { Diag.ThreadPrint("Open start"); await LoadBankAccounts(); Diag.ThreadPrint("Open end"); }
public string ReadResponse(Task <HttpResponseMessage> httpResponseTask) { string message = null; try { if (httpResponseTask.IsCanceled || httpResponseTask.IsFaulted) { Diag.DebugPrint("Task is cancelled or has failed"); return(message); } // We'll wait until we got the whole response. This is the only supported // scenario for HttpClient for ControlChannelTrigger. HttpResponseMessage httpResponse = httpResponseTask.Result; Diag.DebugPrint("Reading from httpresponse"); if (httpResponse == null || httpResponse.Content == null) { Diag.DebugPrint("Cant read from httpresponse, as either httpResponse or its content is null. try to reset connection."); } else { // This is likely being processed in the context of a background task and so // synchronously read the Content's results inline so that the Toast can be shown. // before we exit the Run method. message = httpResponse.Content.ReadAsStringAsync().Result; } } catch (Exception exp) { Diag.DebugPrint("Failed to read from httpresponse with error: " + exp.ToString()); } return(message); }
public static Rot RotBetween(Vector3 v1, Vector3 v2) { Rot rResult = new Rot(); Vector3 VectorNorm1 = new Vector3(v1).Normalize(); Vector3 VectorNorm2 = new Vector3(v2).Normalize(); Vector3 RotationAxis = Vector3.CrossProduct(VectorNorm1, VectorNorm2); //Test.Debug( "math: " << RotationAxis ); // Test.Debug //Test.Debug( Math.Abs( RotationAxis.x ) << " " << Math.Abs( RotationAxis.y ) << " " << Math.Abs( RotationAxis.z ) ); // Test.Debug if (Math.Abs(RotationAxis.x) < 0.0005 && Math.Abs(RotationAxis.y) < 0.0005 && Math.Abs(RotationAxis.z) < 0.0005) { Vector3 RandomVector = new Vector3(VectorNorm1); RandomVector.x += 0.5; RandomVector.Normalize(); RotationAxis = Vector3.CrossProduct(VectorNorm1, RandomVector); rResult = mvMath.AxisAngle2Rot(RotationAxis, Math.PI); } else { double DotProduct = Vector3.DotProduct(VectorNorm1, VectorNorm2); Diag.Debug("DotProduct: " + DotProduct.ToString()); // Test.Debug double Vangle = Math.Acos(DotProduct); Diag.Debug("math: " + Vangle.ToString()); // Test.Debug rResult = AxisAngle2Rot(RotationAxis, Vangle); } return(rResult); }
public bool SetupTransport(Uri serverUriIn) { bool result = false; lock (this) { try { // Save these to help reconnect later. serverUri = serverUriIn; // Set up the CCT channel with the stream socket. result = RegisterWithCCT(); if (result == false) { Diag.DebugPrint("Failed to sign on and connect"); DisposeProperties(); } } catch (Exception ex) { Diag.DebugPrint("Failed to sign on and connect. Exception: " + ex.ToString()); DisposeProperties(); } } return(result); }
async void ClientInit() { commModule = new CommModule(); if (lockScreenAdded == false) { BackgroundAccessStatus status = await BackgroundExecutionManager.RequestAccessAsync(); Diag.DebugPrint("Lock screen status " + status); switch (status) { case BackgroundAccessStatus.AlwaysAllowed: case BackgroundAccessStatus.AllowedSubjectToSystemPolicy: lockScreenAdded = true; break; case BackgroundAccessStatus.DeniedBySystemPolicy: case BackgroundAccessStatus.DeniedByUser: Diag.DebugPrint("As lockscreen status was Denied, app should switch to polling mode such as email based on time triggers"); break; } } btnConnection.Visibility = Visibility.Visible; return; }
// Registers a background task with a network change system trigger. private void RegisterNetworkChangeTask() { try { // Delete previously registered network status change tasks as // the background triggers are persistent by nature across process // lifetimes. foreach (var cur in BackgroundTaskRegistration.AllTasks) { Diag.DebugPrint("Deleting Background Taks " + cur.Value.Name); cur.Value.Unregister(true); } var myTaskBuilder = new BackgroundTaskBuilder(); var myTrigger = new SystemTrigger(SystemTriggerType.NetworkStateChange, false); myTaskBuilder.SetTrigger(myTrigger); myTaskBuilder.TaskEntryPoint = "Background.NetworkChangeTask"; myTaskBuilder.Name = "Network change task"; var myTask = myTaskBuilder.Register(); } catch (Exception exp) { Diag.DebugPrint("Exception caught while setting up system event" + exp.ToString()); } }
private void SetUpHttpRequestAndSendToHttpServer() { try { AppendOriginToUri(); Diag.DebugPrint("SetUpHttpRequestAndSendToHttpServer started with URI: " + serverUri); // IMPORTANT: // For HTTP based transports that use ControlChannelTrigger, whenever we send the next request, // we will abort the earlier outstanding HTTP request and start a new one. // For example, when the HTTP server is taking longer to reply, and the keep alive trigger is fired // in-between then the keep alive task will abort the outstanding HTTP request and start a new request // which should be finished before the next keep alive task is triggered. ResetRequest(); httpRequest = new HttpRequestMessage(HttpMethod.Get, serverUri); SendHttpRequest(); } catch (Exception ex) { Diag.DebugPrint("Connect failed with: " + ex.ToString()); throw; } }
private async void Reload() { Diag.ThreadPrint("Reload start"); await LoadBalanceDates(); Diag.ThreadPrint("Reload end"); }
public async void Open() { Diag.ThreadPrint("Open start"); await LoadBalanceDates(); Diag.ThreadPrint("Open end"); }
private void BtnTeleportToCoordinates_Click(object sender, EventArgs e) { var sekiro = Utils.Sekiro(); if (sekiro == null) { return; } var cx = BitConverter.GetBytes(float.Parse(coordX.Text)); var cy = BitConverter.GetBytes(float.Parse(coordY.Text)); var cz = BitConverter.GetBytes(float.Parse(coordZ.Text)); var full = new byte[cx.Length + cy.Length + cz.Length]; Buffer.BlockCopy(cx, 0, full, 0, cx.Length); Buffer.BlockCopy(cy, 0, full, cx.Length, cy.Length); Buffer.BlockCopy(cz, 0, full, cx.Length + cy.Length, cx.Length); var remoteProc = new RemoteProcess(sekiro); var offsets = new byte[] { 0x48, 0x28, 0x80 }; var addr = new IntPtr(0x143B67DF0); addr = offsets.Aggregate(addr, (current, offset) => remoteProc.Read <IntPtr>(current) + offset); //remoteProc.Write<byte[]>(addr, full); remoteProc.WriteBytes(addr, full); Diag.WriteLine(BitConverter.ToString(full).Replace("-", "")); }
private async Task LoadBalanceDates() { Diag.ThreadPrint("Load start"); base.IsBusy = true; var target = new ActionBlock <BalanceDate>(a => { balanceDates.GetOrAdd(a.BalanceDateId, a); base.DataList.Add(new BalanceDateItemViewModel(a)); //Diag.ThreadPrint("In target. Account={0}", a.Name); }, new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 1 }); balanceDates.Clear(); base.DataList.Clear(); Diag.ThreadPrint("Load - before repo"); await this.balanceDateRepository.PostList(target).ConfigureAwait(false); Diag.ThreadPrint("Load - after repo. qty={0}", balanceDates.Count); await target.Completion.ConfigureAwait(false); Diag.ThreadPrint("Load - after target completion. qty={0}", balanceDates.Count); base.IsBusy = false; Diag.ThreadPrint("Load end"); }
private async Task LoadBalanceDates_old2() { var ts = TaskScheduler.FromCurrentSynchronizationContext(); Diag.ThreadPrint("Load start"); base.IsBusy = true; var tf = new TaskFactory(ts); var target = new ActionBlock <BalanceDate>(async a => { await tf.StartNew(() => { balanceDates.GetOrAdd(a.BalanceDateId, a); base.DataList.Add(new BalanceDateItemViewModel(a)); //Diag.ThreadPrint("In target. Account={0}", a.Name); }); }, new ExecutionDataflowBlockOptions() { MaxDegreeOfParallelism = 1 }); balanceDates.Clear(); base.DataList.Clear(); Diag.ThreadPrint("Load - before repo"); await this.balanceDateRepository.PostList(target); await target.Completion; Diag.ThreadPrint("Load - after repo. qty={0}", balanceDates.Count); base.IsBusy = false; Diag.ThreadPrint("Load end"); }
internal static void Compute( Order order, Side side, UpLo uplo, Transpose transA, Diag diag, int m,int n, double alpha, double[] A, int lda, double[] B, int ldb ){ if ( transA == Transpose.ConjTrans ) { transA = Transpose.Trans; } ArgumentCheck(side, m, n, A, lda, B, ldb); dna_blas_dtrsm(order, side, uplo, transA, diag, m, n, alpha, A, lda, B, ldb); }
internal static void Compute( Order order, Side side, UpLo uplo, Transpose transA, Diag diag, int m,int n, Complex alpha, Complex[] A, int lda, Complex[] B, int ldb ){ ArgumentCheck(side, m, n, A, lda, B, ldb); dna_blas_ztrsm(order, side, uplo, transA, diag, m, n, ref alpha, A, lda, B, ldb); }
private static extern void dna_blas_ztrsm( Order order, Side side, UpLo uplo, Transpose transA, Diag diag, int m,int n, ref Complex alpha, [In]Complex[] A, int lda, [In,Out]Complex[] B, int ldb );
private static extern void dna_blas_dtrsm( Order order, Side side, UpLo uplo, Transpose transA, Diag diag, int m,int n, double alpha, [In]double[] A, int lda, [In,Out]double[] B, int ldb );
private static extern void dna_blas_strsm( Order order, Side side, UpLo uplo, Transpose transA, Diag diag, int m,int n, float alpha, [In]float[] A, int lda, [In,Out]float[] B, int ldb );