SchematicDrawing.IDrawingItCmpntWithCustomBmp and several bitmaps added, ver. 3.1.1886

This commit is contained in:
Milan Hanajik 2022-04-14 13:41:53 +02:00
parent deabff9a18
commit c5db2c0138
39 changed files with 469 additions and 85 deletions

View File

@ -1,12 +1,8 @@
///
/// Copyright (c) 2020 Sensus Slovensko a.s.
/// Copyright (c) 2020-2022 Sensus Slovensko a.s.
///
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SchematicDrawing
{
@ -26,8 +22,8 @@ namespace SchematicDrawing
public readonly Edge[] Edges; /// Edges (in the open state in case there are two states: open/closed)
/// open (route bit = 1), wet
public readonly bool HasImg; /// True when there is an image of this item to be displayed
public readonly Image ImgRight; /// Bitmap to be drawn (in the open state in case there are two states: open/closed)
public readonly bool HasImg; /// True when there is an image of this item to be displayed
public readonly Image ImgRight; /// Bitmap to be drawn (in the open state in case there are two states: open/closed)
public readonly Image ImgUp;
public readonly Image ImgLeft;
public readonly Image ImgDown;
@ -80,13 +76,13 @@ namespace SchematicDrawing
public readonly Image ImgDownFlippedVacuum;
DrawingShape(Shape shape, Sz sz, int szX, int szY, Node[] nodes = null, Edge[] edges = null,
int offsX = -10, int offsY = -10, int wid = 20, int hgh = 20,
Bitmap bmp = null, /// wet, open (route bit = 1)
Bitmap bmpClosedDry = null, /// dry (Dist == int.MaxValue), closed (route bit = 0)
Bitmap bmpVacuum = null, /// vacuum (int.MaxValue > Dist && Dist > Const.Vacuum)
Bitmap bmpOpenDry = null, /// dry (Dist == int.MaxValue), open (route bit = 1)
Bitmap bmpClosedWet = null) /// wet, closed (route bit = 0) ... diverter only
public DrawingShape(Shape shape, Sz sz, int szX, int szY, Node[] nodes = null, Edge[] edges = null,
int offsX = -10, int offsY = -10, int wid = 20, int hgh = 20,
Bitmap bmp = null, /// wet, open (route bit = 1)
Bitmap bmpClosedDry = null, /// dry (Dist == int.MaxValue), closed (route bit = 0)
Bitmap bmpVacuum = null, /// vacuum (int.MaxValue > Dist && Dist > Const.Vacuum)
Bitmap bmpOpenDry = null, /// dry (Dist == int.MaxValue), open (route bit = 1)
Bitmap bmpClosedWet = null) /// wet, closed (route bit = 0) ... diverter only
{
Shape = shape;
Sz = sz;
@ -286,11 +282,31 @@ namespace SchematicDrawing
public static DrawingShape[] Shapes;
///
public static int DrShIx(Shape shape, Sz sz) { return (int)shape * (int)Sz.Count + (int)sz; }
public static int DrShIx(Shape shape, Sz sz)
{
return (int)shape * (int)Sz.Count + (int)sz;
}
///
public static DrawingShape GetDrawingShape(Shape shape, Sz sz) { return Shapes[DrShIx(shape, sz)]; }
public static DrawingShape GetDrawingShape(Shape shape, Sz sz)
{
return Shapes[DrShIx(shape, sz)];
}
///
public static DrawingShape GetDrawingShape(IDrawingItem item) { return (item != null) ? Shapes[DrShIx(item.Shape, item.Sz)] : null; }
public static DrawingShape GetDrawingShape(IDrawingItem item)
{
if (item == null)
{
return null;
}
else if (item is IDrawingItemWithCustomBmp)
{
return (item as IDrawingItemWithCustomBmp).GetSampleBitmap();
}
else
{
return Shapes[DrShIx(item.Shape, item.Sz)];
}
}
/// <summary>
/// Static constructor that initializes Shapes[] array

View File

@ -51,7 +51,9 @@ namespace SchematicDrawing
Vacuum,
Valve,
WaterM,
Count
Count,
Custom,
}
public enum Sz

View File

@ -0,0 +1,12 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
using System.Drawing;
namespace SchematicDrawing
{
public interface IDrawingItCmpntWithCustomBmp
{
DrawingShape GetCustomBitmap();
}
}

View File

@ -0,0 +1,10 @@
///
/// Copyright (c) 2022 Sensus Slovensko a.s.
///
namespace SchematicDrawing
{
public interface IDrawingItemWithCustomBmp : IDrawingItem
{
DrawingShape GetSampleBitmap();
}
}

View File

@ -46,6 +46,8 @@
<Compile Include="GEdge.cs" />
<Compile Include="GNode.cs" />
<Compile Include="Graph.cs" />
<Compile Include="IDrawingItCmpntWithCustomBmp.cs" />
<Compile Include="IDrawingItemWithCustomBmp.cs" />
<Compile Include="ItemElementRect.cs" />
<Compile Include="DrawingShape.cs" />
<Compile Include="Edge.cs" />

View File

@ -114,6 +114,16 @@ namespace SchematicDrawing
get { return setpoints; }
}
///
/// Custom bitmaps
///
private DrawingShape[] customBitmaps;
public DrawingShape[] CustomBitmaps
{
set { if (customBitmaps != value) { customBitmaps = value; Redraw(); } }
get { return customBitmaps; }
}
///
/// Pipes
///
@ -347,6 +357,7 @@ namespace SchematicDrawing
if (!EditMode)
{
DrawingShape dshape = DrawingShape.GetDrawingShape(item);
if (dshape != null && dshape.Nodes != null && dshape.Nodes.Length > 0)
{
item.GNodes.Clear();
@ -565,13 +576,22 @@ namespace SchematicDrawing
///
/// Draw pictures of all items except of junctions
///
int customBmpIx = 0;
foreach (var item in items)
{
DrawingShape dshape = DrawingShape.GetDrawingShape(item);
if (dshape != null && dshape.Shape != Shape.Junction && dshape.HasImg && (!Utils.IsHidden(item) || (EditMode && item == selectedItem)))
if (dshape != null && dshape.Shape != Shape.Junction && (!Utils.IsHidden(item) || (EditMode && item == selectedItem)))
{
Rectangle rect = DrawItem(e, item, dshape);
ItemElementRectangles.Add(new ItemElementRect(item, Element.Body, rect));
if (item is IDrawingItemWithCustomBmp && customBitmaps != null && customBitmaps.Length > customBmpIx)
{
Rectangle rect = DrawItem(e, item, customBitmaps[customBmpIx++]);
ItemElementRectangles.Add(new ItemElementRect(item, Element.Body, rect));
}
else if (dshape.HasImg)
{
Rectangle rect = DrawItem(e, item, dshape);
ItemElementRectangles.Add(new ItemElementRect(item, Element.Body, rect));
}
}
}
@ -639,7 +659,7 @@ namespace SchematicDrawing
if (!string.IsNullOrEmpty(strVal))
{
/// Paint water in the tank on a scale
DrawingShape dshape = DrawingShape.GetDrawingShape(item.Shape, item.Sz);
DrawingShape dshape = DrawingShape.GetDrawingShape(item);
if (dshape.Shape == Shape.Scale)
{
Rectangle r = dshape.GetRotatedFlippedImageRectangle(item);

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Build Number
// Revision
//
[assembly: AssemblyVersion("3.1.1884.0")]
[assembly: AssemblyFileVersion("3.1.1884.0")]
[assembly: AssemblyVersion("3.1.1886.0")]
[assembly: AssemblyFileVersion("3.1.1886.0")]

View File

@ -150,6 +150,166 @@ namespace TBF.Properties {
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_L_both {
get {
object obj = ResourceManager.GetObject("TControl_L_both", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_L_cooling {
get {
object obj = ResourceManager.GetObject("TControl_L_cooling", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_L_heating {
get {
object obj = ResourceManager.GetObject("TControl_L_heating", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_L_idle {
get {
object obj = ResourceManager.GetObject("TControl_L_idle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_M_both {
get {
object obj = ResourceManager.GetObject("TControl_M_both", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_M_cooling {
get {
object obj = ResourceManager.GetObject("TControl_M_cooling", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_M_heating {
get {
object obj = ResourceManager.GetObject("TControl_M_heating", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_M_idle {
get {
object obj = ResourceManager.GetObject("TControl_M_idle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_S_both {
get {
object obj = ResourceManager.GetObject("TControl_S_both", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_S_cooling {
get {
object obj = ResourceManager.GetObject("TControl_S_cooling", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_S_heating {
get {
object obj = ResourceManager.GetObject("TControl_S_heating", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_S_idle {
get {
object obj = ResourceManager.GetObject("TControl_S_idle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_XL_both {
get {
object obj = ResourceManager.GetObject("TControl_XL_both", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_XL_cooling {
get {
object obj = ResourceManager.GetObject("TControl_XL_cooling", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_XL_heating {
get {
object obj = ResourceManager.GetObject("TControl_XL_heating", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>
internal static System.Drawing.Bitmap TControl_XL_idle {
get {
object obj = ResourceManager.GetObject("TControl_XL_idle", resourceCulture);
return ((System.Drawing.Bitmap)(obj));
}
}
/// <summary>
/// Looks up a localized resource of type System.Drawing.Bitmap.
/// </summary>

View File

@ -160,4 +160,52 @@
<data name="qrcode_48x48" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Resources\qrcode-48x48.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_L_both" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-L-both.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_L_cooling" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-L-cooling.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_L_heating" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-L-heating.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_L_idle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-L-idle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_M_both" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-M-both.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_M_cooling" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-M-cooling.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_M_heating" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-M-heating.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_M_idle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-M-idle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_S_both" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-S-both.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_S_cooling" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-S-cooling.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_S_heating" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-S-heating.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_S_idle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-S-idle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_XL_both" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-XL-both.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_XL_cooling" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-XL-cooling.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_XL_heating" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-XL-heating.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
<data name="TControl_XL_idle" type="System.Resources.ResXFileRef, System.Windows.Forms">
<value>..\Rig\Modbus\TempControl\Pictures\TControl-XL-idle.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</value>
</data>
</root>

View File

@ -203,7 +203,8 @@ namespace TBF.Rig.ControlBoard.Papouch
ProcessData.MsrmntAvailableFlags,
ProcessData.MeasuredValues,
ProcessData.AltStrings,
ProcessData.Setpoints));
ProcessData.Setpoints,
ProcessData.CustomBitmaps));
}
public void StopDevice()

View File

@ -501,7 +501,7 @@ namespace TBF.Rig.ControlBoard.Uni
ProcessData.UpdateMeasuredValuesAndSetpoints();
Bridge.OnStateMachineTick(this, new StateMachineTickEventArgs(route, ProcessData.MsrmntAvailableFlags, ProcessData.MeasuredValues,
ProcessData.AltStrings, ProcessData.Setpoints));
ProcessData.AltStrings, ProcessData.Setpoints, ProcessData.CustomBitmaps));
/// Make sure the serial port is open
if (cbCfg.DebugLevel == DebugMode.Normal && (serialPort == null || !serialPort.IsOpen))

View File

@ -11,7 +11,7 @@ using TBF.Rig.Generic;
namespace TBF.Rig.Modbus.PumpFM.DanfossVLT
{
public class PumpCfg : ComponentCfgBase, Generic.IChildComponentCfg, IRouteBasedDrawingItem, IDrawingItemWithSetpoint
public class PumpCfg : ComponentCfgBase, IChildComponentCfg, IRouteBasedDrawingItem, IDrawingItemWithSetpoint
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(PumpCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }

View File

@ -76,7 +76,7 @@ namespace TBF.Rig.Modbus.TempControl.Easytherm
Name = "Novus";
ParentName = "Modbus";
Shape = Shape.TempControl;
Shape = Shape.Custom;
Sz = Sz.M;
MsrdValLimLo = 5;
MsrdValLimHi = 95;

View File

@ -3,25 +3,29 @@
///
using System;
using System.Collections.Generic;
using System.Drawing;
using log4net;
using Common;
using Config.Entities;
using SchematicDrawing;
using TBF.Rig.Generic;
using TBF.Boxes;
using TBF.Rig.Generic;
namespace TBF.Rig.Modbus.TempControl.Novus
{
public class TControl : ComponentBase, IDevice, ITempControl, IDrawingItCmpntWithSetpoint, IDrawingItCmpntWithMeasuredVal
public class TControl : ComponentBase, IDevice, ITempControl, IDrawingItCmpntWithSetpoint,
IDrawingItCmpntWithMeasuredVal, IDrawingItCmpntWithCustomBmp
{
private static readonly ILog log = LogManager.GetLogger(typeof(TControl));
public override string ToString() { return string.Format("{0}({1})", ClassName, Cfg.ToString(-1)); }
const UInt16 SetpointAddress = 0; /// Temperature setpoint
const UInt16 ProcessValueAddress = 1; /// Actual temperature
const UInt16 StatusWord1 = 6; /// Status word 1
const UInt16 StatusWord2 = 9; /// Status word 2
const UInt16 StatusWord3 = 10; /// Status word 3
const UInt16 SetpointAddress = 0; /// Temperature setpoint address
const UInt16 ProcessValueAddress = 1; /// Actual temperature address
const UInt16 Status1Address = 6; /// Status word 1 address
const UInt16 FWVersionAddress = 7; /// Firmware version address
const UInt16 ControllerIdAddress = 8; /// Controller ID address
const UInt16 Status2Address = 9; /// Status word 2 address
const UInt16 Status3Address = 10; /// Status word 3 address
readonly TControlCfg novusCfg;
public IDrawingItem DrawingItem { get { return novusCfg as IDrawingItem; } }
@ -51,17 +55,44 @@ namespace TBF.Rig.Modbus.TempControl.Novus
if (temperatureSetPoint <= 5) temperatureSetPoint = 5;
}
public DrawingShape GetCustomBitmap()
{
switch (novusCfg.Sz)
{
case Sz.S:
return isHeating ? (isCooling ? TControlCfg.DSBothS : TControlCfg.DSHeatingS)
: (isCooling ? TControlCfg.DSCoolingS : TControlCfg.DSIdleS);
case Sz.M:
return isHeating ? (isCooling ? TControlCfg.DSBothM : TControlCfg.DSHeatingM)
: (isCooling ? TControlCfg.DSCoolingM : TControlCfg.DSIdleM);
default:
case Sz.L:
return isHeating ? (isCooling ? TControlCfg.DSBothL : TControlCfg.DSHeatingL)
: (isCooling ? TControlCfg.DSCoolingL : TControlCfg.DSIdleL);
case Sz.XL:
return isHeating ? (isCooling ? TControlCfg.DSBothXL : TControlCfg.DSHeatingXL)
: (isCooling ? TControlCfg.DSCoolingXL : TControlCfg.DSIdleXL);
}
}
bool novusDataValid;
double temperatureSetPoint;
double actualTemperature;
bool temperatureSetPointValid { get { return novusDataValid; } }
bool temperatureSetPointRequested;
Int16 status1;
Int16 status2;
Int16 status3;
Int16 fwVersion;
Int16 controllerId;
double temperatureSetPoint;
double actualTemperature;
bool temperatureSetPointValid;
bool temperatureSetPointRequested;
bool isInvOutput { get { return (status2 & (1 << 2)) != 0; } }
bool isHeating { get { return isInvOutput ? ((status2 & (1 << 11)) == 0) : ((status2 & (1 << 11)) != 0); } } /// Output 1
bool isCooling { get { return isInvOutput ? ((status2 & (1 << 12)) == 0) : ((status2 & (1 << 12)) != 0); } } /// Output 2
bool isFahrenheit { get { return (status2 & (1 << 9)) != 0; } }
public float requiredTemp
@ -73,9 +104,6 @@ namespace TBF.Rig.Modbus.TempControl.Novus
}
bool heating;
bool cooling;
public TControl() { }
@ -83,17 +111,18 @@ namespace TBF.Rig.Modbus.TempControl.Novus
: base(cfg)
{
novusCfg = cfg as TControlCfg;
}
}
/// <summary>Initialize this device</summary>
public override void Initialize()
{
temperatureSetPointValid = false;
temperatureSetPointRequested = false;
{
novusDataValid = false;
temperatureSetPointRequested = false;
if (novusCfg.DebugLevel == DebugMode.Simulate)
{
actualTemperature = 22;
temperatureSetPoint = 18;
log.FatalFormat("{0} simulated: {1}", Name, this);
}
else
@ -131,13 +160,17 @@ namespace TBF.Rig.Modbus.TempControl.Novus
- ((telegram[2 * i + 3] & 0x80) != 0 ? 65536 : 0));
}
temperatureSetPoint = (double)values[0] * 0.1; /// setpoint in 0.1 °C
actualTemperature = (double)values[1] * 0.1; /// temperature in 0.1 °C
status1 = values[6];
fwVersion = values[7];
controllerId = values[8];
status2 = values[9];
status3 = values[10];
status1 = values[Status1Address];
status2 = values[Status2Address];
status3 = values[Status3Address];
fwVersion = values[FWVersionAddress];
controllerId = values[ControllerIdAddress];
double setpointCorF = (double)values[SetpointAddress] * 0.1;
temperatureSetPoint = isFahrenheit ? Units.ConvertFrom(Unit.F, setpointCorF) : setpointCorF;
double temperatureCorF = (double)values[ProcessValueAddress] * 0.1;
actualTemperature = isFahrenheit ? Units.ConvertFrom(Unit.F, temperatureCorF) : temperatureCorF;
novusDataValid = true;
@ -151,10 +184,17 @@ namespace TBF.Rig.Modbus.TempControl.Novus
log.InfoFormat("[{0}] received soemthing else", Name);
}
}
else if (novusCfg.DebugLevel == DebugMode.Simulate)
{
switch ((StateMachine.Time / 3) % 3)
{
case 0: status2 = 0; break;
case 1: status2 = 1 << 11; break;
case 2: status2 = 1 << 12; break;
}
}
}
const int Modulo = 2;
/// <summary>Run this device</summary>
public void RunDeviceAfter()
{
@ -192,47 +232,33 @@ namespace TBF.Rig.Modbus.TempControl.Novus
/// <summary>
/// Set Easytherm controller to specified temperature
/// </summary>
/// <param name="reqTemp">Temperature in °C</param>
/// <param name="reqTempC">Temperature in °C</param>
/// <returns>true = OK, false = any error</returns>
public bool SetTemperatureSetpoint(float reqTemp)
public bool SetTemperatureSetpoint(double reqTempC)
{
if (reqTemp != 0 && (reqTemp < 5 || reqTemp > 95.0f))
if (reqTempC != 0 && (reqTempC < 5.0 || reqTempC > 95.0))
{
return false; /// required temperature out of range
}
if (novusDataValid && (reqTemp == temperatureSetPoint))
if (novusDataValid && (reqTempC == temperatureSetPoint))
{
return true; /// already set to the required temperature
}
if (reqTemp != 0) /// temperature==0 disables sending the setpoint
if (reqTempC != 0) /// temperature==0 disables sending the setpoint
{
Int16 usTempSetpoint = Convert.ToInt16(Math.Round(10 * reqTemp)); /// setpoint in 0.1 °C
double reqTemp = isFahrenheit ? Units.ConvertTo(Unit.F, reqTempC) : reqTempC;
Int16 tempSetpointInt16 = Convert.ToInt16(Math.Round(10 * reqTemp)); /// setpoint in 0.1 °C or °F
ushort destAddress = SetpointAddress;
///
SendValueToNovus(Function.PresetSingleRegister, destAddress, usTempSetpoint);
SendValueToNovus(Function.PresetSingleRegister, destAddress, tempSetpointInt16);
}
temperatureSetPoint = reqTemp;
temperatureSetPointValid = true;
temperatureSetPoint = reqTempC;
return true;
}
public void RequestTemperatureSetpoint()
{
SendValueToNovus(Function.ReadHoldingRegisters, SetpointAddress, 1); /// rel.address=2, 1 word
}
public void RequestActualTemperature()
{
SendValueToNovus(Function.ReadInputRegister, ProcessValueAddress, 1); /// rel.address=x, 1 word
}
public void RequestAll()
{
SendValueToNovus(Function.ReadInputRegister, 0, 2); /// Registers: Setpoint=0, ProcessValue=1, Status1=6, Status2=9, Status3=10
}
void SendValueToNovus(Function function, UInt16 address, Int16 value)
{

View File

@ -13,7 +13,7 @@ using TBF.Rig.Generic;
namespace TBF.Rig.Modbus.TempControl.Novus
{
public class TControlCfg : ComponentCfgBase, IChildComponentCfg, IParamsProvider,
IDrawingItemWithSetpoint, IDrawingItemWithMeasuredVal
IDrawingItemWithSetpoint, IDrawingItemWithMeasuredVal, IDrawingItemWithCustomBmp
{
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TControlCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
@ -77,7 +77,7 @@ namespace TBF.Rig.Modbus.TempControl.Novus
Name = "Novus";
ParentName = "Modbus";
Shape = Shape.TempControl;
Shape = Shape.Custom;
Sz = Sz.M;
MsrdValLimLo = 5;
MsrdValLimHi = 95;
@ -214,5 +214,41 @@ namespace TBF.Rig.Modbus.TempControl.Novus
{
return true; /// =OK, do nothing
}
///
/// SchematicDrawing support
///
public DrawingShape GetSampleBitmap()
{
return (Sz == Sz.S) ? DSCoolingS : (Sz == Sz.M) ? DSCoolingM : (Sz == Sz.XL) ? DSCoolingXL : DSCoolingL;
}
///
/// Static part, DrawingShape constructor arguments depend on bitmap properties
///
public static DrawingShape DSIdleS, DSHeatingS, DSCoolingS, DSBothS;
public static DrawingShape DSIdleM, DSHeatingM, DSCoolingM, DSBothM;
public static DrawingShape DSIdleL, DSHeatingL, DSCoolingL, DSBothL;
public static DrawingShape DSIdleXL, DSHeatingXL, DSCoolingXL, DSBothXL;
///
static TControlCfg()
{
DSIdleS = new DrawingShape(Shape.Custom, Sz.S, 2, 2, null, null, 0, 0, 20, 20, Properties.Resources.TControl_S_idle);
DSHeatingS = new DrawingShape(Shape.Custom, Sz.S, 2, 2, null, null, 0, 0, 20, 20, Properties.Resources.TControl_S_heating);
DSCoolingS = new DrawingShape(Shape.Custom, Sz.S, 2, 2, null, null, 0, 0, 20, 20, Properties.Resources.TControl_S_cooling);
DSBothS = new DrawingShape(Shape.Custom, Sz.S, 2, 2, null, null, 0, 0, 20, 20, Properties.Resources.TControl_S_both);
DSIdleM = new DrawingShape(Shape.Custom, Sz.S, 3, 4, null, null, 0, 5, 30, 30, Properties.Resources.TControl_M_idle);
DSHeatingM = new DrawingShape(Shape.Custom, Sz.S, 3, 4, null, null, 0, 5, 30, 30, Properties.Resources.TControl_M_heating);
DSCoolingM = new DrawingShape(Shape.Custom, Sz.S, 3, 4, null, null, 0, 5, 30, 30, Properties.Resources.TControl_M_cooling);
DSBothM = new DrawingShape(Shape.Custom, Sz.S, 3, 4, null, null, 0, 5, 30, 30, Properties.Resources.TControl_M_both);
DSIdleL = new DrawingShape(Shape.Custom, Sz.S, 4, 4, null, null, 0, 0, 40, 40, Properties.Resources.TControl_L_idle);
DSHeatingL = new DrawingShape(Shape.Custom, Sz.S, 4, 4, null, null, 0, 0, 40, 40, Properties.Resources.TControl_L_heating);
DSCoolingL = new DrawingShape(Shape.Custom, Sz.S, 4, 4, null, null, 0, 0, 40, 40, Properties.Resources.TControl_L_cooling);
DSBothL = new DrawingShape(Shape.Custom, Sz.S, 4, 4, null, null, 0, 0, 40, 40, Properties.Resources.TControl_L_both);
DSIdleXL = new DrawingShape(Shape.Custom, Sz.S, 5, 6, null, null, 0, 5, 50, 50, Properties.Resources.TControl_XL_idle);
DSHeatingXL = new DrawingShape(Shape.Custom, Sz.S, 5, 6, null, null, 0, 5, 50, 50, Properties.Resources.TControl_XL_heating);
DSCoolingXL = new DrawingShape(Shape.Custom, Sz.S, 5, 6, null, null, 0, 5, 50, 50, Properties.Resources.TControl_XL_cooling);
DSBothXL = new DrawingShape(Shape.Custom, Sz.S, 5, 6, null, null, 0, 5, 50, 50, Properties.Resources.TControl_XL_both);
}
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 425 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 313 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 197 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 189 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 182 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 178 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 168 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 161 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 226 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 214 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 218 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 213 B

View File

@ -18,7 +18,7 @@ namespace TBF.Rig.Modbus.TempMeter.Meret
public static XmlSerializer Serializer = XmlSerializer.FromTypes(new[] { typeof(TempMeterCfg) })[0];
public override XmlSerializer GetSerializer() { return Serializer; }
public IComponentCfgCtrl GetControl(IList<Config.Entities.Component> cmpntEntities)
public IComponentCfgCtrl GetControl(IList<Component> cmpntEntities)
{
var parents = cmpntEntities.Where(x => x.ClassName == "Modbus.Common");
return new Configs.ParamsProvider.ComponentCfgCtrl(this, parents);
@ -50,7 +50,7 @@ namespace TBF.Rig.Modbus.TempMeter.Meret
public Orient MsrdOrient { get; set; }
public string MsrdFormat { get; set; } /// 2
public Unit MsrdUnit { get; set; } /// 3
public Unit MsrdUnit { get; set; } /// 3
public double MsrdValLimLo { get; set; } /// 4
public double MsrdValLimHi { get; set; } /// 5

View File

@ -1,5 +1,6 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using log4net;
using Common;
@ -51,6 +52,7 @@ namespace TBF.Rig.Sequences
public static readonly IList<IDrawingItCmpntWithMeasuredVal> ComponentsWithMeasuredVal;
public static readonly IList<IDrawingItCmpntWithSetpoint> ComponentsWithSetpoint;
public static readonly IList<IDrawingItCmpntWithCustomBmp> ComponentsWithCustomBmp;
///
/// Measured values and setpoints to be displayed
@ -59,6 +61,7 @@ namespace TBF.Rig.Sequences
public static double[] MeasuredValues;
public static string[] AltStrings;
public static double[] Setpoints;
public static DrawingShape[] CustomBitmaps;
///
/// State variables to be saved after each completed test
@ -95,6 +98,7 @@ namespace TBF.Rig.Sequences
ComponentsWithMeasuredVal = new List<IDrawingItCmpntWithMeasuredVal>();
ComponentsWithSetpoint = new List<IDrawingItCmpntWithSetpoint>();
ComponentsWithCustomBmp = new List<IDrawingItCmpntWithCustomBmp>();
}
/// <summary>
@ -305,6 +309,16 @@ namespace TBF.Rig.Sequences
{
ProcessData.Setpoints[i] = ProcessData.ComponentsWithSetpoint[i].SetpointVal;
}
/// Collect custom bitmaps
if (ProcessData.CustomBitmaps == null || ProcessData.CustomBitmaps.Length != ProcessData.ComponentsWithCustomBmp.Count)
{
ProcessData.CustomBitmaps = new DrawingShape[ProcessData.ComponentsWithCustomBmp.Count];
}
for (int i = 0; i < ProcessData.ComponentsWithCustomBmp.Count; i++)
{
ProcessData.CustomBitmaps[i] = ProcessData.ComponentsWithCustomBmp[i].GetCustomBitmap();
}
}

View File

@ -1,5 +1,5 @@
///
/// Copyright (c) 2013-2021 Sensus Slovensko a.s.
/// Copyright (c) 2013-2022 Sensus Slovensko a.s.
///
using System;
using System.Text;
@ -220,6 +220,7 @@ namespace TBF.Rig
ProcessData.ComponentsWithMeasuredVal.Clear();
ProcessData.ComponentsWithSetpoint.Clear();
ProcessData.ComponentsWithCustomBmp.Clear();
/// Find all balances (to initialize tank capacities in the control board)
/// Find the control board
@ -239,6 +240,10 @@ namespace TBF.Rig
{
ProcessData.ComponentsWithSetpoint.Add(cmpnt as SchematicDrawing.IDrawingItCmpntWithSetpoint);
}
if (cmpnt is SchematicDrawing.IDrawingItCmpntWithCustomBmp)
{
ProcessData.ComponentsWithCustomBmp.Add(cmpnt as SchematicDrawing.IDrawingItCmpntWithCustomBmp);
}
if ((cmpnt is Output.DB.SensusOracle.Database) && (ProcessData.OracleDB == null))
{

View File

@ -3413,6 +3413,22 @@
<None Include="Resources\qrcode-48x48.png" />
<Content Include="Resources\switch-off.png" />
<Content Include="Resources\switch-on.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-L-both.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-L-cooling.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-L-heating.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-L-idle.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-M-both.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-M-cooling.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-M-heating.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-M-idle.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-S-both.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-S-cooling.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-S-heating.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-S-idle.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-XL-both.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-XL-cooling.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-XL-heating.png" />
<Content Include="Rig\Modbus\TempControl\Pictures\TControl-XL-idle.png" />
<Content Include="SampleConfig\config.xml">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</Content>

View File

@ -341,6 +341,7 @@ namespace TBF.UI
this.drawingCtrl.SelectedElement = SchematicDrawing.Element.None;
this.drawingCtrl.SelectedItem = null;
this.drawingCtrl.Setpoints = null;
this.drawingCtrl.CustomBitmaps = null;
this.drawingCtrl.SupressRedraws = false;
this.drawingCtrl.MouseClick += new System.Windows.Forms.MouseEventHandler(this.drawingCtrl_MouseClick);
//

View File

@ -562,6 +562,13 @@ namespace TBF.UI
drawingCtrl.Setpoints = new double[args.Setpoints.Length];
}
for (int i = 0; i < args.Setpoints.Length; i++) drawingCtrl.Setpoints[i] = args.Setpoints[i];
/// Duplicate custom bitmaps
if (drawingCtrl.CustomBitmaps == null || drawingCtrl.CustomBitmaps.Length != args.CustomBitmaps.Length)
{
drawingCtrl.CustomBitmaps = new DrawingShape[args.CustomBitmaps.Length];
}
for (int i = 0; i < args.CustomBitmaps.Length; i++) drawingCtrl.CustomBitmaps[i] = args.CustomBitmaps[i];
drawingCtrl.SupressRedraws = false;
}

View File

@ -223,6 +223,7 @@ namespace TBF.UI.Process
IDrawingItCmpntWithMeasuredVal[] cmpntWithMeasuredVal;
IDrawingItCmpntWithSetpoint[] cmpntWithSetpoint;
IDrawingItCmpntWithCustomBmp[] cmpntWithCustomBmp;
/// <summary>
@ -236,6 +237,7 @@ namespace TBF.UI.Process
int id = 1;
int msrdIx = 0;
int setpIx = 0;
int bmpIx = 0;
processDrawingCtrl.AddItem(
tankCfg = new TBF.Rig.Various.Drawing.Tank.Configuration("Tank", new TBF.Rig.Various.Drawing.Tank.Factory())
@ -410,9 +412,11 @@ namespace TBF.UI.Process
processDrawingCtrl.MeasuredValues = new double[msrdIx];
processDrawingCtrl.AltStrings = new string[msrdIx];
processDrawingCtrl.Setpoints = new double[setpIx];
processDrawingCtrl.CustomBitmaps = new DrawingShape[bmpIx];
///
cmpntWithMeasuredVal = new IDrawingItCmpntWithMeasuredVal[msrdIx];
cmpntWithSetpoint = new IDrawingItCmpntWithSetpoint[setpIx];
cmpntWithCustomBmp = new IDrawingItCmpntWithCustomBmp[bmpIx];
processDrawingCtrl.PipesS = new string[0];
processDrawingCtrl.PipesM = new string[0];

View File

@ -1,8 +1,9 @@
///
/// Copyright (c) 2020-2021 Sensus Slovensko a.s.
/// Copyright (c) 2020-2022 Sensus Slovensko a.s.
///
using System;
using Dirichlet.Numerics;
using SchematicDrawing;
namespace TBF.UiBridge
{
@ -13,14 +14,17 @@ namespace TBF.UiBridge
public readonly double[] MeasuredValues;
public readonly string[] AltStrings;
public readonly double[] Setpoints;
public readonly DrawingShape[] CustomBitmaps;
public StateMachineTickEventArgs(UInt128 route, bool[] msrmntAvailableFlags, double[] measuredValues, string[] altStrings, double[] setpoints)
public StateMachineTickEventArgs(UInt128 route, bool[] msrmntAvailableFlags, double[] measuredValues,
string[] altStrings, double[] setpoints, DrawingShape[] customBitmaps)
{
Route = route;
MsrmntAvailableFlags = msrmntAvailableFlags;
MeasuredValues = measuredValues;
AltStrings = altStrings;
Setpoints = setpoints;
CustomBitmaps = customBitmaps;
}
}
}