Automation Platform. Code source modification from C#

davec
2015-08-10
2015-08-13
  • davec - 2015-08-10

    Hi,
    we need to modify the source code of our Codesys project directly from C#.
    I've done some search in the Automation Platform documentation, tried all examples but i'm stuck at the Visitor Pattern, I really don't know how to handle this.

    What we want to do is, from C#, we need to add parameter {attribute} before an object in Codesys project that can be of type GVL, POU, Function, Enum, etc.
    In the document AP_Concepts_LanguageModelManager(page 34) there is an example for Visitor Pattern. I'm able to get the CompilationContext, CompiledPou , i've created an instance of "ChangeStatement" (it's Private in the example but i guess it should be Public) but I don't know how to visit each element.

    Do you have a source code of an actual example modifying Codesys project source code from C# ?

    Regards,
    Dave

     
  • r.evbatyrov - 2015-08-13

    Hi Dave,

    please note, that CODESYS Forum is an end-user forum, where topics conserning the of CODESYS are discussed. Automation Platfrom is not an add-on or store product. It is not how to use CODESYS, but how CODESYS made of.

    The proper place for such discussions is Developer Network
    http://dn.codesys.com/

    Here just a short answer.
    With language model expression visitor you can modify the language model (how the source is interpeted), but not a source code itself.
    If you want to modify a source code, you have to access the object (document AP_Concepts_LanguageModelManager is not about it at all).
    If you want to mofify a language model:
    1. Creare a pragma attribute statement using
    IPragmaStatement ILanguageModelBuilder3.CreatePragmaAttributeStatement(IExprementPosition pos, string attributeName, string attributeValue)
    2. The statement can be added/inserted with ISequenceStatement.AddStatemnt(IStatement) / ISequenceStatement.InsertStatement(int,IStatement) to desired part of language model tree.

    Regards,
    Roman

     
  • davec - 2015-08-13

    Hi Roman,
    thank you for clarification, I was really going the wrong way with LanguageModel.
    As suggested, i'll ask help on the developer network

    Regards,
    Dave

     
  • r.evbatyrov - 2015-08-13

    Hi Dave,
    sorry for misleading answer - there is actually no forum for Automation Platform.
    Developer Network is a documentation/samples resource.
    Just contact Support for AP questions; your inquiry will be directed to responsible person.

    Regards
    Roman

     

Log in to post a comment.