You are not registered yet. Please click here to register!


 
 
plc storereviewsdownloads
This board is for PLC Related Q&A ONLY. Please DON'T use it for advertising, etc.
 
Try our online PLC Simulator- FREE.  Click here now to try it.

---------->>>>>Get FREE PLC Programming Tips

New Here? Please read this important info!!!


Go Back   PLCS.net - Interactive Q & A > PLCS.net - Interactive Q & A > LIVE PLC Questions And Answers

PLC training tools sale

Reply
 
Thread Tools Display Modes
Old January 10th, 2018, 09:59 AM   #1
bjh
Member
United States

bjh is offline
 
Join Date: Jul 2010
Location: Madison, WI
Posts: 220
RSLogix500 Compare through Command Line?

I've been using Git and Microsoft's VSTS for software versioning, source control and work tracking lately for all of my projects, PLC and C# to great success - except for one thing.

Because RS500 .RSS files are compiled binaries (and ladder logic) they cannot be compared easily. The RSLogix500 Compare tool is great for this and I'd like to be able to launch it automatically as my "diff" tool in git for these files but I haven't had any success in figuring out how!

I'm looking for something command line based, like this:
Code:
rs500.exe /compare "oldProgram.RSS" "newProgram.RSS"
  Reply With Quote
Old January 11th, 2018, 04:15 PM   #2
bjh
Member
United States

bjh is offline
 
Join Date: Jul 2010
Location: Madison, WI
Posts: 220
Well, I couldn't find a way to make RSLogix 500 open in the "Compare" mode through the command line, so I made an ugly hack instead. It's made even more complicated for me because I keep my git tools on my host and my PLC Programming in a VMWare image and use unity mode which makes things even more worse.

So, that being said, here's what I did.

I made a .bat that opens my VM, enters unity mode and opens a custom RSLogix 500 Launcher with arguments as the source/compare project:

Code:
REM Compare500RSS.bat
REM @echo off
C:
cd C:\Program Files (x86)\VMware\VMware Workstation

REM Start VM
vmrun -T ws start "C:\Users\xxxx\Virtual Machines\RSLogix 500\RSLogix 500.vmx" nogui

REM Now run application 
vmware-unity-helper.exe -r -G:6 -V:1
vmrun -T ws -gu xxxx -gp xxxx runProgramInGuest "C:\Users\xxxx\Virtual Machines\RSLogix 500\RSLogix 500.vmx" -activeWindow -interactive -nowait "C:\Utilities\RSlogix 500 Compare.exe " %1 %2

exit
I then used this Compare500RSS.bat as my external "git difftool" in my git config

Code:
[diff]
[difftool "Compare500File"]
	cmd = "\"C:/Compare500RSS.bat\" \"$LOCAL\" \"$REMOTE\""
[diff]
	tool = Compare500File
The "RSLogix 500 Compare.exe" I made in c# - the launcher translates the path to what the VM sees in the shared folder to my host hard drive, loads up RSLogix, then (disgusting hack alert!!!) uses a series of keystokes to call up the compare utility and enter in all the info (base project path, compare project path etc), maximize and rearrange windows etc. Again, this was whipped up on the fly and is not pretty or perfect but it does work.

Code:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace RSlogix_500_Compare
{
    class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]

        [DllImport("user32.dll")]
        public static extern IntPtr FindWindow(string lpClassName, string lpWindowName);

        [DllImport("user32.dll", CharSet = CharSet.Unicode)]
        public static extern bool SetForegroundWindow(IntPtr hWnd);

        [DllImport("user32.dll")]
        private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
        static void Main(string[] args)
        {
            //Start RSLogix
            ProcessStartInfo si = new System.Diagnostics.ProcessStartInfo();
            si.CreateNoWindow = true;
            si.FileName = "C:\\Program Files (x86)\\Rockwell Software\\RSLogix 500 English\\rs500.exe";          
            si.UseShellExecute = false;
            System.Diagnostics.Process.Start(si);

            //Wait for it to boot
            System.Threading.Thread.Sleep(3000);

            //Get the handle of the RSLogix window
            System.IntPtr iHandle = FindWindow(null, "RSLogix 500");
            if (iHandle != IntPtr.Zero)
            {
                //Maximize the window
                ShowWindow(iHandle, 3);
                //Alt-t then c for compare
                SendKeys.SendWait("%t");
                SendKeys.SendWait("c");
                //Send the paths
                SendKeys.SendWait(convertFilePath(args[0]));
                SendKeys.SendWait("{TAB}{TAB}{TAB}");
                SendKeys.SendWait(convertFilePath(args[1]));
                SendKeys.SendWait("{ENTER}");
                //Wait for window and say OK
                System.Threading.Thread.Sleep(500);
                SendKeys.SendWait("{ENTER}");
                //Scroll down to first ladder file and open it
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}{DOWN}");
                SendKeys.SendWait("{ENTER}");
                //enter the passcode
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("passcodehere{ENTER}");
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("passcodehere{ENTER}");
                //Arrange the windows to default project
                System.Threading.Thread.Sleep(100);
                SendKeys.SendWait("%w");
                SendKeys.SendWait("a");
                SendKeys.SendWait("{ENTER}");

                Application.Exit();
            }
        }
        private static string convertFilePath(string path)
        {
            //Convert file path for VMware image from C:\ to Z:\C\
            StringBuilder newPathSourceProject = new StringBuilder(path);
            newPathSourceProject.Replace("C:\\", "Z:\\C\\");

            return newPathSourceProject.ToString();
 
        }

    }
}
I hope someone can use this in the future because I sure was frustrated looking for the easy way with a command line switch. If you don't have a VM you can use the launcher program directly as your git difftool or maybe an AutoHotKey script to do the same thing.

Last edited by bjh; January 11th, 2018 at 04:17 PM.
  Reply With Quote
Reply
Jump to Live PLC Question and Answer Forum

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Topics
Thread Thread Starter Forum Replies Last Post
Logix Designer Compare Tool error message taylor1982 LIVE PLC Questions And Answers 6 January 16th, 2017 05:28 PM
Logix compare tool phuz LIVE PLC Questions And Answers 1 March 30th, 2016 08:45 AM
Compare in STL S7 Combo LIVE PLC Questions And Answers 2 January 10th, 2008 06:26 AM
RSLogix500 and RSLogix500 Profession, differences ? GTX LIVE PLC Questions And Answers 6 November 17th, 2005 10:59 AM
rslogix500 w/sp2 jimpad LIVE PLC Questions And Answers 7 December 19th, 2004 07:48 PM


All times are GMT -5. The time now is 06:34 PM.


.