A complete guide to utilize Git in your plant use AssetCentre as a "Build" tool.

PreLC

Member
Join Date
Apr 2019
Location
Mars
Posts
587
A complete guide to utilize Git in your plant use AssetCentre as a "Build" tool.

Hello PLCs.net!

I have found my older tutorial to be really helpful to people across the automation field.

That tutorial dealt with integrating the LogixCompareTool with git, and using it as a Difftool.

Since then, I have also been able to successfully integrate AssetCentre as a part of my repo's "build tool" AKA disaster recovery for my plant infrastructure. Here are some of the steps I followed to get to this point:

Preface: At my particular location, my repository contains about 95 PLCs which I back up every day, using AssetCentre and committing it onto Git. My git utilizes 2 branches: AutomatedBackups, and Develop.
AutomatedBackups are automatic, and Develop are user-pushed changes for things that are either not automated, or just need some work for automation(Like PLC firmware upgrade needs more file)

Tools used:
Windows(Latest possible), task scheduler enabled.
GitExtensions(Latest possible)
Network drive location to call it a "Central repository"
AssetCentre(Latest possible), any supporting software for AssetCentre, such as Studio5K v13-32 in my case. Depends on what the equipment being backed up is.
Git(Latest possible)
FactoryTalk AssetCentre Archive Extractor Utility, more info about installation in FactoryTalk AssetCentre Utilities User Manual(Rockwell Automation Publication - FTAC-UM001A-EN-E - February 2019)
CMD
ROBOCOPY: Should be included in recent windows packets.

I'll start step by step. The first step is to have a plant with prolifirated PLCs and other automation infrastructure.
This is the worst case scenario, and my tutorial is targeted towards this, but better cases would work smoothly with this approach too.
In this guide, I will have a method for backing up anything that's possible to be backed up using command line to a windows directory.
1) Start with a logical layout of the plant. Try to make it as verbose in naming as possible, so future searches by name yield good results. I use PascalCase for all nomencleature if possible.
2) Recreate this layout in a windows directory. This can be multiple levels as windows allows it, still try to keep it as brief as possible.
My directory structure(Names changed, but otherwise all use PascalCase with no underscores, sometimes hyphens for folder names):
Code:
        Assembly Line(Had documentations in top level)
            Logical division of line(Had line PLCs)
                CellA(Had Cell equipment code and related documentations)
                    Assortment of files
                CellB(Had Cell equipment code and related documentations)
                CellC(Had Cell equipment code and related documentations)
                ..
                Assortment of files
            Logical division of line(Had line PLCs)
            Logical division of line(Had line PLCs)
            ..
            Assortment of files
        ..
        Assortment of files
For more Assembly lines in my plant, I'll have a similar layout.
"Assortment of files" means that any files pertainent to that directory, for example MES information is common across the logical divisons, so I keep it in the top directory.
Also, if you have "Logical divison of line" named similar across multiple lines, I would recomment a driver name like: AssemblyLineLogicalDivisionOfLine
Another tip I found helpful in RSLinx, is that if you enter a name after the IP address, it's visible under the driver. Example: "192.168.1.1 Cell1" will show Cell1 beside the IP address.

3) Recreate this layout in RSLinx AND Factorytalk Linx. Note, since RSLinx only allows 1 layer of cascading(Driver>Devices), I utilize the "Logical division of line" names for drivers in RSLinx.
I usually have ~10 PLCs in each driver, and have a total of ~15 drivers.
I backup this using the RSLinx backup-resotre utility and also keep this in my git repository.
I also backup "Computer\HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Rockwell Software\RSLinx" and keep this too, since the restore utility recently started giving me issues backing up from Windows Server2016 to windows 10 PCs.
I Recreate this in FactoryTalk linx and add HMI IP addresses.

4)Now at this point, I create a folder in a new called CodeRepository. I then initialize this folder as a .git repository just by right clicking and "GitExt create new repository". This is just a fresh repo, so multiple ways to do this.
Once the git repo is created, edit the .gitignore file and add relevant files in it. My gitignore is at the bottom of this post.
I then copied the directory structure above into this folder. Remember, git does not track empty directories, this is a Linus philosophy I agree a 100% with. So if you don't have files for some cells/logical diviison, just create a standard nomencelature and add them as you recieve code.
Then do a Commit, and now your git has all the files you put in. Enforce a strong commenting culture within your team.

ALL repos have 2 branches, 'Develop' and 'AutomatedBackups'.

