Author Topic: How to create an EasyPLC External Driver with C++  (Read 10165 times)

dannyvdh

  • Newbie
  • *
  • Posts: 13
    • VDH Software Solutions BVBA
How to create an EasyPLC External Driver with C++
« on: December 04, 2009, 04:08:26 PM »
Can you give me an example how to create a driver with borland builder C or Visual Studio C
Normaly I have to make a lib file from the InterfaceIO.dll with implib
Then I have to write a header file with the external functions and import the lib file
Any example will help

Thanks

EasyPLC_Master

  • Developer
  • Administrator
  • *****
  • Posts: 849
  • Nirtec
    • The EasyPLC Project
Re: How to create an EasyPLC External Driver with C++
« Reply #1 on: December 05, 2009, 12:44:44 PM »
In the EasyPLC Regsitered version documentation, a couple of Visual Basic 6.0 examples are provided about how to create a External Driver for EasyPLC.
If you wan to use other programming language you must to be sure this language supports the ActiveX/COM Microsoft technology. Obviously Visual Studio C supports it. You can find in Internet a lot of examples of how to create a ActiveX/COM libraries with Visual Studio C, for example a good tutorial can be found on: http://www.flipcode.com/archives/Interfacing_Visual_Basic_And_C.shtml
Then with the EasyPLC documentation help and this tutorials is possible to create the needed libraries.
Anyway if you still have problems comment me and I will try to provide some examples.

Regards.

dannyvdh

  • Newbie
  • *
  • Posts: 13
    • VDH Software Solutions BVBA
Re: How to create an EasyPLC External Driver with C++
« Reply #2 on: December 05, 2009, 09:50:18 PM »
Can you give me some example(s) how to interact with the TCP/IP external driver ,maybe this is a possibility to communicate with my environment.
I have written a few communication programs to interact with siemens S7 hardware and S7 PLCSIM software plc.
If I can sent the IO with TCP/IP client it would be great!

All help is welcome, Thanks


EasyPLC_Master

  • Developer
  • Administrator
  • *****
  • Posts: 849
  • Nirtec
    • The EasyPLC Project
Re: How to create an EasyPLC External Driver with C++
« Reply #3 on: December 06, 2009, 11:32:12 AM »
The provided TCP/IP external driver has a closed protocol, this means that is designed to communicate two remote PC's running each one EasyPLC with this driver, one configured like server and the other like client.
Also with this driver is possible to manage the EasyPLC declared I/O remotely, configuring this driver like HTML server, then with some electronic device with internet acces is possible to manahe them.
If you want to use a specific TCP/IP protocol, you must to create your own External Driver. With Visual Basic using the winsock control provided by it, is very easy to do it. You can find on Internet a lot of documentation about the Visual Basic winsock control.

dannyvdh

  • Newbie
  • *
  • Posts: 13
    • VDH Software Solutions BVBA
Re: How to create an EasyPLC External Driver with C++
« Reply #4 on: December 07, 2009, 11:19:12 PM »
Sorry but I am not that strong to start with it, if you can provide me with any little example in c visual studio to communicate
with machines simulator by a little prog to activate a input/output channel I would be very happy.
I can translate visual c++ example to Borland c++ builder,cos thats the environment I work with.
Borland C++ Builder has ActiveX/Com possibilities.
I made lots of communication drivers with a little help of the authors, It would be a fine extension to your programs!
I worked with Trysim for many projects but yours is much more realistic! I hope you work on it for a long time and extend it with lots of possibilities! 
From the moment I can write a gateway I make a uni-driver for different plc's and off course plcsim from Siemens! and even with a opc client.
( 8) I will pay for it if necessary ,sent me a mail with your prices.)

Thanks in advance

EasyPLC_Master

  • Developer
  • Administrator
  • *****
  • Posts: 849
  • Nirtec
    • The EasyPLC Project
Re: How to create an EasyPLC External Driver with C++
« Reply #5 on: December 08, 2009, 12:54:33 PM »
OK!, pay attention in the next days, I will create a new thread in this forum with the instructions of how to make an External driver for EasyPLC with Microsoft Visual C++. 
I'm sorry but for my software politics its not possible to communicate any software directly with Machines Simulator. You always must to use EasyPLC to manage the Machines Simulator software. 
If you want to use third party's software you must to use EasyPLC to interface it with Machines Simulator.   
Then I think that you must to create an EasyPLC External Driver with your custom needs.   
All customers opinions, suggestions and improvements are welcome to going growing the EasyPLC project!

