Kepware Server and Advanced Simulation from CSV files

Off late, I have been working with Industrial IoT projects with Kepware Server, Azure IoT Edge and IoT Hub. During one of those, there was an ask to use an excel file with hand crafted data to be used as input data source at the edge. While investigating options including writing custom module at the edge to read the excel and send row by row, I realized that Kepware Server can be used along with Advanced Simulator. Being a noob on Kepware this was quite a surprise.

As I started configuring this, it took sometime to get this up and running and definitely a few steps and caveats along the way. So I thought why not give the screenshots and walk you through the steps and configuration needed.

Before I got ahead thanks to my friend Akhila (akhilahebbar@outlook.com) for troubleshooting and figuring out some of these specific roadblocks which a noob like me was trying to figure out from manuals.

Let’s us go ahead and deep dive into the Kepserver Ex and learn the specifics of using Advanced Simulator driver.

Simulator Setup

Let us create a new channel and set the type of the channel to be Advanced Simulator

Provide a useful/meaningful name to the channel and proceed.

Since we won’t be changing much of the default settings for this demo, let us leave the next pages as is and proceed.

Let us add the data source.. this is where csv is used. Click on the “Configure DSN” and Hit the Add Button on the right of the pop up window.

We need to select the driver for data source. We have an xls file with multiple columns. We converted that into a csv file, so we could use a Microsoft Text Driver (*.txt,*.csv).

Give a meaningful name to the data source and after that select the directory where you have stored your converted csv files, with columns having your simulated data. Ensure that your headings are meaningful as that become your tag values. Also, make sure it doesn’t have space between the text or leading spaces. That will make the tag reading erroneous.Use “Define Format” feature to select the columns and guess the tag rows. That will help you know if the file is being read correctly. If there are changes to delimiters and stuff we can give all those customizations here. We had a standard csv.

Click on Ok and we are done with the Data Source Name creation with the files specified in the folder.

Select the data source that just got created under the “Add Channel Wizard” and click Next.

Click “Finish” to complete adding the Channel.

We need to add device that can now read the files from the data source. Right Click on the Channel that got created previously and click on “New Device” to get started.

Setting up a device

Choose a meaningful name for the device and leave the next window as default in the wizard.

Setting the “Initial Updates from Cache” to “Enabled” helped us create those tag values automatically. Leave the Next wizard as default until choosing TableClick on the three dots and select the soecific csv for this device from the data source mapped earlier while setting up channel.

Specify the file read rate in the record selection interval. Please note that the time is milliseconds. Enable looping so that you get continuous stream of data once the cycle gets over. Please note that you need to repeat these steps for all the devices and its CSVs. but those devices timestamps may not be synchronized necessarily. it starts counting whenever it is setup and running.Click Finish and the device is successfully added, the driver should be able to “Generate” the TAG names from the column names. In case, the logs indicate an error as below, you may want to change OPC configuration settings to resolve it.

Ensure the user has administrator access on the Kepware so that he can access the kepware administration application as shown below. [It is accessible over the tray icon at the right bottom of the windows ]. Click on the “Settings” and Find and Navigate to the “Runtime Process” Tab. Change the selected mode to “Interactive”

Apply the settings and “Re-initialize” / Stop and Start the Kepware server instance.

The Tags should now be auto generated, and the simulator should be able to read the data from the files successfully.

This can now be pushed to either to the IoT Hub or Edge device to process it further!

Happy Simulations.. 🙂

The right pitch!

Having won a few high stake competitions in my company and elsewhere, I was planning to do an article on how I created most of those 10-15 mins pitches, with a ‘believable’ story telling to convey my ideas.

But before I could pen my thoughts, Scott Dadich, Editor in Chief of Wired, articulated it better than what I could have. He wrote in his editorial of Jun 2015, how he chose the cover story on Artificial Intelligence from a number of other pitches.

To rephrase what he said in 7 points regarding selling of an incredible idea in a time when ideas are plenty and execution debatable.

  1. Firstly, imagine you are writing a one page pitch, under 500 words, for your cover story to an editor in chief. You are selling your story and he has that tough task of selecting the best one among a deluge of good material from people like you. Now, how would you go about it?
  2. Establish quickly why you are a Subject Matter Expert and why you know your story well inside out.
  3. What is unique in the story as compared to similar ones read or heard earlier – USP!
  4. Is this the future? Case in point where we are seeing some adoption points.
  5. Like a short story – A conflict between the current popular narrative and thought process and the story in hand – This is where the idea has to be elaborated and told how it works out.
  6. If this clicks, what is the impact that we are looking at.
  7. Applies only if you are selling your idea to someone else for a spot in the final story telling – How will you present it and what more could be in store – time and condition permits?