5) Create the central repository. For advanced features you can use Microsoft Azure, Gitlab, Github, gitkracken among others in the future, but to start I would suggest creating a new folder in a shared drive, I call mine CodeRepositoryBare, right clicking and "GitExt create new repository".
In the shared drive, this would be a "Central repository, no working directory. This is so that people don't end up using the central repo as their main repo.
In case you want to expose the repo on the shared drive, I would recommend creating a clone in a different folder, called CodeRepository in the shared drive.
In GitExtensions, set up the \\shareddrivepath\CodeRepositoryBare as a remote repository, by opening CodeRepository in Gitextensions, then Repository>Remote Repository. Name this remote 'FactorytalkDrive'.
Now do a push to the central repository. At this point, your central repo and your local PC have the same code in git.

6) Cloning \\shareddrivepath\CodeRepositoryBare should be easy, I would recommend everyone in the team creates a folder called CodeRepository in C: and clone it here, so future scripting is easier.
If you want to integrate assetcentre, clone a personal repository into a location also accessible on the AssetCentre server. I have done mine on the AssetCentre server's C: drive, and called it CodeRepository, to keep it standardized for scripting.

At this point, as long as your plant is equipped with humans who can work together on git without being ignorant of others, you now have git, and you have people collaborating and updating files as needed.
Till this point, things are also FREE of $$$. Now comes the more advanced functionality, creating a "Build agent", or it's closest cousin possible in the automation world.

Integrating the FactoryTalk AssetCentre:
7)Setting up the AssetCentre tree: I was starting from scratch, and ended up creating a windows based git repo before and then integrating with AssetCentre.
This really helped me as I was able to use the same windows structure in assetcenter and git, at least as similar as possible.
If you already have AssetCentre, I would suggest use the folder structure from AssetCentre and use that in step two.
You should also consider changing and standardizing the RSLinx heirarcy on your Assetcentre to be the same as your personal PCs, following the same heirarcy.

Instead of folders create a "Generic folder" in the design tree. Create the entire heirarcy with empty generic folders(Linus would roll in his grave if he was dead), so that would be
Assembly Line(generic)>Logical division of line(generic)
In the Logical division of line generic folder, create a simple folder.
When it prompts you to select a windows folder, select C:\CodeRepository\Logical division of line, based on the name of the generic folder you are nesting it under.
Check "Add all the contents as well". Add descriptions.
Now to configure AssetCentre, just create your plant devices(HMI/PLC etc) in the generic Logical divison of line folder.
In the properties link it to the file we just added in the tree.
Also link the address to the well defined heirarcy in RSLinx.
Set up automatic backups in AssetCentre on a desired period. For about 80-90 PLCs it takes about 2 hours to complete the backups. I have it every day at 6PM, usually done by 8:30PM.
They happen in series unless you configure agents on assetcenter, but that's a different functionality

8) FactoryTalk AssetCentre Archive Extractor Utility setup: So in order to integrate AssetCentre with Git, .bat scripting is the simplest method of integrating git bash and the Extractor utility.
This .bat script runs at 11PM every day. This takes the 6PM backup from AssetCentre and brings it into git. More of this script below.
The Extractor utility can be called via command line, but has to be configured first.
Configuration is through a gui, more information on this is in the rockwell publication cited above. The extract location needs to be unique though, and I mine is C:\AssetCentreDailyExtract\

9) Once you are at this point, if you have a successful Assetcentre disaster recovery, try this on the Assetcentre server:

start "Update From Assetcentre To Git" "C:\Program Files (x86)\Rockwell Software\AssetCentre Client\FTAC Utility\ArchiveExtractor\RA.FTAC.ArchiveExtractor.exe" /WAIT
timeout /t 30

You should have the assetcentre contents in a folder that you specified in the Configuration. You can also play around with the timeout settings as needed.
At this point, the latest files from Assetcentre's automated recovery are now in your posession. Next steps are to commit this into git.

Rest of the post is the first reply, character limit in posts on PLCS.net. smh.
 
Last edited:
Part 2 of the post.

10) Transferring files into Git directory on the AssetCentre server:
Now I needed to get these latest "Built" files from C:\AssetCentreDailyExtract to my Git repository. Try and make this work in CMD:

robocopy "C:\AssetCentreDailyExtract\AssetCentre\Plant\AssemblyLine\LogicalDivisonOfLine\LogicalDivisonOfLine" "C:\AssemblyLine\LogicalDivisonOfLine" /s

Once you are at this point, try getting git commands to execute:

cd "C:\CodeRepository"
git add .
git commit -a --author="F. Talk<[email protected]>" --message="These files have been automatically backed up, Thanks to AssetCentre!"
git push FactoryTalkRepository AutomatedBackups

11) Once you have validated the commands manually, put them on a scheduler. I have a bat script that I have, it goes deep in multiple levels, but I have made a gimped version of it in this post below.
It's triggerred at 11PM for me.
Action for that script is: Start a program> CMD with arguments:

/c "C:\CodeRepository\CommonScripts\FactorytalkServer\UpdateFromAssetcentreToGit.bat" >> C:\TaskSchedulerLogs\TaskLog.txt