dannyvdh

  • Newbie
  • *
  • Posts: 13
    • VDH Software Solutions BVBA
Re: How to create an EasyPLC External Driver with C++
« Reply #6 on: December 08, 2009, 01:36:57 PM »
That machines simulator always use easyplc is no problem, if you can add drivers to communicate with other soft/hardware will be strong enough.
Another thread in this forum to put custom made components into (or links) will also be fine! because this will make the program more and more
interesting for anyone!
There is so much to do with this kind of program, even a manual how to create your own models will be very interesting to.
I'll think you will have lots of work in the future if you would make this a excellent tool for everyone how has something with automation!
Thanks for developing this kind of software.

See Ya!
 

bill534

  • Newbie
  • *
  • Posts: 3
Re: How to create an EasyPLC External Driver with C++
« Reply #7 on: December 27, 2010, 06:47:58 AM »
Dear
I am programming with delphi. I would like to communication with shared memory. I have registered Sharedmemory.dll.th
Following function need a parameter which name of lpName. What's name,I must to give it.

HANDLE CreateFileMapping(

    HANDLE hFile,   // handle to file to map
    LPSECURITY_ATTRIBUTES lpFileMappingAttributes,   // optional security attributes
    DWORD flProtect,   // protection for mapping object
    DWORD dwMaximumSizeHigh,   // high-order 32 bits of object size 
    DWORD dwMaximumSizeLow,   // low-order 32 bits of object size 
    LPCTSTR lpName    // name of file-mapping object
   );

EasyPLC_Master

  • Developer
  • Administrator
  • *****
  • Posts: 849
  • Nirtec
    • The EasyPLC Project
Re: How to create an EasyPLC External Driver with C++
« Reply #8 on: December 27, 2010, 08:01:58 PM »
if you google the windows api function: CreateFileMapping, you can find all the explanation about the parameters,

for your question:

lpName [in, optional]

    The name of the file mapping object.

    If this parameter matches the name of an existing mapping object, the function requests access to the object with the protection that flProtect specifies.

    If this parameter is NULL, the file mapping object is created without a name.

    If lpName matches the name of an existing event, semaphore, mutex, waitable timer, or job object, the function fails, and the GetLastError function returns ERROR_INVALID_HANDLE. This occurs because these objects share the same namespace.


Summarizing: this parameter is the 'virtual' name that you give to the memmory mapped file.

bill534

  • Newbie
  • *
  • Posts: 3
Re: How to create an EasyPLC External Driver with C++
« Reply #9 on: December 28, 2010, 10:19:05 AM »
Dear

Sorry,I have some question. Would you please give me some suggestions to solve my question.

In Easyplc,I have configure digital inputs 8 bytes and digital outputs 8 bytes.

I use following segment to open sharedmemory but OpenFileMapping function always return zero. Is my procedure right ?

FHandle := OpenFileMapping(FILE_MAP_ALL_ACCESS, false, pchar('virtual'));
         :
         :
pDevice := MapViewOfFile(FHandle, lMapping, 0, 0, SizeOf(TjiSHV)); TjiSHV = array[1..16] of Byte

EasyPLC_Master

  • Developer
  • Administrator
  • *****
  • Posts: 849
  • Nirtec
    • The EasyPLC Project
Re: How to create an EasyPLC External Driver with C++
« Reply #10 on: January 01, 2011, 06:53:01 PM »
This is due the 'virtual' file still have not been created.

You must to set the name virtual in the field Virtual file name of the Shared Memory External Driver of EasyPLC.
Then the EasyPLC must to be running in order to create the virual file, then after, the FHandle variable must to return you the reference of the mapped file.

bill534

  • Newbie
  • *
  • Posts: 3
Re: How to create an EasyPLC External Driver with C++
« Reply #11 on: January 03, 2011, 02:25:11 AM »
Dear  ;D
I can communication with easyplc now. Thk's. :-*