public void Set(MemoryType type, object value, uint index)
        {
            if (index >= memory.Length)
            {
                throw new IndexOutOfRangeException("Set");
            }

            memory[index] = new MemorySlot(type, value);
        }
示例#2
0
        public Mem()
        {
            _type = MemoryType.Native;
            _segmentPrefix = SegmentPrefix.None;

            _base = RegIndex.Invalid;
            _index = RegIndex.Invalid;
            _scalingFactor = ScalingFactor.Times1;

            _target = IntPtr.Zero;
            _displacement = IntPtr.Zero;
        }
示例#3
0
        public EraseViewModel(string portName, SerialPortSettings serialPortSettings, ILoggerFacade logger, MemoryType type, IMemory memory)
            : base(portName, serialPortSettings, logger)
        {
            Text = "Erase " + ((type == MemoryType.FLASH) ? "FLASH" : "EEPROM");
            taskm = new TaskManager<bool>((taskManager) =>
            {
                return (new ErasePageWorkerSlave(portName, serialPortSettings, logger, type, memory).Run(taskManager));
            });

            taskm.Canceled += taskm_Canceled;
            taskm.Completed += taskm_Completed;
            taskm.Faulted += taskm_Faulted;
            taskm.Started += taskm_Started;
        }
示例#4
0
        private void WriteData(
            long Position,
            IList <byte> Data,
            MemoryType Type,
            AMemoryPerm Perm)
        {
            Memory.Manager.MapPhys(Position, Data.Count, (int)Type, AMemoryPerm.Write);

            for (int Index = 0; Index < Data.Count; Index++)
            {
                Memory.WriteByte(Position + Index, Data[Index]);
            }

            Memory.Manager.Reprotect(Position, Data.Count, Perm);
        }
        // hook_mem_invalid
        private static bool InvalidMemoryHook(Emulator emulator, MemoryType type, ulong address, int size, ulong value, object userData)
        {
            switch (type)
            {
            case MemoryType.WriteUnmapped:
                Console.WriteLine($">>> Missing memory is being WRITE at 0x{address.ToString("x2")}, data size = {size}, data value = 0x{value.ToString("x2")}");

                // Map missing memory & return true to tell unicorn we want to continue execution.
                emulator.Memory.Map(0xAAAA0000, 2 * 1024 * 1024, MemoryPermissions.All);
                return(true);

            default:
                return(false);
            }
        }
示例#6
0
        public void Equals()
        {
            var a = new MemoryType(TestValues.Limits);
            var b = new MemoryType(TestValues.Limits);

            Assert.That(a.Equals(a), Is.True);
            Assert.That(a.Equals(b), Is.True);
            Assert.That(a.Equals(null), Is.False);
            Assert.That(a.Equals((object)a), Is.True);
            Assert.That(a.Equals((object)b), Is.True);
            Assert.That(a.Equals((object)null), Is.False);
            Assert.That(a.GetHashCode(), Is.EqualTo(b.GetHashCode()));
            Assert.That(a == b, Is.True);
            Assert.That(a != b, Is.False);
        }
示例#7
0
 protected MemorySafeEnumerator(MemoryType memoryType)
 {
     if (memoryType == MemoryType.Safe)
     {
         throw new NotSupportedException("Memory type safe is currently not supported in .NET Standard");
     }
     if (memoryType == MemoryType.Strict)
     {
         throw new NotSupportedException("Memory type strict is currently not supported in .NET Standard");
     }
     MemoryType = memoryType;
     // TODO: Update for .NET Standard 2.0 (will support Thread)...
     //MainThreadId = Thread.CurrentThread.ManagedThreadId;
     IteratorState = -1;
 }
示例#8
0
        public void Keys_works_multiple_times(MemoryType memoryType, int numberOfIterations, int expectedResult)
        {
            var dictionary = new TreeDictionary<int, string>(memoryType) { { 1, "One" }, { 2, "Two" }, { 3, "Three" }, { 4, "Four" } };

            var sum = 0;
            for (var i = 0; i < numberOfIterations; i++)
            {
                foreach (var value in dictionary.Keys)
                {
                    sum += value;
                }
            }

            Assert.AreEqual(expectedResult, sum);
        }
