S# is a formal modeling and safety analysis framework for safety-critical systems. It provides a domain specific modeling language and fully automated formal safety analysis tools based on C# and .NET.
interface ICapability {
void Execute(BaseAgent agent);
bool IsEquivalentTo(ICapability capability);
CapabilityType Type { get; }
}
interface ICapabilityHandler<T> where T : ICapability {
void ApplyCapability(T capability);
}
// separate from ICapability, so we don't have to carry the type parameter everywhere
abstract class Capability<T> : ICapability where T : Capability<T> {
void Execute(BaseAgent agent) {
var handler = agent as ICapabilityHandler<T>;
if (handler == null)
throw new InvalidOperationException();
handler.ApplyCapability(this);
}
}
// maybe provide ProduceCapability, ConsumeCapability subclasses (no additional data)
// but not ProcessCapability (will almost always require application-specific data)
class RobotAgent : ICapabilityHandler<Produce>, ICapabilityHandler<Process>, ICapabilityHandler<Consume>
{
void ApplyCapability(ProduceCapability c) { ... }
void ApplyCapability(ProcessCapability c) { ... }
void ApplyCapability(ConsumeCapability c) { ... }
}
enum CapabilityType { Produce, Process, Consume }
Use different capability types to specify invariants (valid tasks etc.)
Use IsEquivalentTo() to distinguish between semantic equality and reference equality of capabilities.
possible implementation of capabilities:
Use different capability types to specify invariants (valid tasks etc.)
Use
IsEquivalentTo()
to distinguish between semantic equality and reference equality of capabilities.