42 lines
995 B
C#
42 lines
995 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
|
|
namespace ESPServer
|
|
{
|
|
class RegistersContainer
|
|
{
|
|
private Dictionary<int, int> registers;
|
|
|
|
public RegistersContainer()
|
|
{
|
|
registers = new Dictionary<int, int>();
|
|
}
|
|
|
|
public int this[int address]
|
|
{
|
|
get
|
|
{
|
|
lock(registers)
|
|
{
|
|
if (registers.ContainsKey(address)) return registers[address];
|
|
return 0;
|
|
}
|
|
}
|
|
set
|
|
{
|
|
lock (registers)
|
|
{
|
|
registers[address] = value;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void SetFloat(int address, float value)
|
|
{
|
|
byte[] bytes = BitConverter.GetBytes(value);
|
|
registers[address + 1] = (int)bytes[0] + (((int)bytes[1]) << 8);
|
|
registers[address] = (int)bytes[2] + (((int)bytes[3]) << 8);
|
|
}
|
|
}
|
|
}
|