public void AddConnectionWizard() { var flds = TheNMIEngine.AddNewWizard <TheModbusWiz>(new Guid("{824858DA-061A-4A70-92E3-A31B2D8C7800}"), Guid.Empty, TheNMIEngine.GetEngineDashBoardByThing(MyBaseThing).cdeMID, "Welcome to the Modbus Connection Wizard", new nmiCtrlWizard { PanelTitle = "<i class='fa faIcon fa-5x'></i></br>New Modbus Connection", SideBarTitle = "New Modbus Connection Wizard", SideBarIconFA = "", TileThumbnail = "FA5:f545" }, (myClass, pClientInfo) => { myClass.cdeMID = Guid.Empty; TheThing tMemTag = null; if (myClass.DeviceType == "RTU") { var tReq = new TheThingRegistry.MsgCreateThingRequestV1() { EngineName = MyBaseEngine.GetEngineName(), DeviceType = eModbusType.ModbusRTUDevice, FriendlyName = myClass.ClientName, OwnerAddress = MyBaseThing, InstanceId = Guid.NewGuid().ToString(), Address = myClass.Address, Properties = new Dictionary <string, object> { { "Baudrate", myClass.Baudrate }, { "BitFormat", myClass.BitFormat }, { "AutoConnect", myClass.AutoConnect }, { "SlaveAddress", myClass.SlaveAddress }, }, CreateIfNotExist = true }; tMemTag = TheThingRegistry.CreateOwnedThingAsync(tReq).Result; } else { var tReq = new TheThingRegistry.MsgCreateThingRequestV1() { EngineName = MyBaseEngine.GetEngineName(), DeviceType = eModbusType.ModbusTCPDevice, FriendlyName = myClass.ClientName, OwnerAddress = MyBaseThing, InstanceId = Guid.NewGuid().ToString(), Address = myClass.Address, Properties = new Dictionary <string, object> { { "IpPort", myClass.Port }, { "AutoConnect", myClass.AutoConnect }, { "SlaveAddress", myClass.SlaveAddress }, }, CreateIfNotExist = true }; tMemTag = TheThingRegistry.CreateOwnedThingAsync(tReq).Result; } tTargetButton.SetUXProperty(pClientInfo.NodeID, $"OnClick=TTS:{tMemTag.GetBaseThing().cdeMID}"); }); var tMyForm2 = flds["Form"] as TheFormInfo; tMyForm2.RegisterEvent2(eUXEvents.OnShow, (para, obj) => { var pMsg = para as TheProcessMessage; if (pMsg?.Message == null) { return; } }); var tFlds = TheNMIEngine.AddNewWizardPage(MyBaseThing, tMyForm2, 0, 1, 2, null /*"Name and Address"*/, "3:'<%DeviceType%>'=='RTU'"); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.SingleEnded, 1, 1, 2, 0, "Connection Name", "ClientName", new TheNMIBaseControl { Explainer = "1. Enter name for the new Modbus connection.", }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.ComboBox, 1, 2, 2, 0, "Modbus Type", "DeviceType", new nmiCtrlComboBox { Options = "RTU;TCP", Explainer = "2. Select the Type of Modbus Connection.", }); tFlds = TheNMIEngine.AddNewWizardPage(MyBaseThing, tMyForm2, 1, 2, 0, null /*"Name and Address"*/); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.SingleEnded, 2, 1, 2, 0, "IP Address or DNS", "Address", new TheNMIBaseControl { Explainer = "1. Enter IP Address or DNS name of Server.", }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.Number, 2, 2, 2, 0, "Port", "Port", new TheNMIBaseControl { DefaultValue = "502", Explainer = "2. Enter port of the modbus server.", }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.Number, 2, 3, 2, 0, "Slave Address", "SlaveAddress", new nmiCtrlNumber() { DefaultValue = "1", TileWidth = 3, ParentFld = 200, MaxValue = 255, MinValue = 0 }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.SingleCheck, 2, 4, 2, 0, "Auto-Connect", "AutoConnect", new nmiCtrlSingleCheck { DefaultValue = "true", Explainer = "3. If selected the connection will auto-connect.", }); tFlds = TheNMIEngine.AddNewWizardPage(MyBaseThing, tMyForm2, 1, 3, 0, null /*"Name and Address"*/); var ComSelect = TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.ComboBox, 3, 1, 2, 0, "Select COM Port", "Address", new TheNMIBaseControl { Explainer = "1. Select the COM port connected to your Server.", }); try { var sports = SerialPort.GetPortNames(); string tp = TheCommonUtils.CListToString(sports, ";"); ComSelect.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.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.ComboBox, 3, 2, 2, 0, "Baud", "Baudrate", new nmiCtrlComboBox() { TileWidth = 3, ParentFld = 200, Options = "2400;4800;9600;19200;38400;57600" }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.ComboBox, 3, 3, 2, 0, "Bit Format", "BitFormat", new nmiCtrlComboBox() { TileWidth = 3, ParentFld = 200, Options = "8,N,1:0;8,E,1:1;8,O,1:2" }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.Number, 3, 4, 2, 0, "Slave Address", "SlaveAddress", new nmiCtrlNumber() { DefaultValue = "1", TileWidth = 3, ParentFld = 200, MaxValue = 255, MinValue = 0 }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.SingleCheck, 3, 5, 2, 0, "Auto-Connect", "AutoConnect", new nmiCtrlSingleCheck { DefaultValue = "true", Explainer = "2. If selected the connection will auto-connect.", }); TheNMIEngine.AddWizardFinishPage(MyBaseThing, tMyForm2, 5); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.SmartLabel, 5, 1, 0, 0, null, null, new nmiCtrlSmartLabel { NoTE = true, TileWidth = 7, Text = "Done...what do you want to do next?", TileHeight = 2 }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.TileGroup, 5, 2, 0, 0, null, null, new nmiCtrlTileGroup { TileWidth = 1, TileHeight = 2, TileFactorX = 2 }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.TileButton, 5, 3, 2, 0, "Go to Modbus Dashboard", null, new nmiCtrlTileButton { NoTE = true, TileHeight = 2, TileWidth = 3, OnClick = $"TTS:{mMyDashboard.cdeMID}", ClassName = "cdeTransitButton" }); TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.TileGroup, 5, 4, 0, 0, null, null, new nmiCtrlTileGroup { TileWidth = 1, TileHeight = 2 }); tTargetButton = TheNMIEngine.AddWizardControl(MyBaseThing, tMyForm2, eFieldType.TileButton, 5, 5, 2, 0, "Go to New Connection", null, new nmiCtrlTileButton { NoTE = true, TileHeight = 2, TileWidth = 3, ClassName = "cdeTransitButton" }); }