Add Instant Messaging and Chat Functionality to Any Project

Perfect Abstractions just released PerfectChat.

PerfectChat is instant messenger and chat functionality that is very easy to use and add to any existing Ignition project that uses Ignition version 7.7.5 and up.

With it you can add instant messaging and chat functionality to projects in minutes.

Check out the blog post about it: nickmudge.info/post/perfectchat- … n-projects

Here is a video that shows it in action: youtube.com/watch?v=VwRLlDL … tu.be&hd=1

Best,

Nice Nick!

This works awesome. I always wanted to spend some time to create a chat system but I never got around to it. Thanks for saving me some work :wink:

Very impressive, I will have to sift through the code and see what you are doing.

Thanks Doug, sounds good.

The installer template for PerfectChat is pretty interesting.

Directly importing the PerfectChat project into an existing project using the Ignition designers File -> Import would not work because it would cause any existing client message handlers and client menu items to be overwritten or erased. So that is why a template with a button is used to install PerfectChat.

The pa.project.* scripting functions from the PA Power Scripting Module can be used to import projects from a script in a safe way that doesn’t overwrite or erase existing project resources.

You will notice that there is a non-visible “Get Resources” button in the PerfectChat Installation template. The script on that button is how I got the bytes and text for the message handler, windows and project script modules and stuck them into the custom properties in the root container. In this way I embedded the PerfectChat project into the PerfectChat Installation template and then provided the Install button that has a script that gets those resources and installs them in whatever project the template is added to.

The pa.project.* functions enable project functionality to be embedded in a template, disseminated through Inductive Automation’s public or private cloud template repositories, and installed via a script on a button in the template. The PerfectChat Installation template is a perfect example (that anyone can look at and copy) of this working.

Best,

Excellent, thanks for the explanation. I will have to poke around and play with it.

Just a suggestion, if you put this code in the configure cell extension function on the chat history content power table it makes the chat window a little easier to follow and looks more like a typical chat client.

data = system.dataset.toPyDataSet(self.data) if data[rowIndex][0] == "me > ": return {'foreground': 'red'} else: return {'foreground': 'blue'}

Excellent idea, we will probably change it how you mentioned. More suggestions like this are very welcome.

Hey Nick,

Another thing I was playing with is flashing the taskbar icon for the client incase it is minimized or not the focused window. Here is what I came up with:

[code]from javax import swing
windows = swing.JFrame.getWindows()

for window in windows:
if window.isVisible:
try:
if “Project Title” in window.getTitle():
if not window.isFocused():
window.toFront()
except AttributeError:
pass[/code]

If you put this in the client message handler it works.
Problems:

  1. The project title has to be hard coded, I don’t know how to get the project title with any kind of scripting function.
  2. I’m not a Java guy so swing and I don’t get along. I’m sure there is a more elegant way of doing this.

However, it is nice to get notified if there is a message waiting and the client is not right up front or even visible.

[quote=“Duffanator”]
Problems:

  1. The project title has to be hard coded, I don’t know how to get the project title with any kind of scripting function.
  2. I’m not a Java guy so swing and I don’t get along. I’m sure there is a more elegant way of doing this.

However, it is nice to get notified if there is a message waiting and the client is not right up front or even visible.[/quote]

You can pick up the project title from a system tag. Heading home, so I can’t try it yet, but try:

[code]from javax import swing
windows = swing.JFrame.getWindows()
projectName = system.tag.read("[System]Client/System/ProjectName").value

for window in windows:
if window.isVisible:
try:
if projectName in window.getTitle():
if not window.isFocused():
window.toFront()
except AttributeError:
pass[/code]

Hey Jordan,

Yeah, I looked at that. But that is the project name, not the project title. They could be different and the title of the JFrame window uses the project title, not the project name. I would think that there would be a way to get the project title somehow… after all they are using it for the JFrame window title, but it’s probably some hidden property somewhere.

Ah!

Okay, my first thought was to iterate to the top window:

win = system.gui.getParentWindow(event) parent = win while parent is not None: win = parent parent = win.getParent() projectName = win.getTitle()

In the long run. it’s not any different than what you have, the main problem being the dash separating the project title from the window title. If you have more than one dash, it gets problematic.

I was able to do it using the Power Scripting Module, since we can query the internal database:

projectName = system.tag.read('[System]Client/System/ProjectName').value query = "SELECT title FROM PROJECTS WHERE name = '"+projectName+"'" result = pa.ignition.db.runPrepInternalDBQuery(query) if result[0][0] != None: projectName = result[0][0] print projectName

Since PerfectChat is dependent on the module, it should’nt be too problematic to build it in.

I say shouldn’t be, but then, I’m not the one who has to do it! :wink:

Hey guys,

Great creations. I love it.

Just a note: PerfectChat does not use the PA Power Scripting Module. Only the installation of PerfectChat uses the Power Scripting Module.

This allows people to install and use PerfectChat without needing a license for the Power Scripting module since the installation is done in the designer and all Power Scripting functions work in the designer without a license. Jordan has a license for the Power Scripting module so it makes sense to use it :thumb_left:

Best,

Got it. Thanks for the clarification, Nick!

[quote=“nmudge”]Perfect Abstractions just released PerfectChat.

[/quote]

Nick, any chance on integrating the chat with enterprise Skype for Business (formerly Lync) platform?

I would buy that module… :wink:

1 Like

btw… this kind of reminds me of a failed initiative at our company faktory.co/

not because it failed, but because it was basically a chat/notification app

/c

is it still available?, the link in youtube says “The video is private”.