public virtual void CreateUXBase(string formTitle) { var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, "FACEPLATE"); MyForm = tFlds["Form"] as TheFormInfo; var ts = TheNMIEngine.AddStatusBlock(MyBaseThing, MyForm, 3); ts["Group"].SetParent(1); var tc = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyForm, 20, (pMsg, bConnect) => { if (bConnect) { Connect(); } else { Disconnect(true); } }); tc["Group"].SetParent(1); }
public override bool CreateUX() { if (!mIsUXInitCalled) { mIsUXInitCalled = true; var tHead = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 12, null, null, 0, $"..Event Logs on {TheCommonUtils.GetMyNodeName()}"); MyStatusForm = tHead["Form"] as TheFormInfo; // TheNMIEngine.AddForm(new TheFormInfo(MyBaseThing) { FormTitle = MyBaseThing.DeviceType, DefaultView = eDefaultView.Form, PropertyBag = new ThePropertyBag { "MaxTileWidth=6" } }); MyStatusFormDashPanel = tHead["DashIcon"] as TheDashPanelInfo; var tBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyStatusForm, 2); tBlock["Group"].SetParent(1); tBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyStatusForm, 120, sinkConnect); tBlock["Group"].SetParent(1); DoCreateUX(tHead["Form"] as TheFormInfo); mIsUXInitialized = true; } return(true); }
public override bool CreateUX() { if (!mIsUXInitStarted) { mIsUXInitStarted = true; var tSF = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 18, null, null, 0, "ISOLated Plugin KPIs"); mMyForm = tSF["Form"] as TheFormInfo; var sBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, mMyForm, 100); sBlock["Group"].SetParent(1); var cBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, mMyForm, 200, (msg, DoConnect) => { if (DoConnect) { Connect(); } else { Disconnect(); } }); TheNMIEngine.DeleteFieldById(cBlock["Address"].cdeMID); cBlock["Group"].SetParent(1); TheNMIEngine.AddSmartControl(MyBaseThing, mMyForm, eFieldType.CollapsibleGroup, 300, 2, 0, "KPIs", null, new nmiCtrlCollapsibleGroup { ParentFld = 1, IsSmall = true }); ShowKPI(310, "Up Time", "UpTime", 2000, 1000, "seconds"); ShowKPI(320, "Working Set (KB)", "WorkingSet", 100000, 50000); ShowKPI(330, "Handles", "Handles", 10000, 5000, "handles"); ShowKPI(340, "Threads", "Threads", 100, 40, "count"); ShowKPI(350, "CPU Time", "CPU", 100, 25, "%"); ShowKPI(360, "Total CPU Time", "CPUTime", 100, 70, "second"); ShowKPI(370, "IO Bytes", "IORead", 100000, 30000); mIsUXInitCompleted = true; } return(true); }
public virtual void InitUX() { var tHead = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, null, 0x0, new nmiStandardForm { MaxTileWidth = 12, IconUpdateName = "StatusLevel", UseMargin = true }); MyStatusForm = tHead["Form"] as TheFormInfo; // TheNMIEngine.AddForm(new TheFormInfo(MyBaseThing) { FormTitle = MyBaseThing.DeviceType, DefaultView = eDefaultView.Form, PropertyBag = new ThePropertyBag { "MaxTileWidth=6" } }); SummaryForm = tHead["DashIcon"] as TheDashPanelInfo; MyCollapsHead = tHead["Header"] as TheFieldInfo; SummaryForm.PropertyBag = new nmiDashboardTile { Format = $"{MyBaseThing.FriendlyName}<br>Status Level: {{0}}", LabelForeground = "white", ClassName = "cdeLiveTile cdeLiveTileBar" }; var tBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyStatusForm, 2); tBlock["Group"].SetParent(1); tBlock["Group"].Flags = 0; tBlock["Group"].cdeA = 0; tBlock["Value"].cdeA = 0; tBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyStatusForm, 120, sinkConnect); tBlock["Group"].SetParent(1); sinkUpdateUX(null); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; bool readOnly = TheThing.GetSafePropertyBool(MyBaseThing, TheThingRegistry.eOwnerProperties.cdeReadOnly); int writeEnableFlag; if (!readOnly) { writeEnableFlag = 2; } else { writeEnableFlag = 0; } //NUI Definition for All clients TheThing.SetSafePropertyString(MyBaseThing, "StateSensorUnit", "Live Tags"); TheThing.SetSafePropertyString(MyBaseThing, "StateSensorIcon", "/Images/OPCLogo.png"); var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, "FACEPLATE", null, 0, new nmiStandardForm { MaxTileWidth = 24, UseMargin = true }); var tMyForm = tFlds["Form"] as TheFormInfo; var tSBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, tMyForm, 10); tSBlock["Group"].SetParent(1); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 20, 0, 0x0, "Live Tags:", "LiveTagCnt", new nmiCtrlNumber() { ParentFld = tSBlock["Group"].FldOrder }); //TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 30, 0, 0x0, "Browsed Tags:", "BrowsedTagCnt", new nmiCtrlNumber() { ParentFld = tSBlock["Group"].FldOrder }); var tCBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, tMyForm, 100, (m, c) => { if (c) { Connect(false); } else { Disconnect(false, false, "Disconnect due to user/NMI request"); } }); tCBlock["Group"].SetParent(1); CreateConfigurationSection(writeEnableFlag, tMyForm, 500, 1); //TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TextArea, 13, 0, 0, "Last-Msg", "LastMessage", new ThePropertyBag() { "TileHeight=2", "TileWidth=6" }); #if USE_CSVIMPORT TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 400, 2, 0xc0, "Tag import...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup() { ParentFld = 1, DoClose = true, IsSmall = true, TileWidth = 6 })); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.DropUploader, 410, 2, 0xC0, "Drop a CSV or JSON file with tags", null, new nmiCtrlDropUploader { NoTE = true, TileHeight = 4, TileWidth = 3, ParentFld = 400, EngineName = MyBaseEngine.GetEngineName(), MaxFileSize = 52428800 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 420, 2, 0xC0, "Replace existing tags", nameof(ReplaceAllTagsOnUpload), new nmiCtrlSingleCheck { TileHeight = 1, TileWidth = 3, ParentFld = 400 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 425, 2, 0xC0, "Bulk apply tags", nameof(BulkApplyOnUpload), new nmiCtrlSingleCheck { TileHeight = 1, TileWidth = 3, ParentFld = 400 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.TileButton, 430, writeEnableFlag, 0xF0, "Export Tags", null, new nmiCtrlTileButton() { ClassName = "cdeGoodActionButton", TileWidth = 3, TileHeight = 1, ParentFld = 400, NoTE = true }) .RegisterUXEvent(MyBaseThing, eUXEvents.OnClick, "EXPORTTAGS", ExportTags); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 435, 2, 0xC0, "Export As CSV", nameof(ExportAsCSV), new nmiCtrlSingleCheck { TileHeight = 1, TileWidth = 3, ParentFld = 400 }); #endif TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 615, 2, 0xC0, "Security...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup() { ParentFld = 100, UseMargin = false, DoClose = true, IsSmall = true, TileWidth = 6 })); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 620, writeEnableFlag, 0xC0, "User Name", "UserName", new nmiCtrlSingleEnded { ParentFld = 615, TileWidth = 6, TileHeight = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Password, 630, writeEnableFlag | 1, 0xC0, "Password", "Password", new nmiCtrlPassword() { ParentFld = 615, HideMTL = true }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 640, writeEnableFlag, 0xC0, "Disable Security", "DisableSecurity", new nmiCtrlSingleCheck() { ParentFld = 615, TileWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 650, writeEnableFlag, 0xC0, "Accept Untrusted Cert", "AcceptUntrustedCertificate", new nmiCtrlSingleCheck { ParentFld = 615, TileWidth = 3, TileHeight = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 660, writeEnableFlag, 0xC0, "Disable Domain Check", "DisableDomainCheck", new ThePropertyBag() { "ParentFld=615", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 670, writeEnableFlag, 0xC0, "Accept Invalid Cert", "AcceptInvalidCertificate", new ThePropertyBag() { "ParentFld=615", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 680, writeEnableFlag, 0xC0, "Anonymous", "Anonymous", new ThePropertyBag() { "ParentFld=615", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleEnded, 690, writeEnableFlag, 0xC0, "Client Cert Subject Name", "AppCertSubjectName", new ThePropertyBag() { "ParentFld=615", "TileWidth=6", "TileHeight=1" }); #if USE_ADVANCED TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 600, 2, 0xC0, "Advanced Configurations...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup() { ParentFld = 1, DoClose = true, IsSmall = true /*, MaxTileWidth=18*/ })); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 695, 2, 0xC0, "Reconnects and Timeouts...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup() { ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6 })); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 700, writeEnableFlag, 0xC0, "Reconnect Delay", "ReconnectPeriod", new ThePropertyBag() { "ParentFld=695", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 710, writeEnableFlag, 0xC0, "Keep-Alive Interval", nameof(KeepAliveInterval), new ThePropertyBag() { "ParentFld=695", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 715, writeEnableFlag, 0xC0, "Keep-Alive Timeout", nameof(KeepAliveTimeout), new ThePropertyBag() { "ParentFld=695", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 720, writeEnableFlag, 0xC0, "Publishing Interval", nameof(PublishingInterval), new ThePropertyBag() { "ParentFld=695", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 730, writeEnableFlag, 0xC0, "Operation Timeout", "OperationTimeout", new ThePropertyBag() { "ParentFld=695", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.Number, 740, writeEnableFlag, 0xC0, "Session Timeout", "SessionTimeout", new ThePropertyBag() { "ParentFld=695", "TileWidth=6", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 745, 2, 0xC0, "Status info and data formats...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup() { ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6 })); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 750, writeEnableFlag, 0xC0, "Send Status Code", nameof(SendStatusCode), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 755, writeEnableFlag, 0xC0, "Use Local Timestamp", nameof(UseLocalTimestamp), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 760, writeEnableFlag, 0xC0, "Send Server Timestamp", nameof(SendServerTimestamp), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 770, writeEnableFlag, 0xC0, "Send Pico Seconds", nameof(SendPicoSeconds), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 772, writeEnableFlag, 0xC0, "Send OPC Data Type", nameof(SendOpcDataType), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 775, writeEnableFlag, 0xC0, "Send Sequence Number", nameof(SendSequenceNumber), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 778, writeEnableFlag, 0xC0, "Use OPC Sequence Number for Thing sequence", nameof(UseSequenceNumberForThingSequence), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 780, writeEnableFlag, 0xC0, "Do not use sub-properties ", nameof(DoNotUsePropsOfProps), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 790, writeEnableFlag, 0xC0, "Do not write array properties", nameof(DoNotWriteArrayElementsAsProperties), new ThePropertyBag() { "ParentFld=745", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.CollapsibleGroup, 795, 2, 0xC0, "Browsing and logging...", null, ThePropertyBag.Create(new nmiCtrlCollapsibleGroup() { ParentFld = 600, DoClose = true, IsSmall = true, TileWidth = 6 })); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 800, writeEnableFlag, 0xC0, "Do Not Use Parent Path", nameof(DoNotUseParentPath), new ThePropertyBag() { "ParentFld=795", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 810, writeEnableFlag, 0xC0, "Show Tags in Properties", nameof(ShowTagsInProperties), new ThePropertyBag() { "ParentFld=795", "TileWidth=3", "TileHeight=1" }); TheNMIEngine.AddSmartControl(MyBaseThing, tMyForm, eFieldType.SingleCheck, 820, writeEnableFlag, 0xC0, "Enable Data Logging", nameof(EnableOPCDataLogging), new ThePropertyBag() { "ParentFld=795", "TileWidth=3", "TileHeight=1" }); #endif mIsUXInitialized = true; return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 18, null, null, 0, ".Modbus TCP"); MyModConnectForm = tFlds["Form"] as TheFormInfo; var tStatusBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyModConnectForm, 10); tStatusBlock["Group"].SetParent(1); var tConnectBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyModConnectForm, 200, sinkConnect); tConnectBlock["Group"].SetParent(1); tConnectBlock["Group"].Header = "Modbus TCP Connectivity"; tConnectBlock["ConnectButton"].FldOrder = 280; tConnectBlock["DisconnectButton"].FldOrder = 290; TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 205, 2, 0, "Custom Port", nameof(CustomPort), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 206, 2, 0, "Slave Address", nameof(SlaveAddress), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 240, 2, 0, "Base Offset", nameof(Offset), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 250, 2, 0, "Polling Interval", nameof(Interval), new nmiCtrlNumber() { TileWidth = 3, MinValue = 100, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.SingleCheck, 260, 2, 0, "Keep Open", nameof(KeepOpen), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 270, 2, 0, "Address Type", nameof(ConnectionType), new nmiCtrlComboBox() { NoTE = true, Options = "Read Coils:1;Read Input:2;Holding Registers:3;Input Register:4;Read Multiple Register:23", DefaultValue = "3", TileWidth = 6, ParentFld = 200 }); ////METHODS Form MyFldMapperTable = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "FLDMAP"), eEngineName.NMIService, "Field Mapper", $"MBFLDS{MyBaseThing.ID}") { AddButtonText = "Add Tag", AddACL = 128 }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MyFldMapperTable, "CMyTable", "Field Mapper", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 50, 2, 0, "Property Name", "PropertyName", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 55, 2, 0, "Current Value", "Value", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3, Disabled = true, GreyCondition = "cde.CBool('%AllowWrite%')==false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 60, 2, 0, "Source Offset", "SourceOffset", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 70, 2, 0, "Source Size", "SourceSize", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 75, 2, 0, "Scale Factor", "ScaleFactor", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.ComboBox, 80, 2, 0, "Source Type", "SourceType", new nmiCtrlComboBox() { Options = "float;double;int32;int64;float32;uint16;int16;utf8;byte;float-abcd;double-cdab", TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleCheck, 90, 2, 0, "Allow Write", "AllowWrite", new nmiCtrlSingleEnded() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddTableButtons(MyFldMapperTable); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.CollapsibleGroup, 500, 2, 0x0, "Modbus Tags", null, new nmiCtrlCollapsibleGroup() { IsSmall = true, DoClose = true, TileWidth = 6, ParentFld = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.TileButton, 510, 2, 0xF0, "Show Field Mapper", null, new nmiCtrlTileButton() { OnClick = $"TTS:{MyFldMapperTable.cdeMID}", TileWidth = 6, TileHeight = 1, NoTE = true, ParentFld = 500, Background = "blue", Foreground = "white" }); SetupModbusProperties(false, null); mIsUXInitialized = true; return(true); }
public override bool CreateUX() { if (mIsUXInitCalled) { return(false); } mIsUXInitCalled = true; var tFlds = TheNMIEngine.AddStandardForm(MyBaseThing, MyBaseThing.FriendlyName, 18, null, null, 0, ".Modbus RTU"); MyModConnectForm = tFlds["Form"] as TheFormInfo; var tStatusBlock = TheNMIEngine.AddStatusBlock(MyBaseThing, MyModConnectForm, 10); tStatusBlock["Group"].SetParent(1); var tConnectBlock = TheNMIEngine.AddConnectivityBlock(MyBaseThing, MyModConnectForm, 200, sinkConnect); tConnectBlock["Group"].SetParent(1); tConnectBlock["Group"].Header = "Modbus TCP Connectivity"; tConnectBlock["ConnectButton"].FldOrder = 280; tConnectBlock["DisconnectButton"].FldOrder = 290; tConnectBlock["Address"].Type = eFieldType.ComboBox; try { var sports = SerialPort.GetPortNames(); string tp = TheCommonUtils.CListToString(sports, ";"); tConnectBlock["Address"].PropertyBag = new nmiCtrlComboBox { Options = tp }; } catch (Exception eee) { TheBaseAssets.MySYSLOG.WriteToLog(10000, TSM.L(eDEBUG_LEVELS.OFF) ? null : new TSM(MyBaseThing.EngineName, $"GetPortNames failed : {eee}", eMsgLevel.l1_Error)); } TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 205, 2, 0, "Baud", nameof(Baudrate), new nmiCtrlComboBox() { TileWidth = 3, ParentFld = 200, Options = "2400;4800;9600;19200;38400;57600" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 206, 2, 0, "Bit Format", nameof(BitFormat), new nmiCtrlComboBox() { TileWidth = 3, ParentFld = 200, Options = "8,N,1:0;8,E,1:1;8,O,1:2" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 207, 2, 0, "Slave Address", nameof(SlaveAddress), new nmiCtrlNumber() { TileWidth = 3, ParentFld = 200, MaxValue = 255, MinValue = 0 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 240, 2, 0, "Base Offset", nameof(Offset), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.Number, 250, 2, 0, "Polling Interval", nameof(Interval), new nmiCtrlNumber() { TileWidth = 3, MinValue = 100, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.SingleCheck, 260, 2, 0, "Keep Open", nameof(KeepOpen), new nmiCtrlSingleEnded() { TileWidth = 3, ParentFld = 200 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.ComboBox, 270, 2, 0, "Address Type", nameof(ConnectionType), new nmiCtrlComboBox() { Options = "Read Coils:1;Read Input:2;Holding Registers:3;Input Register:4;Read Multiple Register:23", DefaultValue = "3", ParentFld = 200 }); ////METHODS Form MyFldMapperTable = new TheFormInfo(TheThing.GetSafeThingGuid(MyBaseThing, "FLDMAP"), eEngineName.NMIService, "Field Mapper", $"MBFLDS{MyBaseThing.ID}") { AddButtonText = "Add Tag", AddACL = 128 }; TheNMIEngine.AddFormToThingUX(MyBaseThing, MyFldMapperTable, "CMyTable", "Field Mapper", 1, 3, 0xF0, null, null, new ThePropertyBag() { "Visibility=false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 50, 2, 0, "Property Name", "PropertyName", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleEnded, 55, 2, 0, "Current Value", "Value", new nmiCtrlSingleEnded() { TileWidth = 4, FldWidth = 3, Disabled = true, GreyCondition = "cde.CBool('%AllowWrite%')==false" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 60, 2, 0, "Source Offset", "SourceOffset", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 70, 2, 0, "Source Size", "SourceSize", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.Number, 75, 2, 0, "Scale Factor", "ScaleFactor", new nmiCtrlNumber() { TileWidth = 3, FldWidth = 1, DefaultValue = "1" }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.ComboBox, 80, 2, 0, "Source Type", "SourceType", new nmiCtrlComboBox() { DefaultValue = "byte", Options = "float;double;int32;int64;float32;uint16;int16;utf8;byte;float-abcd;double-cdab", TileWidth = 2, FldWidth = 2 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyFldMapperTable, eFieldType.SingleCheck, 90, 2, 0, "Allow Write", "AllowWrite", new nmiCtrlSingleEnded() { TileWidth = 1, FldWidth = 1 }); TheNMIEngine.AddTableButtons(MyFldMapperTable); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.CollapsibleGroup, 500, 2, 0x0, "Modbus Tags", null, new nmiCtrlCollapsibleGroup() { IsSmall = true, DoClose = true, TileWidth = 6, ParentFld = 1 }); TheNMIEngine.AddSmartControl(MyBaseThing, MyModConnectForm, eFieldType.TileButton, 510, 2, 0xF0, "Show Field Mapper", null, new nmiCtrlTileButton() { OnClick = $"TTS:{MyFldMapperTable.cdeMID}", TileWidth = 6, TileHeight = 1, NoTE = true, ParentFld = 500, Background = "blue", Foreground = "white" }); SetupModbusProperties(false, null); mIsUXInitialized = true; return(true); }