- Manuale introduttivo
- Creare progetti
- OPC UA
- Oggetti grafici
- Oggetti grafici predefiniti
- Esercitazione sugli oggetti grafici
- Collegamenti dinamici
- Allarmi
- Ricette
- Logger
- Traduzioni
- Sessioni e impostazioni locali
- Riferimenti a oggetti e variabili
- Estensione dei progetti
- NetLogic
- Esercitazione sulle NetLogic
- Riferimento API C#
Sviluppare una NetLogic che gestisce gli accessi
Questa NetLogic convalida nomi utente e password.
Prerequisiti
Impostare l'editor di codice esterno predefinito. Vedere Impostare l'editor di codice predefinito.
- Per sviluppare una NetLogic che gestisce gli accessi
- InVista progetto, fare doppio clic suLoginFormNetLogic.L'editor di codice esterno si apre in una scheda separata.
- Nell'editor di codice, sostituire il codice esistente con il codice seguente:#region Using directives using System; using UAManagedCore; using OpcUa = UAManagedCore.OpcUa; using FTOptix.HMIProject; using FTOptix.UI; using FTOptix.NativeUI; using FTOptix.Core; using FTOptix.CoreBase; using FTOptix.NetLogic; #endregion public class LoginFormNetLogic : BaseNetLogic { public override void Start() { // Insert code to be executed when the user-defined logic is started } public override void Stop() { // Insert code to be executed when the user-defined logic is stopped } [ExportMethod] public void Login(string username, string password) { if (!PerformLogin(username, password)) { // Set incorrect login message var messageVariable = LogicObject.GetVariable("Message"); messageVariable.Value = "Incorrect login"; return; } // Check the correct type of PanelLoader PanelLoader panelLoader = (PanelLoader)Owner.Owner; if (panelLoader == null) { Log.Error(panelLoader + " is not a PanelLoader"); return; } // Retrieve Panel variable var panelVariable = (NodeId)LogicObject.GetVariable("Panel").Value; if (panelVariable == NodeId.Empty) { Log.Error("Panel variable is empty"); return; } // Perform ChangePanel panelLoader.ChangePanel(panelVariable, NodeId.Empty); } private bool PerformLogin(string username, string password) { return Session.ChangeUser(username, password); } }
- Salvare il codice.
Fornire un feedback