Now the above points have been made extremely (field) agnostic, from a technology parlance, so that it can be applied to a cover story you are writing, a technology business pitch you are selling to an audience judging you (something like shark tank 😉 ) or you are part of the deal team selling a multi year outsourcing project to a company with many competitors in the bidding process.

Ultimately, in my opinion, story telling is vital to every single individual irrespective of the field of practice we are in.

Would love to hear whether this helps you out to make your next brilliant pitch!

 

~ Trilok R. ~

 

IoT Data Ingestion strategies (quickly pressed..)

Having worked on data ingestion part of IoT for 6 months with IoThub, what I have understood is that a few strategies should be applied while during data ingress to ensure smooth and meaningful data ingress.

  • Understanding the frequency of data ingress

If you look at the tiers given by Azure itself for data ingress Total Messages per day and each message packet size determine the one you choose among the 4 available. The more the messages, the more difficult it is to stuff everything into a database and then parse to make it meaningful. The ideal solution is to remove certain data which are off the chart or send it specific repositories. For example, if you want to remove data from event 1 processed and moved to datastore 1 and data from event 2 moved into datastore 2 at the outset itself.

  • Annotation metadata to data

Now that your IoT Device has collected billions of data and that you have stored it in some format, to build a relationship and history, would you search through the entire tables and build that hierarchy. I guess, you are better off adding metadata on the run

  • Stream Analytics is a must

If you want to raise an alarm when there is a temperature spike or fall, or if you want to start another process when the process 1 is continuously failing / not sending data, we would want a Stream analytics solution whomsoever provides in your ecosystem, be it Azure, Amazon, Google, IBM and the like. No one wants to build analytics and wait 10 mins for the instant alerts.

 

(Article in KDNuggets helped me verify that my understanding is in tune with what the industry and academia in general thinks about data ingress in general.)

HTTP Status Code confusions..

Recently, we were working with Microsoft BOT connector and a few other libraries on Microsoft Stack.

We were continuously getting 403 Forbidden returned from server.

Of the course, the naive person that I am, googled what all it could mean. Since, I had already given the right keys and access and it matched all the other code samples available on the internet for accessing the said image content from an URL from Slack, FB and skype, I had to check all the headers and the whether I have used the right ones.

After numerous hits and trials, we stumbled on a solution which told us, that Skype needed login and details, FB messenger and Slack needed Accept Header telling the Content Type for the respective Bot platforms to send image back.

More about this issue and how to handle in the next post on Bot messenger and sending images to your chat bot.

Going back to our case here, I was wondering why was it that all three messenger platforms were giving me confusing responses which had nothing to do with the issue causing it. After a few searches I ended up this blog piece – Choosing a HTTP Status Code.

It is extremely important that servers send the right error code and we act according to the expected error code.

In our case had we got either 406 or 415, we would have found out the issue much earlier!

 

The website gives the following reasons to use the right elaborated status codes.

  1. Clients already handle (or could easily be extended to handle) different codes with special behavior:

    • 301 Moved Permanently vs 302 Found has SEO implications with Google and others
    • 301 Moved Permanently is implicitly cacheable, while 429 Too Many Requests is implicitly not-cacheable, and so on
    • A client library could handle 429 Too Many Requests by backing off and retrying the request after a delay
    • A client library could handle 503 Service Unavilable similarly
  2. Even though not exhaustive for modern requirements, many status codes represent cases still worth handling with a special response (so why not use the standard code?)

    • APIs that return 404 in place of 405 Method Not Allowed drive me crazy wondering, “did I just fat-finger the URL or am I sending the wrong HTTP method?”
    • I can tell you we would have saved hours upon hours of debugging time if only we had distinguished 502 Bad Gateway (an upstream problem) instead of confusing it with 500 Internal Server Error
  3. Believe it or not, a convention is being established among widely used APIs to return status codes like 201 Created, 429 Too Many Requests, and 503 Service Unavilable. If you follow that convention, users will find it that much easier to use your website/API and troubleshoot any issues they may run into.

XHackers Meetup | Xamarin Evolve 2014 Recap

Saturday the 8th of November, 2014.

Hamilton Hall in Microsoft Signature building was half occupied by the time Kirti and I walked in to the room. Nish was already there and setting things up. We understand Bangalore, rains, traffic and the general laziness in the general scheme of things. We quickly started off with a round of introduction. By then the rest of the folks came in including the late XHackers core team 😉

With the introduction behind us we realised that we had people from varying levels of Xamarin understanding.

  • Amateurs & Rookies : Professionals from mobile and desktop application & students
  • Semi-pro : Mainly professional who have tried out Xamarin and are aware of the basic building blocks
  • Pro – Developers from industry who had already mastered Xamarin were here only for the recent announcements and demos.

IMG_1222IMG_1150