My script is also kept inside the repository. Also, C:\TaskSchedulerLogs\TaskLog.txt collects logs for steps in case of failure.
Usually I end up checking what the latest committed code in the local and remote repos are, and then manually typing parts of the script to do a step-by-step troubleshooting. It's fairly easy.

Developed and Been using this system for about 10 months, by far the easiest system I've ever used. Also, easily mantainiable with minor pain. As long as the ecosystem has a common nomencelature, it works well.

Regards,
-PreLC



_____________________________________________________________________________________________________________________
Gitextensions file:

Code:
#Ignore thumbnails created by Windows
Thumbs.db
#Ignore files built by Visual Studio
*.obj
*.pdb
*.user
*.aps
*.pch
*.vspscc
*_i.c
*_p.c
*.ncb
*.suo
*.tlb
*.tlh
*.bak
*.cache
*.ilk
*.log
[Bb]in
[Dd]ebug*/
*.lib
*.sbr
obj/
[Rr]elease*/
_ReSharper*/
[Tt]est[Rr]esult*
.vs/
#Nuget packages folder
packages/

#Ignore useless packages created by Studio/RSLogix 5000.
*.bak*acd
*_BAK*.acd
*.acd.recovery
*.sem
*.wrk

#Ignore useless packages created by RSLogix 500
*_bak*rsp
*_bak*[0-9].RSS
*.ada
*.aid
*.ctd
*.cti
*.ida
*.iid
*.rda
*.rid
*.sgd
*.sgi
*.xda
*.xid

#Ignore useless packages created by Rockwell Assetcentre
*.asc
/.ssh*


_____________________________________________________________________________________________________________________
Example of script I run on a daily basis, about 1 hour after my assetcenter backup is complete:

Code:
rem Gets files from AssetCentre own to the location: C:\AssetCentreDailyExtract
rem To change this location, please open C:\Program Files (x86)\Rockwell Software\AssetCentre Client\FTAC Utility\ArchiveExtractor\RA.FTAC.ArchiveExtractor.exe
rem with the switch '/c'. 
start "Update From Assetcentre To Git" "C:\Program Files (x86)\Rockwell Software\AssetCentre Client\FTAC Utility\ArchiveExtractor\RA.FTAC.ArchiveExtractor.exe" /WAIT

timeout /t 30

rem The following RoboCopy commands copy code from the AssetCentre extract into the code repository:

robocopy "C:\AssetCentreDailyExtract\AssetCentre\Plant\AssemblyLine\LogicalDivisonOfLine\LogicalDivisonOfLine" "C:\AssemblyLine\LogicalDivisonOfLine" /s

rem The following copies the FactorytalkLinx application heirarchy from the server into the code repository:
robocopy "C:\ProgramData\Rockwell\RSLinx Enterprise" "C:\CodeRepository\Communication" RSLinxNG.xml

rem The following RoboCopy commands can also copy configuration from line PCs into the code repository:

robocopy "\\x.x.x.x\C\...\FolderOfRelevance" "C:\CodeRepository\Code\LogicalDivisonOfLine" FileNameWithoutExtension

rem The following snipped sets the path to the local git repository on C:\
rem The default branch checked out on the tree must be: 'AutomatedBackups'
cd "C:\CodeRepository"

rem Adds all newly-created files onto Git. For example, new files inside robots. 
git add .

rem Commits the code into the local branch. 
git commit -a --author="F. Talk<[email protected]>" --message="These files have been automatically backed up, Thanks to AssetCentre!"

rem Pushes the code onto the remote repository set up for C:\Code Repository
rem E:\FactorytalkDrive\CodeRepositoryBare = \\shareddrivepath\CodeRepositoryBare shared folder. Make sure the username running this has read/write access to the repo's directory. 
git push FactoryTalkRepository AutomatedBackups

rem Made with love, by PreLC :D
 
Last edited:

Similar Topics

Good Afternoon, I’m limited with a skilled maintenance staff to design and build Load Cell , Rollers , etc. for conveyor sections . Do...
Replies
11
Views
659
Hi all I have been thinking, if you haven’t got a project for a Siemens 1500 , I’m aware that you can create a new project and pick the cpu from...
Replies
6
Views
2,227
Cant decide if this will take a 100 scans or 1 scan to complete - my thoughts are that if the internal memory in the plc is updated and available...
Replies
29
Views
8,016
Hi All, I am going to use the prosave to do a complete backup with license for the TP1200, I am wondering after I do this backup, will the TP1200...
Replies
1
Views
905
Hello all, i will start off by saying i know nothing about load cells, i want a converter/amplifier to output a 4/20mA signal from a load cell...
Replies
14
Views
5,398
Back
Top Bottom