2019-02-04 23:52:21 +00:00
|
|
|
|
// <copyright file="Device.cs" company="Adrian Conlon">
|
|
|
|
|
// Copyright (c) Adrian Conlon. All rights reserved.
|
|
|
|
|
// </copyright>
|
|
|
|
|
|
|
|
|
|
namespace EightBit
|
2019-02-02 15:12:51 +00:00
|
|
|
|
{
|
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
public class Device
|
|
|
|
|
{
|
|
|
|
|
private PinLevel powerLine;
|
|
|
|
|
|
2019-02-04 23:52:21 +00:00
|
|
|
|
protected Device()
|
|
|
|
|
{
|
|
|
|
|
}
|
2019-02-02 15:12:51 +00:00
|
|
|
|
|
|
|
|
|
public event EventHandler<EventArgs> RaisingPOWER;
|
2019-02-04 23:52:21 +00:00
|
|
|
|
|
2019-02-02 15:12:51 +00:00
|
|
|
|
public event EventHandler<EventArgs> RaisedPOWER;
|
2019-02-04 23:52:21 +00:00
|
|
|
|
|
2019-02-02 15:12:51 +00:00
|
|
|
|
public event EventHandler<EventArgs> LoweringPOWER;
|
2019-02-04 23:52:21 +00:00
|
|
|
|
|
2019-02-02 15:12:51 +00:00
|
|
|
|
public event EventHandler<EventArgs> LoweredPOWER;
|
|
|
|
|
|
2019-04-22 23:58:33 +00:00
|
|
|
|
public bool Powered => this.POWER.Raised();
|
2019-02-02 15:12:51 +00:00
|
|
|
|
|
2019-04-22 23:58:33 +00:00
|
|
|
|
public ref PinLevel POWER => ref this.powerLine;
|
2019-02-02 15:12:51 +00:00
|
|
|
|
|
|
|
|
|
public virtual void RaisePOWER()
|
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.OnRaisingPOWER();
|
2019-04-22 23:58:33 +00:00
|
|
|
|
this.POWER.Raise();
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.OnRaisedPOWER();
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public virtual void LowerPOWER()
|
|
|
|
|
{
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.OnLoweringPOWER();
|
2019-04-22 23:58:33 +00:00
|
|
|
|
this.POWER.Lower();
|
2019-02-04 23:52:21 +00:00
|
|
|
|
this.OnLoweredPOWER();
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
|
2019-02-04 23:52:21 +00:00
|
|
|
|
protected virtual void OnRaisingPOWER() => this.RaisingPOWER?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
|
|
|
|
|
protected virtual void OnRaisedPOWER() => this.RaisedPOWER?.Invoke(this, EventArgs.Empty);
|
|
|
|
|
|
|
|
|
|
protected virtual void OnLoweringPOWER() => this.LoweringPOWER?.Invoke(this, EventArgs.Empty);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
|
2019-02-04 23:52:21 +00:00
|
|
|
|
protected virtual void OnLoweredPOWER() => this.LoweredPOWER?.Invoke(this, EventArgs.Empty);
|
2019-02-02 15:12:51 +00:00
|
|
|
|
}
|
|
|
|
|
}
|