private void run(object obj) { while (true) { Thread.Sleep(60000); try { // cleanup while (EventLists.Count > 200) { EventLists.RemoveAt(0); } while (DeviceLogs.Count > 200) { DeviceLogs.RemoveAt(0); } // save data hashDevices = saveData(hashDevices, JsonConvert.SerializeObject(Devices), "devices"); hashDeviceLogs = saveData(hashDeviceLogs, JsonConvert.SerializeObject(DeviceLogs), "devicelogs"); hashEventLists = saveData(hashEventLists, JsonConvert.SerializeObject(EventLists), "eventlists"); hashJbalotrons = saveData(hashJbalotrons, JsonConvert.SerializeObject(Jablotrons), "jablotrons"); } catch { } } }
private void OnRebuild(VoidPtr address, int length) { // Remove empty event lists for (int i = 0; i < EventLists.Count; i++) { if (EventLists.Values[i].Empty) { EventLists.RemoveAt(i); } } VoidPtr addr = address; // Base address. (0x00) Util.SetWordUnsafe(address, 0x444D4341, Endianness.Little); // ACMD //==========================================================================// // Rebuilding Header and offsets // //==========================================================================// Util.SetWordUnsafe(address + 0x04, 2, Runtime.WorkingEndian); // Version (2) Util.SetWordUnsafe(address + 0x08, EventLists.Count, Runtime.WorkingEndian); int count = EventLists.Values.Sum(e => e.Count); Util.SetWordUnsafe(address + 0x0C, count, Runtime.WorkingEndian); addr += 0x10; //===============Write Event List offsets and CRC's=================// for (int i = 0, prev = 0; i < EventLists.Count; i++) { int dataOffset = 0x10 + (EventLists.Count * 8) + prev; Util.SetWordUnsafe(addr, (int)EventLists.Keys[i], Runtime.WorkingEndian); Util.SetWordUnsafe(addr + 4, dataOffset, Runtime.WorkingEndian); prev += EventLists.Values[i].Size; addr += 8; } // Write event lists at final address. foreach (ACMDScript e in EventLists.Values) { e.Rebuild(addr, e.Size); addr += e.Size; } }