示例#9
0
        public void Values_works_multiple_times(MemoryType memoryType, int numberOfIterations, int expectedResult)
        {
            var dictionary = new TreeDictionary<string, int>(memoryType) { { "One", 1 }, { "Two", 2 }, { "Three", 3 }, { "Four", 4 } };

            var sum = 0;
            for (var i = 0; i < numberOfIterations; i++)
            {
                foreach (var value in dictionary.Values)
                {
                    sum += value;
                }
            }

            Assert.AreEqual(expectedResult, sum);
        }
示例#10
0
        public Mem(IntPtr target, IntPtr displacement, SegmentPrefix segmentPrefix, int size = 0)
            : base(size: size)
        {
            Contract.EndContractBlock();

            _type = MemoryType.Absolute;
            _segmentPrefix = segmentPrefix;

            _base = RegIndex.Invalid;
            _index = RegIndex.Invalid;
            _scalingFactor = ScalingFactor.Times1;

            _target = target;
            _displacement = displacement;
        }
示例#11
0
        /// <summary>
        /// Возвращает запрос (без CRC) на чтение указанного числа байт из заданной области памяти
        /// </summary>
        public static byte[] CreateReadMemoryRequest(MemoryType MemoryType, int controllerAddress, int Address, Type type)
        {
            List <byte> l = new List <byte>();

            l.Add((byte)controllerAddress);
            byte command       = 0;
            int  AddressLength = 0;

            switch (MemoryType)
            {
            case MemoryType.RAM:
                command       = (byte)0x50;
                AddressLength = 1;
                break;

            case MemoryType.Clock:
                command       = (byte)0x51;
                AddressLength = 1;
                break;

            case MemoryType.EEPROM:
                command       = (byte)0x52;
                AddressLength = 2;
                break;

            case MemoryType.FRAM:
                command       = (byte)0x53;
                AddressLength = 2;
                break;

            case MemoryType.XRAM:
                command       = (byte)0x54;
                AddressLength = 2;
                break;

            case MemoryType.Flash:
                command       = (byte)0x55;
                AddressLength = 2;
                break;

            default:
                throw new Exception("Указанный тип памяти " + MemoryType + " не поддерживается в " + type);
            }
            l.Add(command);
            byte[] a = AppliedMath.IntToBytes(Address);
            l.AddRange(Utils.GetSubArray <byte>(a, a.Length - AddressLength));
            return(l.ToArray());
        }
示例#12
0
        /// <summary>
        /// Добавление элемента в очередь
        /// </summary>
        /// <param name="Queuetype">Тип запроса (чтение/запись)</param>
        /// <param name="Memorytype">Тип памяти</param>
        /// <param name="Address">Начальный адрес</param>
        /// <param name="Count">Количество байт для чтения</param>
        /// <param name="Period">Период опроса</param>
        /// <param name="CycleElement">Флаг цикличности</param>
        /// <param name="Recording_Buffe">Записываемых буфер</param>
        /// <param name="Callback">Функция обратного вызова</param>
        /// <returns>Уникальный номер в очереди</returns>
        public Guid AddElementInQueue
        (
            DebuggerPrimitive.ActionType Queuetype,
            MemoryType Memorytype,
            int Address,
            byte[] Recording_Buffe,
            int Count,
            bool CycleElement,
            int Period,
            ProceedingCompleetedDelegate Callback
        )
        {
            Guid m_ret = AddElement(null, Queuetype, Memorytype, Address, Recording_Buffe, Count, CycleElement, Period, Callback, null);

            return(m_ret);
        }
示例#13
0
 /// <summary>
 /// Добавляет в очередь опороса отладчика объект записи данных
 /// </summary>
 /// <param name="Address">Адрес области памяти, к которой производится обращение</param>
 /// <param name="MemoryType">Тип области памяти, которой производится обращение</param>
 /// <param name="Count">Число байт, которое надо считать</param>
 /// <param name="Sender">Опрашиваемый объект</param>
 /// <param name="ProgressChangedCallback">Callback для получения информации о процессе опроса</param>
 /// <param name="CompleetingCallback">Callback для порлучения информации о завершении опроса</param>
 public void AddWriteItem(int Address, MemoryType MemoryType, byte[] Buffer, object Sender,
                          ProceedingProgressChangedDelegate ProgressChangedCallback, ProceedingCompleetedDelegate CompleetingCallback)
 {
     lock (this.writeItems)
     {
         this.writeItems.Add(new RequestItem()
         {
             Address    = Address,
             MemoryType = MemoryType,
             Data       = Buffer,
             Sender     = Sender,
             ProgressChangedCallback     = ProgressChangedCallback,
             ProceedingCompletedCallback = CompleetingCallback
         });
     }
 }
