model PressureSensor
extends HydraulicsByFluidon.Components.Sensors.Base.Sensor;
parameter HydraulicsByFluidon.Types.TPressureTypes sensorType = HydraulicsByFluidon.Types.TPressureTypes.relative "Sensor type";
equation
if sensorType == HydraulicsByFluidon.Types.TPressureTypes.absolute then
value = fluidPort.p;
else
value = fluidPort.p - environment.pAmbient;
end if;
fluidPort.mFlow = 0;
annotation (
Icon(
coordinateSystem(initialScale = 0.1),
graphics = {
Line(
rotation = 45,
points = {
{0, 25},
{0, -25}}),
Polygon(
origin = {40, -40},
rotation = 90,
fillPattern = FillPattern.Solid,
points = {
{59, 59},
{45, 51},
{51, 45},
{59, 59}}),
Text(
origin = {0, 22},
extent = {
{-30, -25},
{30, -55}},
textString = "p")}),
Documentation(info = "<html>\n <p>\n PressureSensor acts either as an absolute or a relative pressure sensor,\n depending on the parameter <var>Sensor type</var>.\n </p>\n <p>\n <var>Sensor type</var> = absolute: Measured value = Pressure at fluidPort</br>\n <var>Sensor type</var> = relative: Measured value = Pressure at fluidPort minus ambient pressure\n </p></html>"));
end PressureSensor;