Setting up SoftPAC's ScratchPad to use OptoMMP?


#1

I want to use the “PAC .NET OptoMMP SDK” to talk to the ScratchPad on SoftPAC. My goal is for my Windows program to write to and read from the Scratch Pad on SoftPAC, which I understand is the way to do it with SoftPAC and MMP - the ScratchPad is the only are accessible via MMP on a SoftPAC.

I wrote a Windows program in C++ and have added “OptoMMP3.dll” as a Resource. I can instantiate an OptoMMP object with no errors, and would like to “Open()” it and start sending/receiving scratch pad data using the Scratch Pad commands for OptoMMP. Given the examples that are provided, after instantiating the OptoMMP object, I use the following command to open the connection to the scratchpad on my SoftPAC:

result = m_pMmpObj->Open( “10.0.10.10”, 22001, OptoMMP::Connection::UdpIp,3000,true );

Thing is, I’m getting errors. Like -2, -10, -11 and such, and sometimes “bCommFault” and “bProtocolFault” when I call GetExtended ErrorInformation().

I’m a little confused on how to set up the SoftPAC so I must be doing something wrong. My understanding is I need to add an “I/O Unit” of type “Generic OptoMMP Device”, so based on the instructions in document 1704, I launched Pad Manager, created an I/O unit like this. For the IP address, rather than use the loopback address I used a the static IP I assigned to my SoftPAC. 10.0.10.10. I arbitrarily chose the port 22001. I launch PAC Control Pro, open my Strategy, set the Strategy up to use SoftPAC as it’s Control Unit. Run the strategy. I then launch my Windows program and execute the command above, but get the results I mentioned.

Questions:

  • Do I need to [I]also[/I] create an I/O Unit in the Strategy that’s of type “Generic OptoMMP Device”??
  • Do I need to do anything in the Strategy running on SoftPAC to get it to connect via MMP?
  • Does it matter if I use UPD or TCP/IP?
  • Is there a specific port number I need to use?
  • SoftPAC runs and I can access it at “10.0.10.10” with Pac Manager.

If there’s anything else I’m obviously doing wrong, please let me know.

Thanks,
Mark.


#2

Hi Mark,

When you access the OptoMMP part of SoftPAC, it’s via port [I]2001[/I] by default (I don’t recommend changing that default). When you download a strategy to the “control engine” part of SoftPAC, that’s via port [I]22001[/I]. So in your Open() call, change the port to 2001. In your strategy, create an I/O Unit of type “Generic OptoMMP” at address 127.0.0.1 port 2001 (also the default). Then you should be good to go.

To answer your questions:

  • Q: Do I also need to create…
    A: While you [I]can [/I]create an I/O Unit in PAC Manager, then import that otg file into PAC Control, it’s easier to just create it in PAC Control directly. We should probably update the instructions you saw in 1704 (can you tell me what lead you to 1704 for the in the first place so we can get that cleared up?)

  • Q: Do I need to do anything in the Strategy?..
    A: To move your tag tree variables in/out of the mem map (port 2001) part of SoftPAC for access from your custom software, you’ll use commands from the “I/O Unit - Scratch Pad” group like “Set I/O Unit Integer 32 Element” and those commands require and I/O Unit. That’s where you’ll use that “Generic OptoMMP” unit which you’ll configure for “loopback” IP address 127.0.0.1, specifically port 2001.

  • Q: Does it matter if I use UDP or TCP?
    A: Best to use UDP, which is “connectionless” so you don’t have to worry about how many connections you have in use at any given time.

  • Q: Is there a specific port number I need to use?
    A: Yes, use 2001 for all your OptoMMP communications.

  • SoftPAC running at 10.0.10.10 is good, but when you configured your I/O Unit, we normally recommend 127.0.0.1 when you’re “talking to self” so if you later change that 10.0.10.10 you have fewer places to remember to update that IP address.

I hope that all makes sense!

-OptoMary


#3

Thanks for the info and the clarification about which port to use. This has always been confusing.

I wound up contacting support last Friday and talked with an engineer to looked over a copy of my C++ code. He ran it locally on his system and discovered the version of the “OPTOMMP DOTNET” software SDK I was using had a bug that was fixed in version 3.0.3.0. He gave me a link to your FTP site and I downloaded the latest OptoMMP3.dll file as well as the latest SDK zip and the software is now connecting to my strategy.

Oh, also… regarding what lead me to look at 1704, in document 1700 page 289 it says: “For details on the Scratch Pad area, see Opto 22 form 1704, the PAC Manager User’s Guide.”

Mark