示例#14
0
        public WriteViewModel(string portName, SerialPortSettings serialPortSettings, ILoggerFacade logger,
                              MemoryType type, IMemory memory)
            : base(portName, serialPortSettings, logger)
        {
            Text = "Write " + ((type == MemoryType.FLASH) ? "FLASH" : "EEPROM");

            taskm = new TaskManager <bool>((taskManager) =>
            {
                return(new WritePageWorkerSlave(portName, serialPortSettings, logger, type, memory).Run(taskManager));
            });

            taskm.Canceled  += taskm_Canceled;
            taskm.Completed += taskm_Completed;
            taskm.Faulted   += taskm_Faulted;
            taskm.Started   += taskm_Started;
        }
示例#15
0
 public void SetValue(object value, MemoryType type, bool canOverrideType)
 {
     if (canOverrideType)
     {
         m_type = type;
         ResetValues();
         SetValueInternal(value, type);
     }
     else
     {
         if (m_type == type)
         {
             SetValueInternal(value, type);
         }
     }
 }
示例#16
0
        public override void FillProcess()
        {
            Console.Write("Processor name: ");
            ProcessorName = Console.ReadLine();

            Console.Write("RAM memory (GB): ");
            RamMemoryGb = Convert.ToInt32(Console.ReadLine());

            Console.Write("Memory type: ");
            MemoryType = Enum.Parse <MemoryType>(Console.ReadLine());

            Console.Write("Screen size: ");
            ScreenSize = Convert.ToSingle(Console.ReadLine());

            base.FillProcess();
        }
        public UsersAndRewardsDataProvider(MemoryType type)
        {
            switch (type)
            {
            case MemoryType.DataBase:
            {
                memory = new DataBaseUserAndReward();
                break;
            }

            case MemoryType.Memory:
            {
                memory = new UserAndRewardList();
                break;
            }
            }
        }
示例#18
0
        public virtual ICarOwnersRepository CreateRepository(MemoryType memory = MemoryType.InMemory, string connectionString = "")
        {
            ICarOwnersRepository carOwners = null;

            switch (memory)
            {
            case MemoryType.MongoDB:
                try{ carOwners = new CarOwnersRepository(connectionString); }
                catch { carOwners = new CarOwnersInMemRepository(); }
                break;

            default:
                carOwners = new CarOwnersInMemRepository();
                break;
            }
            return(carOwners);
        }
示例#19
0
        /// <summary>
        /// Allocates a new memory pool.
        /// </summary>
        /// <param name="dev">Device to allocate on</param>
        /// <param name="blockSize">Memory block size</param>
        /// <param name="blockCount">Number of blocks to allocate</param>
        /// <param name="usage">buffer usage</param>
        /// <param name="flags">buffer creation flags</param>
        /// <param name="memoryType">Memory to use</param>
        /// <param name="sharedQueueFamilies">Concurrency mode, or exclusive if empty</param>
        public BufferPool(Device dev, ulong blockSize, ulong blockCount, VkBufferUsageFlag usage,
                          VkBufferCreateFlag flags, MemoryType memoryType, params uint[] sharedQueueFamilies)
        {
            Device = dev;
            var bitAlignment = (uint)System.Math.Ceiling(System.Math.Log(blockSize) / System.Math.Log(2));

            blockSize = (1UL << (int)bitAlignment);
            _pool     = new MemoryPool(blockSize * blockCount, bitAlignment);
            _buffer   = new PooledMemoryBuffer(dev, usage, flags, new MemoryRequirements()
            {
                TypeRequirements = new VkMemoryRequirements()
                {
                    MemoryTypeBits = 1u << (int)memoryType.TypeIndex
                }
            },
                                               blockSize * blockCount, sharedQueueFamilies);
        }
示例#20
0
        private string GetTypeStr(MemoryType type)
        {
            switch (type)
            {
            case MemoryType.Image:
                return("Image");

            case MemoryType.Mapped:
                return("Mapped");

            case MemoryType.Private:
                return("Private");

            default:
                return("Unknown");
            }
        }
