API Help
EPLAN API / User Guide / API Electrotechnical services / Verifications
In This Topic
    Verifications
    In This Topic

    You can use an EPLAN API add-in to add new verifications. EPLAN will use them in the same way as already existing internal verifications. 

    For a new verification the add-in has to implement the interface IVerification. 

    C#
    Copy Code
    public class NewVerification : Eplan.EplApi.EServices.Verification
    {
        private int m_iMessageId = 30;
        /// <summary>
        /// Default constructor.
        /// </summary>
        public NewVerification()
        {
        }
        /// <summary>
        /// In this function, the test logic will implement. 
        /// </summary>
        /// <param name="oObject1">
        /// This object is tested.  One can be certain that here only
        /// function objects of the desired category arrive
        /// </param>
        public override void Execute(Eplan.EplApi.DataModel.StorableObject oObject1)
        {
            DoErrorMessage(oObject1, oObject1.Project, "Verification dynamic text");
        }
        /// <summary>
        /// This function is called after end of all verifications run.
        /// </summary>
        public override void OnEndInspection()
        {
            // TODO:  Add NewVerification.OnEndInspection implementation
        }
        /// <summary>
        /// Registration function of the verification.
        /// </summary>
        /// <param name="strName">
        /// Under this name, the new verification registered  in the system.
        /// </param>
        /// <param name="iOrdinal">
        /// Overload priority. 
        /// </param>
        public override void OnRegister(ref string strName, ref int iOrdinal)
        {
            strName = "NewVerification";
            iOrdinal = 30;
            this.VerificationPermission = IVerification.Permission.OnlineOfflinePermitted;
            this.VerificationState = IVerification.VerificationState.OnlineOfflineState;
        }
        /// <summary>
        /// This function is called before start of all verifications run.
        /// </summary>
        /// <param name="bOnline">
        /// true: online verification
        /// false: offline verification
        /// </param>
        public override void OnStartInspection(bool bOnline)
        {
            // TODO:  Add NewVerification.OnStartInspection implementation
        }
    
        /// <summary>
        /// This function must deliver the accompanying message text. 
        /// A test has always exactly an accompanying message text. 
        /// </summary>
        /// <returns>Der Meldungstext</returns>
        public override string GetMessageText()
        {
            return "Verification static text . %1!s!";
        }
        ///<summary>
        ///This function is called if to a message the aid text is supposed to be indicated. 
        ///It lies in the responsibility of the Implementation of the function to call
        ///the suitable aid system in the correct language.
        ///In the simplest case, for example only a simple dialog can be called. 
        ///</summary>
        public override void DoHelp()
        {
            // TODO:  NewVerification.DoHelp implementation
        }
        /// <summary>
        /// This function is called of the system if the message of this test
        ///  is supposed to be registered in the system. 
        /// </summary>
        /// <param name="strCreator">Creator of the message</param>
        /// <param name="eRegion">Message region</param>
        /// <param name="iMessageId">Number of the message</param>
        /// <param name="eClassification">Default classification.  </param>
        /// <param name="iOrdinal">Overload priority.</param>
        public override void OnRegister(ref String strCreator, ref Eplan.EplApi.EServices.IMessage.Region eRegion, ref int iMessageId, ref Eplan.EplApi.EServices.IMessage.Classification eClassification, ref int iOrdinal)
        {
            strCreator = "Author";
            eRegion = IMessage.Region.Externals;
            iMessageId = m_iMessageId;
            eClassification = IMessage.Classification.Error;
            iOrdinal = 20;
        }
    }
    
     
    
     
    

    In order to make creating a verification easier, the EPLAN API has some base classes, which provide a few service functions. 

    These base classes are:

     

    In your add-in you just let your verification class inherit from one of these base classes and implement the necessary interface functions. For outputting messages, then different variations of the AddMessage() function are available. Additionally, the classes contain some functions to find cross-referenced objects. 

    If you want to implement a verification that verifies something concerning potentials then you implement a new verification derived from PotentialVerification. In the Execute function of your new verification you can use the function GetAllPotentialsWithSameName() to get the potential from the verification cache. It makes no sense to call this function in other context than in verification Execute(). 

    All registered verifications will be called from the system by using "Check project...". If you want to execute only your verification, then you have to configure the settings for the check (create new scheme, disable other verifications ("Type of check": No)) 

    Please take into account that in comparison to 1.9 version, verifications that inherit from Verification class need to have 'override' keyword in base methods' definitions. This is required since API extension was migrated to C++/CLI . 

     

    How to start a verification 

    Verifications can be invoked from API or GUI in 3 modes: 

    C#
    Copy Code
    using (UndoStep oUndo = new UndoManager().CreateUndoStep())
    {
    oFunction.Location = new PointD(oFunction.Location.X + 10.0, oFunction.Location.Y + 10.0);
    }
    
    
    

     Prevent errors mode (restrictive mode). This is similar to Online mode, but in case DoErrorMessage() is called, the last UndoStep is undone automatically, so that the last changes are reverted. For 'Prevent errors mode' you should set the following options in OnRegister of the verification:

    C#
    Copy Code
    this.VerificationPermission = IVerification.Permission.RestrictivePermitted;
    this.VerificationState = IVerification.VerificationState.RestrictiveState;
    
    
    
    See Also