GithubHelp home page GithubHelp logo

Create a custom CIP Object about opener HOT 2 CLOSED

igorbzin avatar igorbzin commented on September 13, 2024
Create a custom CIP Object

from opener.

Comments (2)

azoitl avatar azoitl commented on September 13, 2024

The only examples available are the implementations of the standard CIP objects needed for a generic communications adapter. An object where many of the neede functionality can be found is the TCPIP Interface object.

The general sequence for setting up such an object is:

  1. Create a CIPObject:
    p_stTCPIPClass = createCIPClass(YOUR_OBJECT_CLASS_CODE, /Check CIP speck for valid ranges */
    0, /
    # class attributes_/
    0xffffffff, /_ class getAttributeAll mask keep it to all 1 so that the default get attribute all will work_/
    0, /_ # class services_/
    1, /_ # instance attributes_/
    0xffffffff, /_ instance getAttributeAll mask_/
    1, /_ # of additional instance services (getAttributeSingle and getAttributeAll are added per default_/
    1, /_ # instances which should already be create now_/
    "our obect name",
    1 /_revision of your object, 1 is here a good thing to start with */
    );

  2. configure your instances:
    attributes should typically be put into the instances of your object

    pstInstance = getCIPInstance(p_stTCPIPClass, 1); /* bind attributes to the instance #1 that was
    created above*/

    insertAttribute(pstInstance,
    1, /* Atrtibute number /
    CIP_UINT, /
    data type of attribute _/
    (void ) &attributeMemory); /_a memory place for your attribute/

  3. configure the instance services
    insertService(p_stTCPIPClass, CIP_SET_ATTRIBUTE_SINGLE,
    &setAttributeSingleMyObject, "SetAttributeSingle");

  4. Implement the service:
    EIP_STATUS
    setAttributeSingleTCP(S_CIP_Instance pa_pstObjectInstance,
    S_CIP_MR_Request *pa_pstMRRequest, S_CIP_MR_Response *pa_pstMRResponse)
    {
    if (1 == pa_pstMRRequest->RequestPath.AttributNr)
    {
    /
    This is a request for our attribute one_/
    decodeData(CIP_UINT, &attributeMemory, &pa_pstMRRequest->Data);
    /_TODO if you have more instances: determine which instance the request was target to /
    pa_pstMRResponse->GeneralStatus = CIP_ERROR_SUCCESS;
    }
    else
    {
    /
    we don't have this attribute */
    pa_pstMRResponse->GeneralStatus = CIP_ERROR_ATTRIBUTE_NOT_SUPPORTED;
    }

    pa_pstMRResponse->SizeofAdditionalStatus = 0;
    pa_pstMRResponse->DataLength = 0;
    pa_pstMRResponse->ReplyService = (0x80 | pa_pstMRRequest->Service);
    return EIP_OK_SEND;
    }

I hope this helps.

from opener.

MartinMelikMerkumians avatar MartinMelikMerkumians commented on September 13, 2024

As no further questions were posted to this topic I will close this issue.

from opener.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.