示例#21
0
        public ActionResult Create(MemoryType item)
        {
            if (item.Validate() is Exception ex)
            {
                return(View("Error", ex));
            }

            Derictory.Add(item);

            if (Derictory.Error is Exception ex2)
            {
                return(View("Error", ex2));
            }
            else
            {
                return(RedirectToAction("Index"));
            }
        }
示例#22
0
        /// <summary>
        /// Записывает указанный массив байт в некоторую область памяти
        /// </summary>
        public void WriteToMemory(MemoryType MemoryType, int Address, byte[] Data)
        {
            int PacketSize = _bufferSize - 16;
            int c          = 0;

            do
            {
                int    i        = Math.Min(Data.Length - c, PacketSize);
                byte[] response = this.SendRequest(this.CreateWriteMemoryRequest(MemoryType, Address, Utils.GetSubArray <byte>(Data, c, i)), 4);
                c += i;

                if (response == null && !_canceled)
                {
                    throw new Exception("Сбой при обращении к контроллеру");
                }
                Address += i;
            }while (c != Data.Length && !_canceled);
        }
示例#23
0
        static void NewMemoryItem(dynamic metadata, dynamic content, MemoryType memory)
        {
            var text      = content.Text.ToString();
            var parentId  = content.ParentId.ToString();
            var id        = metadata.ReferenceKey.ToString();
            var hint      = content.Hint.ToString();
            var groupKey  = metadata.GroupKey.ToString();
            var memberKey = metadata.MemberKey.ToString();

            if (!Memories.Any(t => t.Id == id || (t.ParentId == parentId && t.Text == text)))
            {
                AddMemoryItem(id, groupKey, memberKey, text, hint, parentId, GetCreateDate(metadata), memory);
            }
            else
            {
                SendFeedbackMessage(type: MsgType.Error, actionTime: GetCreateDate(metadata), action: MapAction.MemoryFeedback.CannotAddMemory.Name, content: "Cannot add dupicate memory item!");
            }
        }
示例#24
0
        public void KeyValuePairs_works_multiple_times(MemoryType memoryType, int numberOfIterations, int expectedResult)
        {
            var dictionary = new TreeDictionary<int, int>(memoryType) { { 1, -1 }, { 2, -2 }, { 3, -3 }, { 4, -4 } };

            var keys = 0;
            var values = 0;
            for (var i = 0; i < numberOfIterations; i++)
            {
                foreach (var kv in dictionary)
                {
                    keys += kv.Key;
                    values += kv.Value;
                }
            }

            Assert.AreEqual(expectedResult, keys);
            Assert.AreEqual(-expectedResult, values);
        }
示例#25
0
        public void Keys_works_multiple_times(MemoryType memoryType, int numberOfIterations, int expectedResult)
        {
            var dictionary = new TreeDictionary <int, string>(memoryType)
            {
                { 1, "One" }, { 2, "Two" }, { 3, "Three" }, { 4, "Four" }
            };

            var sum = 0;

            for (var i = 0; i < numberOfIterations; i++)
            {
                foreach (var value in dictionary.Keys)
                {
                    sum += value;
                }
            }

            Assert.AreEqual(expectedResult, sum);
        }
