public static IReadOnlyDictionary <IRegisterGroup, IRegister[]> MapRegistersToPossibleGroups( this IReadOnlyCollection <IRegisterGroup> matAtGroups, IReadOnlyList <IRegister> registersToMap) { var result = new Dictionary <IRegisterGroup, IRegister[]>(); var registerIndex = 0; while (registerIndex < registersToMap.Count) { IRegister headRegister = registersToMap[registerIndex]; IRegisterGroup deviceGroup = matAtGroups.FirstOrDefault(register => register.Address == headRegister.Address); if (deviceGroup == null) { throw new InvalidRegistersException($"Register group with address {headRegister.Address} was not found"); } IRegister[] requestRegistersInGroup = Enumerable.Range(deviceGroup.Address, deviceGroup.Count) .Select(address => registersToMap[registerIndex++].WithAddressAssert(address)) .ToArray(); result.Add(deviceGroup, requestRegistersInGroup); } return(result); }
public ImmediateOperationUnit(IRegisterGroup register) { Registers = register; }
public AddIUOperationUnit(IRegisterGroup registers) : base(registers) { }
public LoadOperationUnit(IMemoryProvider <Word> memory, IRegisterGroup registers) : base(registers) { Memory = memory; }
public MoveOperationUnit(IRegisterGroup registers) : base(registers) { }
public abstract void Modify(IRegisterGroup registerGroup);
public MultiplyIUOperationUnit(IRegisterGroup registers) : base(registers) { }
public RegisterOperationUnit(IRegisterGroup register) { Registers = register; }
public SpecialMemoryOperationUnit(SerialAbacus16Cpu cpu, IRegisterGroup registers) : base(registers) { Cpu = cpu; }
public override void Modify(IRegisterGroup registerGroup) { registerGroup.GetType() .GetProperty(nameof(IRegisterGroup.UpdateInterval)) ?.SetValue(registerGroup, TimeSpan.FromMilliseconds(_updateIntervalInMilliseconds)); }
public StoreValueIOperationUnit(IRegisterGroup registers) : base(registers) { }
public DivideUOperationUnit(IRegisterGroup registers) : base(registers) { }
public static void SetRegisterTypeViaReflection(this IRegisterGroup registerGroup, RegisterType registerType) { registerGroup.GetType() .GetProperty(nameof(IRegisterGroup.RegisterType)) ?.SetValue(registerGroup, registerType); }
public StoreOperationUnit(IRegisterGroup register) { Registers = register; }
private static int GetGroupSizeAsSeries(IRegisterGroup registerGroup, IProtocolInfo info) { return(info.AddressSize + registerGroup.DataSize); }
public static int GetLastRegisterAddress(this IRegisterGroup registerGroup) => registerGroup.GetRawRegisters().Last().Address;
public SubIOperationUnit(IRegisterGroup registers) : base(registers) { }