private void Reset() { IsRunning = false; if (_backgroundWorker.IsBusy) { _backgroundWorker.CancelAsync(); } Proc.Reset(); RaisePropertyChanged("Proc"); IsRunning = false; NumberOfCycles = 0; RaisePropertyChanged("NumberOfCycles"); UpdateMemoryPage(); RaisePropertyChanged("MemoryPage"); OutputLog.Clear(); RaisePropertyChanged("CurrentDisassembly"); OutputLog.Insert(0, GetOutputLog()); UpdateUi(); }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); string sIsRunning = node.GetValue("isRunning"); if (sIsRunning != null) { bool.TryParse(sIsRunning, out isRunning); } setRunning(); try { if (HighLogic.fetch && HighLogic.LoadedSceneIsFlight) { if (mProcessor == null) { mProcessor = new Processor.Processor(part, this); } mProcessor.Load(node); } } catch (Exception e) { Logging.Log(e.ToString()); }; }
private void UpdateMemoryPage() { MemoryPage.Clear(); var offset = (_memoryPageOffset * 256); var multiplyer = 0; for (var i = offset; i < 256 * (_memoryPageOffset + 1); i++) { MemoryPage.Add(new MemoryRowModel { Offset = ((16 * multiplyer) + offset).ToString("X").PadLeft(4, '0'), Location00 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location01 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location02 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location03 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location04 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location05 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location06 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location07 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location08 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location09 = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location0A = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location0B = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location0C = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location0D = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location0E = Proc.ReadMemoryValueWithoutCycle(i++).ToString("X").PadLeft(2, '0'), Location0F = Proc.ReadMemoryValueWithoutCycle(i).ToString("X").PadLeft(2, '0'), }); multiplyer++; } }
/// <summary> /// Creates a new Instance of the MainViewModel /// </summary> public MainViewModel() { Proc = new Proc(); Proc.Reset(); ResetCommand = new RelayCommand(Reset); StepCommand = new RelayCommand(Step); OpenCommand = new RelayCommand(OpenFile); RunPauseCommand = new RelayCommand(RunPause); UpdateMemoryMapCommand = new RelayCommand(UpdateMemoryPage); SaveStateCommand = new RelayCommand(SaveState); AddBreakPointCommand = new RelayCommand(AddBreakPoint); RemoveBreakPointCommand = new RelayCommand(RemoveBreakPoint); SendNonMaskableInterruptComand = new RelayCommand(SendNonMaskableInterrupt); SendInterruptRequestCommand = new RelayCommand(SendInterruptRequest); Messenger.Default.Register <NotificationMessage <AssemblyFileModel> >(this, FileOpenedNotification); Messenger.Default.Register <NotificationMessage <StateFileModel> >(this, StateLoadedNotifcation); FilePath = "No File Loaded"; MemoryPage = new MultiThreadedObservableCollection <MemoryRowModel>(); OutputLog = new MultiThreadedObservableCollection <OutputLog>(); Breakpoints = new MultiThreadedObservableCollection <Breakpoint>(); UpdateMemoryPage(); _backgroundWorker = new BackgroundWorker { WorkerSupportsCancellation = true, WorkerReportsProgress = false }; _backgroundWorker.DoWork += BackgroundWorkerDoWork; }
static void Main(string[] args) { var container = new BootStrapper(); container.RegisterComponents(); IProcessor processor = new Processor.Processor(); processor.ProcessMessage(); }
private void SendInterruptRequest() { IsRunning = false; if (_backgroundWorker.IsBusy) { _backgroundWorker.CancelAsync(); } Proc.InterruptRequest(); UpdateMemoryPage(); OutputLog.Insert(0, GetOutputLog()); UpdateUi(); }
public override void OnSave(ConfigNode node) { base.OnSave(node); node.AddValue("isRunning", isRunning); try { if (HighLogic.fetch && HighLogic.LoadedSceneIsFlight) { if (mProcessor == null) { mProcessor = new Processor.Processor(part, this); } mProcessor.Save(node); } } catch (Exception e) { Logging.Log(e.ToString()); } }
private void FileOpenedNotification(NotificationMessage <AssemblyFileModel> notificationMessage) { if (notificationMessage.Notification != "FileLoaded") { return; } Proc.LoadProgram(notificationMessage.Content.MemoryOffset, notificationMessage.Content.Program, notificationMessage.Content.InitialProgramCounter); FilePath = string.Format("Loaded Program: {0}", notificationMessage.Content.FilePath); RaisePropertyChanged("FilePath"); IsProgramLoaded = true; RaisePropertyChanged("IsProgramLoaded"); Listing = notificationMessage.Content.Listing; RaisePropertyChanged("Listing"); Reset(); }
public Listener() { processor = new Processor.Processor(); }
private void StepProcessor() { Proc.NextStep(); NumberOfCycles = Proc.GetCycleCount(); }
/// <summary> /// Creates a new Instance of the MainViewModel /// </summary> public MainViewModel() { Proc = new Proc(); Proc.Reset(); ResetCommand = new RelayCommand(Reset); StepCommand = new RelayCommand(Step); OpenCommand = new RelayCommand(OpenFile); RunPauseCommand = new RelayCommand(RunPause); UpdateMemoryMapCommand = new RelayCommand(UpdateMemoryPage); SaveStateCommand = new RelayCommand(SaveState); AddBreakPointCommand = new RelayCommand(AddBreakPoint); RemoveBreakPointCommand = new RelayCommand(RemoveBreakPoint); SendNonMaskableInterruptComand = new RelayCommand(SendNonMaskableInterrupt); SendInterruptRequestCommand = new RelayCommand(SendInterruptRequest); Messenger.Default.Register<NotificationMessage<AssemblyFileModel>>(this, FileOpenedNotification); Messenger.Default.Register<NotificationMessage<StateFileModel>>(this, StateLoadedNotifcation); FilePath = "No File Loaded"; MemoryPage = new MultiThreadedObservableCollection<MemoryRowModel>(); OutputLog = new MultiThreadedObservableCollection<OutputLog>(); Breakpoints = new MultiThreadedObservableCollection<Breakpoint>(); UpdateMemoryPage(); _backgroundWorker = new BackgroundWorker {WorkerSupportsCancellation = true, WorkerReportsProgress = false}; _backgroundWorker.DoWork += BackgroundWorkerDoWork; }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); string sIsRunning = node.GetValue("isRunning"); if (sIsRunning != null) bool.TryParse(sIsRunning, out isRunning); setRunning(); try { if (HighLogic.fetch && HighLogic.LoadedSceneIsFlight) { if (mProcessor == null) mProcessor = new Processor.Processor(part, this); mProcessor.Load(node); } } catch (Exception e) { Logging.Log(e.ToString()); }; }
public override void OnSave(ConfigNode node) { base.OnSave(node); node.AddValue("isRunning", isRunning); try { if (HighLogic.fetch && HighLogic.LoadedSceneIsFlight) { if (mProcessor == null) mProcessor = new Processor.Processor(part, this); mProcessor.Save(node); } } catch (Exception e) { Logging.Log(e.ToString()); } }
public static void Run([TimerTrigger("0 */10 * * * *")] TimerInfo myTimer, ILogger log) { log.LogInformation(Constants.RequestProcessingStarted); StorageHandler.StorageHandler storageHandler = new StorageHandler.StorageHandler(log); OperationDetails LastOperationDetails = null; try { log.LogInformation(Constants.RequestLastExecutionTime); //Fetch the last execution time and status LastOperationDetails = storageHandler.GetLastOperationDetailsFromLogsAsync(Environment.GetEnvironmentVariable(Constants.LogFileName)).Result; //if there is the first time or no info found if (LastOperationDetails?.LastRunEndTime == null) { LastOperationDetails = new OperationDetails(); log.LogWarning(Constants.LastExecutionTimeNotFound); try { //Fetch the info form configuration //Start set to current time - connectioninterval LastOperationDetails.LastRunEndTime = DateTime.Parse(Environment.GetEnvironmentVariable(Constants.AuditLogExtractionStartDate)); LastOperationDetails.LastRunStartTime = LastOperationDetails.LastRunEndTime?.AddMinutes(-Convert.ToInt32(Environment.GetEnvironmentVariable(Constants.ConnectionIntervalInMinutes))); } catch (Exception) { //if no configuration is found , set the start time and end time LastOperationDetails.LastRunEndTime = DateTime.UtcNow; LastOperationDetails.LastRunStartTime = LastOperationDetails.LastRunEndTime?.AddMinutes(-Convert.ToInt32(Environment.GetEnvironmentVariable(Constants.ConnectionIntervalInMinutes))); log.LogWarning(Constants.AuditLogExtractionStartDateMissing); } } else { LastOperationDetails.LastRunStartTime = LastOperationDetails.LastRunEndTime; LastOperationDetails.LastRunEndTime = LastOperationDetails.LastRunEndTime?.AddMinutes(Convert.ToInt32(Environment.GetEnvironmentVariable(Constants.ConnectionIntervalInMinutes))); } log.LogInformation(Constants.OMSRequestProcessStarted); log.LogWarning($"Daterange set: start time : { LastOperationDetails.LastRunStartTime} , endtime { LastOperationDetails.LastRunEndTime}"); Teams.CustomConnector.Processor.Processor processor = new Processor.Processor(log); //fetch the details. auditDetailedReports = processor.Process(LastOperationDetails.LastRunStartTime?.ToString("G", CultureInfo.InvariantCulture), LastOperationDetails.LastRunEndTime?.ToString("G", CultureInfo.InvariantCulture)).Result; log.LogInformation($"Total {auditDetailedReports.Count} of audit logs found"); if (auditDetailedReports.Count > 0) { //upload to the container var reports = JsonConvert.SerializeObject(auditDetailedReports); if (Convert.ToBoolean(Environment.GetEnvironmentVariable(Constants.EnableDirectInjestionToWorkSpace))) { string SentinelWkSpaceId = string.Empty; string SentinelSharedkey = string.Empty; if (Convert.ToBoolean(Environment.GetEnvironmentVariable(Constants.KeyVaultEnabled))) { SentinelWkSpaceId = KeyVaultHelper.GetKeyValueAsync(Constants.SentinelCustomerId).Result; SentinelSharedkey = KeyVaultHelper.GetKeyValueAsync(Constants.SentinelSharedkey).Result; } else { SentinelWkSpaceId = Environment.GetEnvironmentVariable(Constants.SentinelCustomerId); SentinelSharedkey = Environment.GetEnvironmentVariable(Constants.SentinelSharedkey); } AzureLogAnalyticsConnector azureLogAnalyticsConnector = new Sentinel.AzureLogAnalyticsConnector(SentinelWkSpaceId, SentinelSharedkey, "TeamsAuditLogs"); azureLogAnalyticsConnector.Post(reports); } if (Convert.ToBoolean(Environment.GetEnvironmentVariable(Constants.EnableArchiving))) { Task.Run(async() => await storageHandler.UploadDataToContainerAsync(OperationType.Data, LastOperationDetails.LastRunStartTime?.Ticks.ToString(), reports)); } } LastOperationDetails.IsLastRunSuccessful = true; } catch (Exception ex) { log.LogError(ex, Constants.OMSRequestProcessFailed); log.LogError($"{Constants.FatalError} , {ex.Message} , {ex.InnerException.ToString()}"); LastOperationDetails.IsLastRunSuccessful = false; } if (!LastOperationDetails.IsLastRunSuccessful) { LastOperationDetails.TotalFailCountSinceLastSuccessfulRun++; } else { LastOperationDetails.TotalFailCountSinceLastSuccessfulRun = 0; } //update the last run details. LastOperationDetails.TotalAuditRecordsProcessed = auditDetailedReports.Count; LastOperationDetails.TotalRecordsProcessedInLifeTime += LastOperationDetails.TotalAuditRecordsProcessed; var opdetails = JsonConvert.SerializeObject(LastOperationDetails); Task.Run(() => storageHandler.UploadDataToContainerAsync(OperationType.Log, Environment.GetEnvironmentVariable(Constants.LogFileName), opdetails)); log.LogInformation(Constants.RequestProcessed); }