示例#26
0
        public Mem(GPReg @base, IntPtr displacement, int size = 0)
            : base(size: size)
        {
            if (@base == null)
                throw new ArgumentNullException("base");
            Contract.EndContractBlock();

            _type = MemoryType.Native;
            _segmentPrefix = SegmentPrefix.None;

            _sizePrefix = @base.Size != IntPtr.Size;

            _base = @base.RegisterIndex;
            _index = RegIndex.Invalid;
            _scalingFactor = ScalingFactor.Times1;

            _target = IntPtr.Zero;
            _displacement = displacement;
        }
        /// <summary>
        /// Command code 44: The status reading of continuous discrete.
        /// </summary>
        /// <param name="slaveStationNo">Slave Station No</param>
        /// <param name="numberOfPoints">Number Of Points.</param>
        /// <param name="mType">Memory Type</param>
        /// <param name="startNo">Start No</param>
        /// <param name="dType">Data Type</param>
        /// <returns>bool[]</returns>
        public bool[] ReadDiscretes(int slaveStationNo, ushort numberOfPoints, MemoryType mType, ushort startNo, DataType dType)
        {
            List <bool> result = new List <bool>();

            try
            {
                if (numberOfPoints < 1 || numberOfPoints > 256)
                {
                    throw new InvalidOperationException("Number of points is invalid, Number of points valid: 1 to 256.");
                }
                string frame = this.GetMessageReadDiscretes(slaveStationNo, CommandCode.THE_STATUS_READING_OF_CONTINUOUS_DISCRETE, numberOfPoints, mType, startNo, dType);
                objSerialPort.WriteLine(frame);

                // Read SerialPort
                int      sizeOfMessageReceiver = numberOfPoints + 9;
                string   buffReceiver          = string.Empty;
                DateTime startDateTime         = DateTime.Now;
                do
                {
                    this.CheckBufferReceiver(buffReceiver);
                    buffReceiver = objSerialPort.ReadExisting();
                    System.Threading.Thread.Sleep(100);
                } while (buffReceiver.Length < sizeOfMessageReceiver && (DateTime.Now.Subtract(startDateTime).TotalMilliseconds < objSerialPort.ReadTimeout));
                string errorMsg = this.GetException(buffReceiver);
                if (!string.IsNullOrEmpty(errorMsg) || !string.IsNullOrWhiteSpace(errorMsg))
                {
                    throw new Exception(errorMsg);
                }

                string dataReceiver = buffReceiver.Substring(6, numberOfPoints);
                foreach (char item in dataReceiver)
                {
                    result.Add(!"0".Equals(item.ToString())? true : false);
                }
                //Console.WriteLine("buffReceiver: {0}", buffReceiver);
                //Console.WriteLine("dataReceiver: {0}", dataReceiver);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(result.ToArray());
        }
示例#28
0
 private string GetTypeStr(MemoryType type)
 {
     if (type == MemoryType.Image)
     {
         return("Image");
     }
     else if (type == MemoryType.Mapped)
     {
         return("Mapped");
     }
     else if (type == MemoryType.Private)
     {
         return("Private");
     }
     else
     {
         return("Unknown");
     }
 }
示例#29
0
        public void Values_works_multiple_times(MemoryType memoryType, int numberOfIterations, int expectedResult)
        {
            var dictionary = new TreeDictionary <string, int>(memoryType)
            {
                { "One", 1 }, { "Two", 2 }, { "Three", 3 }, { "Four", 4 }
            };

            var sum = 0;

            for (var i = 0; i < numberOfIterations; i++)
            {
                foreach (var value in dictionary.Values)
                {
                    sum += value;
                }
            }

            Assert.AreEqual(expectedResult, sum);
        }
示例#30
0
        static Memory AddMemory(MemoryLayout layout, string name, MemoryType type, string[] data, int baseIndex, bool required)
        {
            if (data[baseIndex] == "")
            {
                if (required)
                    throw new Exception(name + " not defined!");
                return null;
            }

            layout.Memories.Add(new Memory
            {
                Name = name,
                Access = MemoryAccess.Undefined,
                Type = type,
                Start = ParseHex(data[baseIndex]),
                Size = uint.Parse(data[baseIndex + 1]) * 1024
            });

            return layout.Memories[layout.Memories.Count - 1];
        }
        public object GetValue(MemoryType type)
        {
            if (type != Type)
            {
                return(null);
                // throw new InvalidOperationException("GetValue: Type mismatch.");
            }

            switch (type)
            {
            case MemoryType.Int:
                return((int)Value);

            case MemoryType.Char:
                return((char)Value);

            default:
                throw new InvalidOperationException("GetValue: Invalid type.");
            }
        }
        }                                     //Size in GB

        /// <summary>
        /// Initializes a new Memory component
        /// </summary>
        /// <param name="readSpeed">The read speed in MHz</param>
        /// <param name="writeSpeed">The write speed in MHz</param>
        /// <param name="type">The memory type, either DDR1 to 4</param>
        /// <param name="size">The amount of memory in GB</param>
        public Memory(int readSpeed, int writeSpeed, MemoryType type, int size)
        {
            if (readSpeed < 0)
            {
                throw new ArgumentOutOfRangeException("Read Speed must be a positive value");
            }
            if (writeSpeed < 0)
            {
                throw new ArgumentOutOfRangeException("Write Speed must be a positive value");
            }
            if (size < 0)
            {
                throw new ArgumentOutOfRangeException("Size must be a positive value");
            }

            ReadSpeed  = readSpeed;
            WriteSpeed = writeSpeed;
            Type       = type;
            Size       = size;
        }
        private UInt64 AggregateMemorySize(AndroidMemoryStatistics stats, MemoryType type)
        {
            UInt64 total = 0;

            MemoryType[] types = GetOrderMemoryTypes();
            for (int i = types.Length - 1; i >= 0; i--)
            {
                if (types[i] == type)
                {
                    return(total);
                }
                if (!m_State.MemoryTypeEnabled[i])
                {
                    continue;
                }
                total += stats.GetValue(m_State.MemoryGroup, types[i]);
            }

            throw new Exception("Unhandled memory type: " + type);
        }