Therefore, we attempted to have content to the likes of each group in the audience. Nish started off with the basics and a proverbial hello world of Xamarin to get the audience to the same level and let them know what all the excitement was all about.

Next act was mine.

I gave them an insight into the story behind XHackers, the journey so far. We breezed through all the the meetups so far and its agenda right from our first one @HSR Layout, Bangalore. Detailed them about the expanding chapters of XHackers. Last but not the least introduced the current core members of XHackers. You can find the presentation here. One person stopped me to detail about XHackers name and logo’s design philosophy. I would like to take this opportunity to thank a friend of XHackers – Reeko Johny for this amazing support to create this exciting and fresh logo. It has design philosophy from three major ecosystems Apple, Google and Microsoft in fonts, colours and overall design. X stands for both cross-platform and Xamarin. Hackers are those bunch of people who go one step beyond their normal routine coding tasks to explore the new realms of software development! Find the presentation here.

With that Nish continued with his presentation on Xamarin and announcements.

IMG_1174

He spoke about Xamarin capabilities and code share ability. He spoke about Xamarin Forms, Xamarin Android Player, Sketches, Profiler, Insights, following it up with demonstration of these new features. He also spoke about the partnerships and components availability that Nat spoke about during Evolve. You can find the presentation here.

IMG_1256

Vidyasagar upped the ante with an exciting sneak peek into gaming with CocosSharp. He showed us folks how easy is to do start doing some basic game programming and answered to the cheeky questions from audience. His perspective and blog on the same could be found here.

IMG_1285        Lohith followed that up with a session on Telerik and their amazing Xamarin Forms controls for new wave of cross-platform applications. He showed some interesting demonstrations of the many controls that they have custom-made for Xamarin Forms. This session was especially handy for the folks from enterprise who were there for this session. They had specific questions on how it could be leveraged for their existing applications and Lohith answered to them happily. More information can be found here.

Chaitra coming fresh from her TechEd talk on connected devices, continued with the same passion to talk about the future of connected devices and how Xamarin would help us write for the world of connected devices with applications for multiple devices at the same, including the amazing Android based Moto 360. Nish was wearing that watch with the service running in fact. 🙂 She also spoke about code shareability and other details based on her enterprise experience working with advanced enterprise Xamarin applications and application scenarios.

IMG_1337

Anubhav and I closed the session with some Q & A and goodie fest. T-Shirts and monkeys were given to the avid tweeter in the audience (Prabhu Jackson) and a few other folks with insightful questions. We shared the documentation about Xamarin and ways to order Xamarin T-Shirts.

On closure, we also launched a CONTEST. The best blog about the event will stand a chance to win a Xamarin Forms book!!! Write a blog, publicise and let us know about it. Come back for the next event and if we find that yours is the best, the book is yours for keeps.

If there is one thing we all agreed at the end of the session, it is simple. It is an exciting time to be working with Xamarin and making applications. So enjoy the ride!

I sincerely, hope this blog inspires you folks to write about the event and win the amazing gift.

Special thanks to Core members:

IMG_1240IMG_1220IMG_1290

Nish, Prasant, Mayur, Anubhav, Kirti, Chaitra, Pooran, Murugan, Vic, Lohith, Vidyasagar for making this event successful.

and of course, our friends @Microsoft.

Signing off for now..

~Trilok~

Upcoming Event Alert: Xamarin Evolve 2014 Updates Meetup

"Evolve"d Monkey
“Evolve”d Monkey

Folks,

Hope you all have been feverishly coding using Xamarin. We love Xamarin for the freedom and flexibility of using C# to develop our applications on both iOS and Android in addition to Microsoft platform. To say the least, the journey so far has been exciting. we developed in each platform separately sharing same core and writing native UI. Then we used various plugins to explore MVVM patterns like MVVMCross on top of Xamarin. Then came Xamarin Forms of course which made life all the more easy and straight forward.

It gets all the more interesting and fast paced here on especially with the latest announcements made at Xamarin Evolve 2014.

Wait?  What – You missed it?!!?

OK. Chill…

Don’t worry! This weekend, on Saturday, the 8th of November, 2014 we are doing a recap and a hands on introduction to the new features announced at Evolve this year. To give you a heads up, Evolve announced many new things.

Of course, Xamarin IDE updates, Xamarin running on smart watches, Xamarin on latest iOS, Profilers and sketches, Xamarin Android player, Xamarin Test Cloud, Xamarin Insights, Xamarin.Robotics in Beta and what not.

Too much information? Interesting?

Wait till you see them in action 🙂

This Saturday, hear about all these exciting features from Xamarin Evangelists and Xamarin Enthusiasts – XHackers at Microsoft campus.

Click here to show your interest and register for this meetup. Of course, limited goodies are there for in event participation and contests 😉

See you there.

Trilok…