示例#34
0
        public static uint GetMemoryTypeIndex(uint memoryTypeBits, MemoryPropertyFlags desiredMemoryFlags)
        {
            uint memoryTypeIndex = 0;
            PhysicalDeviceMemoryProperties physicalDeviceMemoryProperties = VContext.Instance.physicalDevice.GetMemoryProperties();

            for (uint i = 0; i < physicalDeviceMemoryProperties.MemoryTypeCount; i++)
            {
                if ((memoryTypeBits & 1) == 1)
                {
                    MemoryType memoryType = physicalDeviceMemoryProperties.MemoryTypes[i];
                    if ((memoryType.PropertyFlags & desiredMemoryFlags) == desiredMemoryFlags)
                    {
                        memoryTypeIndex = i;
                        break;
                    }
                }
                memoryTypeBits >>= 1;
            }

            return(memoryTypeIndex);
        }
示例#35
0
        public MemoryInstanceType(Type type)
        {
            this.type = type;

            if (type.IsSubclassOf(typeof(MonoBehaviour)))
            {
                memoryType = MemoryType.MonoBehaviour;
            }
            else if (type.IsSubclassOf(typeof(Component)))
            {
                memoryType = MemoryType.Component;
            }
            else if (type.IsSubclassOf(typeof(ScriptableObject)))
            {
                memoryType = MemoryType.ScriptableObject;
            }
            else
            {
                memoryType = MemoryType.Other;
            }
        }
示例#36
0
        /// <summary>
        /// Добавляет в очередь опороса отладчика элемент чтения данных данных
        /// </summary>
        /// <param name="Address">Адрес области памяти, к которой производится обращение</param>
        /// <param name="MemoryType">Тип области памяти, которой производится обращение</param>
        /// <param name="Buffer">Записываемые даные</param>
        /// <param name="Sender">Опрашиваемый объект</param>
        /// <param name="ProgressChangedCallback">Callback для получения информации о процессе опроса</param>
        /// <param name="CompleetingCallback">Callback для порлучения информации о завершении опроса</param>
        public void AddReadItem(int Address, MemoryType MemoryType, int Count, object Sender,
                                ProceedingProgressChangedDelegate ProgressChangedCallback, ProceedingCompleetedDelegate CompleetingCallback)
        {
            RequestItem item = new RequestItem()
            {
                Address                     = Address,
                Data                        = new byte[Count],
                MemoryType                  = MemoryType,
                RequestType                 = RequestType.Read,
                Sender                      = Sender,
                ProgressChangedCallback     = ProgressChangedCallback,
                ProceedingCompletedCallback = CompleetingCallback
            };

            this.lockingMemoryType = MemoryType;
            this.lockingAddress    = Address;
            this.lockingLength     = Count;
            this.lockingActive     = true;
            this.AddReadItem(item);
            this.lockingActive = false;
        }
示例#37
0
        public void RegisterWatcher(string name, Type valueType, MemoryType memoryType, int address)
        {
            if (addressOffsets.ContainsKey(name))
            {
                addressOffsets.Remove(name);
            }

            addressOffsets.Add(name, new AddressOffset {
                ValueType = valueType, BaseMemoryType = memoryType, Address = address
            });

            if (IsRunning())
            {
                if (watchers.ContainsKey(name))
                {
                    watchers.Remove(name);
                }

                watchers.Add(name, (MemoryWatcher)Activator.CreateInstance(typeof(MemoryWatcher <>).MakeGenericType(valueType), new DeepPointer(GetBaseAddress(memoryType), address)));
            }
        }
示例#38
0
        public static bool WriteTagMemory(uint address, byte[] data, string uid, Reader reader)
        {
            bool flag = false;

            byte[]      _uid    = ByteFormat.FromHex(uid);
            TagFilter   filter  = new Select_UID((byte)(_uid.Length * 8), _uid);
            MemoryType  type    = MemoryType.BLOCK_MEMORY;
            WriteMemory writeOp = new WriteMemory(type, address, data);

            try
            {
                reader.ExecuteTagOp(writeOp, filter);
                flag = true;
            }
            catch (Exception)
            {
                flag = false;
                //throw;
            }
            return(flag);
        }
示例#39
0
        /// <summary>
        /// Allocates a pooled memory handle of the given size, on the given pool.
        /// </summary>
        /// <param name="type">Required memory type</param>
        /// <param name="poolType">Pool type</param>
        /// <param name="size">Size of allocated region</param>
        /// <returns>Memory handle</returns>
        public MemoryHandle Allocate(MemoryType type, Pool poolType, ulong size)
        {
            var pools = PoolForType(type, poolType);

            foreach (var pool in pools)
            {
                if (pool.TryAllocate(size, out var tmp))
                {
                    return(new MemoryHandle(pool, tmp));
                }
            }
            // Create a new pool
            var blockCount = PoolBlockCount;
            var blockSize  = BlockSizeForPool(poolType);

            blockCount = System.Math.Max((ulong)System.Math.Ceiling(size / (double)blockSize) * 4UL, blockCount);
            var npool = new DeviceMemoryPool(Device, blockSize, type.TypeIndex, blockCount, type.HostVisible);

            pools.Add(npool);
            return(new MemoryHandle(npool, npool.Allocate(size)));
        }
示例#40
0
 private string GetTypeStr(MemoryType type)
 {
     if (type == MemoryType.Image)
         return "Image";
     else if (type == MemoryType.Mapped)
         return "Mapped";
     else if (type == MemoryType.Private)
         return "Private";
     else
         return "Unknown";
 }
示例#41
0
 public abstract Task<long> GetMemoryAvailable(MemoryUse use, MemoryType type);
示例#42
0
 public abstract Task<MemoryStatus> GetMemoryStatus(MemoryType type);
示例#43
0
		public abstract long GetMemoryAvailable (MemoryUse use, MemoryType type);
示例#44
0
        public Mem(GPVar @base, GPVar index, ScalingFactor scalingFactor, IntPtr displacement, int size = 0)
            : base(size: size)
        {
            if (@base == null)
                throw new ArgumentNullException("base");
            if (index == null)
                throw new ArgumentNullException("index");
            if (scalingFactor < ScalingFactor.Times1 || scalingFactor > ScalingFactor.Times8)
                throw new ArgumentOutOfRangeException("scalingFactor");
            Contract.EndContractBlock();

            _type = MemoryType.Native;
            _segmentPrefix = SegmentPrefix.None;

            _sizePrefix = @base.Size != IntPtr.Size || index.Size != IntPtr.Size;

            _base = (RegIndex)@base.Id;
            _index = (RegIndex)index.Id;
            _scalingFactor = scalingFactor;

            _target = IntPtr.Zero;
            _displacement = displacement;
        }
示例#45
0
 public SelectedSettings(MemoryType memoryType, SettingsInfo settingsInfo)
 {
     MemoryType = memoryType;
     SettingsInfo = settingsInfo;
 }
示例#46
0
    private int GetNeighbourCount(MemoryGraphNode memNode, MemoryType fuzzyType)
    {
        int count = 0;
        for (int i = 0; i < memNode.Neighbours.Count; i++)
        {
            if (memNode.Neighbours[i].MemoryType == fuzzyType)
                ++count;
        }

        return count;
    }
示例#47
0
 /// <summary>
 /// Returns memory available for the given use (application or storage) and type.
 /// In this case, only one type is available, so method is returning memory status depending on use.
 /// </summary>
 /// <param name="use">Memory use.</param>
 /// <param name="type">Memory type.</param>
 /// <returns>Available memory.</returns>
 public override long GetMemoryAvailable(MemoryUse use, MemoryType type)
 {
     return GetMemoryAvailable(use);
 }
 public override async Task<MemoryStatus> GetMemoryStatus(MemoryType type)
 {
     throw new NotImplementedException();
 }
示例#49
0
 public IMemorySegment DefineSegment( MemoryType type, string name, int baseAddress, int length )
 {
     throw new NotSupportedException();
 }
示例#50
0
 public MemoryNode(string uid, MemoryType mt)
 {
     UID = uid;
     MemoryType = mt;
 }
示例#51
0
 public MemoryNode(MemoryCue memInfo, MemoryType mt)
 {
     MemoryCue = memInfo;
     UID = memInfo.UniqueNodeID;
     RelatedCues = memInfo.CueMarkers;
     MemoryType = mt;
 }
示例#52
0
        public Mem(Label label, IntPtr displacement, int size = 0)
            : base(size: size)
        {
            if (label == null)
                throw new ArgumentNullException("label");

            _type = MemoryType.Label;
            _label = label;
            _segmentPrefix = SegmentPrefix.None;

            _base = (RegIndex)label.Id;
            _index = RegIndex.Invalid;
            _scalingFactor = ScalingFactor.Times1;

            _target = IntPtr.Zero;
            _displacement = displacement;
        }
示例#53
0
 public override long GetMemoryAvailable(MemoryUse use, MemoryType type)
 {
     throw new NotImplementedException();
 }
示例#54
0
        /// <summary>
        /// Returns memory info for the given type.
        /// In this case, only one type is available, so method is returning total memory status.
        /// </summary>
        /// <param name="type">Memory type.</param>
        /// <returns>Memory status.</returns>
        public override MemoryStatus GetMemoryStatus(MemoryType type)
        {
            MemoryType[] availableMemTypes = GetMemoryAvailableTypes();
			if (availableMemTypes!= null && availableMemTypes.Length>0) {
				for (int i=0;i<availableMemTypes.Length;i++) {
					if (availableMemTypes[i] == type) {
						return GetMemoryStatus();
					}
				}
			} 
			return null;
           
        }
示例#55
0
 public override MemoryStatus GetMemoryStatus(MemoryType type)
 {
     throw new NotImplementedException();
 }
示例#56
0
    internal bool GetConceptNeighbours(string cueUID, MemoryType memType, ref List<string> targetUIDs)
    {
        targetUIDs.Clear();
        if (!MemoryGraph.Contains(cueUID))
            return false;

        MemoryGraphNode memNode = MemoryGraph.GetNamedNodeFromGraph(cueUID);
 
        //Should I just return the mem node references?
        for (int i = 0; i < memNode.Neighbours.Count; i++)
        {
            //Debug.Log("Neighbour " + i + " - " + memNode.Neighbours[i].UID);
            if (memNode.Neighbours[i].MemoryType == memType)
                targetUIDs.Add(memNode.Neighbours[i].UID);
        }

        //Debug.Log("GetConceptTargetUIDs - " + targetUIDs.Count);

        if (targetUIDs.Count > 0)
            return true;

        //Can see Asbel, and that he has a hammer, but has no memory of a location! Is the location being forgotten, or is it not being stored at all!?
        return false;
    }
        public object GetValue(MemoryType type)
        {
            if (type != Type)
            {
                return null;
                // throw new InvalidOperationException("GetValue: Type mismatch.");
            }

            switch(type)
            {
                case MemoryType.Int:
                    return (int)Value;

                case MemoryType.Char:
                    return (char)Value;

                default:
                    throw new InvalidOperationException("GetValue: Invalid type.");
            }
        }
示例#58
0
		public abstract MemoryStatus GetMemoryStatus (MemoryType type);
 public MemorySlot(MemoryType type, object value)
 {
     Type = type;
     Value = value;
 }
示例#60
0
        public Mem(IntPtr target, GPVar index, ScalingFactor scalingFactor, IntPtr displacement, SegmentPrefix segmentPrefix, int size = 0)
            : base(size: size)
        {
            if (index == null)
                throw new ArgumentNullException("index");
            if (scalingFactor < ScalingFactor.Times1 || scalingFactor > ScalingFactor.Times8)
                throw new ArgumentOutOfRangeException("scalingFactor");
            Contract.EndContractBlock();

            _type = MemoryType.Absolute;
            _segmentPrefix = segmentPrefix;

            _sizePrefix = index.Size != IntPtr.Size;

            _base = RegIndex.Invalid;
            _index = (RegIndex)index.Id;
            _scalingFactor = scalingFactor;

            _target = target;
            _displacement = displacement;
        }