IoT & Connectivity Tips | ThingWorx & Kepware PTC
Recently active
This project is a simple custom tab that allows you to search all models and see their assets with basic information. It is packaged as an Axeda SDK v2 Artisan project.Further ReadingDeveloping with Axeda Artisan (Axeda Platform v6.8 and later)Axeda Sample Application: Populating A Web Page with Data ItemsExtending the Axeda Platform UI - Custom Tabs and Modules
Requirements: Axeda 6.1.6+The Axeda Applications User Interface can be extended to accommodate varying degrees of customization. This ability to customize the base product enables repurposing the Axeda Applications User Interface to serve a specific audience.What this tutorial coversThis tutorial discusses three ways to extend the Axeda Applications User Interface, which can be achieved via the following features:Customizing the Look and Feel - Use your own custom stylesheet to replace the default page styles, even on a per-user basisExtended UI Modules - Insert your own Extended UI Module into the Service > Asset DashboardCustom Tab - Create a custom tab that loads content from a custom M2M applicationCustomizing the Look and Feel of the Axeda Applications User InterfaceYou can add style changes into a user.css file which you then upload like any other custom application, via the Administration > Extensions tab as a zip archive. Make sure to adhere to the expec
Scripto Editor is an enhanced Groovy Script Editor that allows the developer to compile and test uploaded Groovy Scripts on the fly. Please note that Scripto Editor is not a replacement for an IDE and should be used mainly for debugging Groovy Scripts.Installation:Download the Javascript Scripto Editor archive attached to this post.Install the archive as a custom app- Log into the Axeda Platform- Navigate to Administration > More Links -> Extended Applications- Click Browse and select the file downloaded in step 1.- Set the URL as "ScriptoEditor"- Set the Default Index as ScriptoEditor.html- Set Dsplay Mode as Standalone- Optionally enter a Description, such as Scripto Editor for Groovy Objects- Click UploadOpen Scripto Editor by navigating to https://yourServicelink.axeda.com/apps/ScriptoEditor/ScriptoEditor.htmlLog in using your Axeda Platform credentialsDouble click any previously uploaded Groovy Script in the list to openAdd or edit parameters in the Properties sideb
This code snippet finds an uploaded file associated with an asset and emails it to a destination email address. It uses a data accumulator to create a temporary file.import org.apache.commons.codec.binary.Base64;import java.util.Date;import java.util.Properties;import java.io.StringWriterimport java.io.PrintWriterimport com.axeda.drm.sdk.Contextimport com.axeda.drm.sdk.data.*import com.axeda.drm.sdk.device.*import groovy.json.JsonSlurperimport javax.activation.DataHandler;import javax.activation.FileDataSource;import org.apache.axiom.attachments.ByteArrayDataSource;import com.axeda.platform.sdk.v1.services.ServiceFactory;import com.thoughtworks.xstream.XStream;import javax.mail.Authenticator;import javax.mail.Message;import javax.mail.MessagingException;import javax.mail.Multipart;import javax.mail.PasswordAuthentication;import javax.mail.Session;import javax.mail.Transport;import javax.mail.internet.AddressException;import javax.mail.internet.InternetAddress;import javax.mail.in
This code snippet creates then deletes a data item to illustrate CRUD technique.Parameter: model_numberimport com.axeda.drm.sdk.Contextimport com.axeda.drm.sdk.device.ModelFinderimport com.axeda.drm.sdk.device.Modelimport com.axeda.drm.sdk.device.DeviceFinderimport com.axeda.drm.sdk.data.CurrentDataFinderimport com.axeda.drm.sdk.device.Deviceimport com.axeda.drm.sdk.data.HistoricalDataFinderimport groovy.xml.MarkupBuilderimport com.axeda.drm.sdk.device.DataItemimport com.axeda.drm.services.device.DataItemType/** DeleteDataItem.groovy** Delete a data item.** @param model_number - (REQ):Str name of the model.** @author Sara Streeter <sstreeter@axeda.com>*/def response = [:]def writer = new StringWriter()def xml = new MarkupBuilder(writer)try {// getUserContext is supported as of release 6.1.5 and higher final def CONTEXT = Context.getUserContext()// find the model def modelFinder = new M
The past few years has seen a tremendous explosion in the numbers of devices with Internet connectivity, and the Axeda product has continued to evolve to meet the requirements of these devices, which are often memory and CPU constrained. Beginning with the Axeda Platform 6.6 release, the Axeda Adaptive Machine Messaging Protocol (AMMP) has been available that allows any device that can make an HTTP GET/POST request to send data to the Axeda Machine Cloud. AMMP uses standard, JSON messages sent inside HTTP requests.How to get AMMPAMMP is a separately available product that can be added to an Axeda installation. Customers should discuss with their Account Managers to get access to the Axeda AMMP product offering. AMMP is a device codec that requires the installation of the Axeda AnyDevice Codec Server (ACS) component. This configuration presents a new endpoint for customer installations - an https://example.axeda.com instance will have an ACS instance availa
The following script takes a parameter of a model name, a device serial number and a data item name, finds the asset location and uses that longitude to determine the current TimeZone. It then converts the Timezone of the data item timestamp to an Eastern Standard Timezone timestamp.import groovy.xml.MarkupBuilderimport com.axeda.drm.sdk.Contextimport java.util.TimeZoneimport com.axeda.drm.sdk.data.*import com.axeda.drm.sdk.device.*import com.axeda.common.sdk.jdbc.*;import net.sf.json.JSONObjectimport net.sf.json.JSONArrayimport com.axeda.drm.sdk.mobilelocation.MobileLocationFinderimport com.axeda.drm.sdk.mobilelocation.MobileLocationimport com.axeda.drm.sdk.mobilelocation.CurrentMobileLocationFinderdef responsetry { Context ctx = Context.getUserContext() ModelFinder mfinder = new ModelFinder(ctx) mfinder.setName(parameters.model_name) Model m = mfinder.find() DeviceFinder dfinder = new Devi
This script illustrates how to call a Groovy script as an external web service. This example also applies to calling any external web service that relies on a username and password.Parameters:external_usernameexternal_passwordscript_nameimport com.axeda.drm.sdk.Contextimport com.axeda.drm.sdk.device.DeviceFinderimport com.axeda.drm.sdk.data.CurrentDataFinderimport com.axeda.drm.sdk.device.Deviceimport com.axeda.drm.sdk.data.HistoricalDataFinderimport com.axeda.drm.sdk.device.DataItemimport net.sf.json.JSONObjectimport com.axeda.drm.sdk.device.ModelFinderimport groovyx.net.http.*import static groovyx.net.http.ContentType.*import static groovyx.net.http.Method.*/*** CallScriptoAsExternalWebService.groovy** This script illustrates how to call a Groovy script as an external web service.** @param external_username - (REQ):Str Username for the external web service.* @param external_password -  
Calling external services from M2M applications is a critical aspect of building end-to-end solutions. Knowing how to apply network timeouts when connecting to external servers can prevent unexpected and problematic network hang-ups. Let's investigate how to create a safe networking flow using HttpClient, HttpBuilder, and Apache’s FTPClient class.BackgroundCustom Objects called from Expression Rules have a configurable maximum execution time. This is set by the com.axeda.drm.rules.statistics.rule-time-threshold property. Without this safeguard in place long running or misbehaved Custom Objects can cause internal processing queues to fill and the server will suffer a performance degradation.In Java (and Groovy) all network calls internally use InputStream.read() to establish the socket connection and to read data from the socket. It is possible for faulty external servers (such as an FTP server) to hang and not properly respond. This means that the InputStr
This script creates a csv file from the audit log filtered by the User Access category, so dates of when users logged in or logged out.*** see update below *** Note: The csv file has the same name as the Groovy script and does NOT have the .csv extension . To get the .csv extension, the Groovy script has to be renamed to AuditEntryToCSV.csv.groovy . Suggestions on how to improve this are welcome.*** Update ***: The download works without the renamed groovy script by returning text instead of an input stream. The script has been modified to illustrate this.Parameters:days - the number of days past to fetch audit logsmodel_name - the model name of the assetserial_number - the serial number of the assetimport com.axeda.drm.sdk.device.ModelFinderimport com.axeda.drm.sdk.Contextimport com.axeda.common.sdk.id.Identifierimport com.axeda.drm.sdk.device.Modelimport com.axeda.drm.sdk.device.DeviceFinderimport com.axeda.drm.sdk.device.Deviceimport com.axeda.drm.sdk.audit.AuditCa
This script finds all the data items both current and historical on all the assets of a model and outputs them as XML.Parameters:model_namefrom_timeto_timeimport com.axeda.drm.sdk.Contextimport com.axeda.drm.sdk.device.ModelFinderimport com.axeda.drm.sdk.device.Modelimport com.axeda.drm.sdk.device.DeviceFinderimport com.axeda.drm.sdk.data.CurrentDataFinderimport com.axeda.drm.sdk.device.Deviceimport com.axeda.drm.sdk.data.HistoricalDataFinderimport groovy.xml.MarkupBuilder/** AllDataItems2XML.groovy** Find all the historical and current data items for all assets in a given model.** @param model_name - (REQ):Str name of the model.* @param from_time - (REQ):Long millisecond timestamp to begin query from.* @param to_time - (REQ):Long millisecond timestamp to end query at.** @note from_time and to_time shou
This is an example of an advanced apc-metadata.xml file for use with Axeda Artisan that includes examples of how to create different data structures on the platform, including Expression Rules and System Timers.Step 1 - In the upload.xml make sure the artisan-installer is 1.2 <dependencies> <dependency> <groupId>com.axeda.community</groupId> <artifactId>artisan-installer</artifactId> <version>1.2</version> </dependency> </dependencies>Step 2 -<?xml version="1.0" encoding="UTF-8"?><!-- apc-metadata.xml--><apcmetadata> <models>
Shown below is example code that when deployed in the appropriate container, will allow an end-user to talk to the Axeda Platform Integration Queue.A customer should supply their unique values for the following properties:queueNameuserpasswordurlimport java.util.Properties;import javax.jms.*;import javax.naming.*;public class SampleConsumer { private String queueName = "com.axeda.integration.ACME.queue"; private String user = "system"; private String password = "manager";//private String url = "ssl://hostname:61616"; private String url = "tcp://hostname:61616"; private boolean transacted; private boolean isRunning = false; public static void main(String[] args) throws NamingException, JMSException { SampleConsumer consumer = new SampleConsumer(); consumer.run();
Since the advent of 6.1.6 we've been able to access the body of a post in a Groovy script. This frees us from the tyranny of those pesky predefined parameters and opens up all sorts of Javascript object-passing possibilities.To keep this example as simple as possible, there are only two files:postbody.htmlTestPostBody.groovypostbody.html<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head> <title>Scripto Post Body Demo</title> <meta http-equiv="content-type" content="text/html; charset=utf-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"/> <meta name="apple-mobile-web-app-capable" content="yes"/> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1
The Axeda Platform provides a few mechanisms for putting user-defined pages or UI modules into the dashboards, or allowing end-users to host AJAX based applications from the same instance their data is retrieved from. This simple application illustrates the use of jQuery to call Scripto and return a JSON formatted array of current data for an Axeda asset.Prerequisites:First steps taken with Axeda ArtisanBasic understanding of HTML, JavaScript and jQueryAxeda Platform v6.5 or greater (Axeda Customers and Partners)Artisan project attached to this article Features:Authentication from a Web appUse of CurrentDataFinder APIScripto from jQueryFiles of Note (Locations are from the root of Artisan project)index.html – main HTML index page..\artisan-starter-html\src\main\webapp\index.htmlapp.js – JavaScript code to build application and call Scripto..\artisan-starter-html\src\main\webapp\scripts\app.jsaxeda.js – axeda web services JavaScript code..\artisan-starter-html\src\main\webapp\scr
One of the killer features of the Axeda Platform is the Axeda Console, a browser-based online portal where developers and business users alike can browse information in an out-of-the-box graphical user interface. The Axeda Console is functional, re-brandable and extensible, and can easily form the foundation for a customized connected product experience.Let's take a tour of the Axeda Console and explore what it means to have a full-featured connected app right at the start of your development.What this tutorial coversThis tutorial discusses the landscape of the online browser-based suite of tools accessible to Axeda customers. It does not do a deep dive into each of the available applications, but rather serves as an introduction to the user interface.Sections of the Axeda Applications Console that are discussed:Landing Page (Home)User PreferencesAsset DashboardAxeda HelpNote: This article features screenshots from Axeda 6.5 which is the current release as of July 1, 2013.&
For those of you that aren't aware - the newest version of the Eclipse Plugin for Extension Development was made available last week in the ThingWorx Marketplace here.Because of the infancy of the product, there is not an official process for supplying release notes along with the plugin. These are not official or all encompassing, but cover the main items worked on for 7.0. New Features:Added Configuration Table Wizard for code generationSDK Javadocs now automatically linked to SDK resources on project creationWhen creating a Service, Trace logging statements are generated inside of it (along with appropriate initializers)ThingWorx Source actions are now available from right click menu within a .java fileBugs:Fixed problem where some BaseTypes are not uppercase in annotations when generating codeFixed error when Creating and importing Extension Projects when the Eclipse install has a space in the file pathFixed inconsistent formatting in the metadata.xml when adding new Entities
The Axeda Platform has long had the ability to write custom logic to retrieve, manipulate and create data. In the current versions of the Platform, there are two classes of API, Version 1 (v1) and Version 2 (v2). The v1 APIs allow a developer to work with data on the Platform, but all of the APIs are subject to the maxQueryResults configuration property, which by default limits the number of results per query to 1000. For some subsets of data, this can be inadequate to process data. In comes the v2 API, which introduces pagination.One of the first things a new user does when exploring the V2 API, is something like the following: HistoricalDataItemValueCriteria criteria = new HistoricalDataItemValueCriteria()criteria.assetId = '9701'criteria.startDate = '2014-07-23T12:33:00Z'criteria.endDate = '2014-07-23T12:44:00Z'DataItemBridge dbridge = com.axeda.sdk.v2.dsl.Bridges.dataItemBridgeFindDataItemValueResult results = dbridge.findHistoricalValues(criteria) &nbs
Remote TimeoutsSome Notes:FormatUnits: unit of measure for the timeout or limit (seconds, milliseconds, cycles, etc.)Description: describes the timeoutsOutcome: describes the default behavior if a timeout or limit is reached.Related Timeouts: lists other timeouts that are closely related to the timeout in question, meaning they should be configured together because one timeout will affect another timeoutNotesThis guide is heavily focused on the C SDK; certain timeouts may have different names in other SDK's or agentsThere are no descriptions of any imposed delays or timeouts related to thread pools on the ThingWorx PlatformLocal timeouts (not related to remote requests) were intentionally not addedThere are far too many applications to provide detail about every situation introduced by every timeout, but this should provide a good starting point for custom timeout configurationEdgesocket_read_timeoutUnits: millisecondsDescription: used to free the socket mutex allowing another service
This is a slide deck I created while learning how to post data from an Arduino to ThingWorx using MQTT protocol.
The ThingWorx EMS and SDK based applications follow a three step process when connecting to the Platform:Establish the physical websocket: The client opens a websocket to the Platform using the host and port that it has been configured to use. The websocket URL exposed at the Platform is /Thingworx/WS. TLS will be negotiated at this time as well.Authenticate: The client sends a AUTH message to the platform, containing either an App Key (recommended) or username/password. The AUTH message is part of the Thingworx AlwaysOn protocol. If the client attempts to send any other message before the AUTH, the server will disconnect it. The server will also disconnect the client if it does not receive an AUTH message within 15 seconds. This time is configurable in the WSCommunicationSubsystem Configuration tab and is named "Amount of time to wait for authentication message (secs)."Once authenticated the SDK/EMS is able to interact with the Platform
This Zip file contains the Axeda patch (axeda-jms-plugin-<version>-machine-streams) required for proper installation and configuration of an Apache ActiveMQ server to use with the Axeda Machine Streams service (which is supported for Axeda Platform v6.8 and later).Note: Information about the Axeda Machine Streams feature is provided in the Axeda Features Guide available from the Axeda Support site, http://help.axeda.com.This patch overlay needs to be applied to the v5.8.0 ActiveMQ server installed as the Axeda Machine Streams endpoint broker, so that Axeda Platform can send streamed content to that server endpoint.Complete instructions for installing and configuring an Apache ActiveMQ server for Axeda Machine Streams are provided in the reference, Axeda® Machine Streams: A Guide to Setting Up Broker Endpoints. This guide is available with all Axeda product documentation from the PTC Support site.
HiI have attached a Postman collection, this can be used as a template and be modified.steps to upload the collection to Postman.1. In your Postman window click at Import.2. Once you clicked import, you can chose your file.3. The collection is now visible in your left side of the window.
JavaMelody is an open source (LGPL) application that measures and calculates statistical information based on application usage. The resulting data can be viewed in a variety of formats including evolution charts, which track various operations and server attributes over time. There are also robust reporting options that allow data to be exported in either HTML of PDF formats.InstallationInstallation is fairly simple and can be done in just a few minutes. Download the distribution from JavaMelody Wiki and extract the javamelody.jar, available at https://github.com/javamelody/javamelody/releasesStep 1: Download the java melody file (in unix, use the following command*):wget javamelody.googlecode.com/files/javamelody-1.49.0.zipNote: Ensure the latest version available at the link provided above before executing the unix command, modify the version accordingly.Step 2: Extract the zip file (using the following command in unix, note the version from step 1);unzip javamelody-1.49.0.zipStep 3
A student in the Axeda Groovy course had some good questions. Instead of answering via email, I thought I'd answer here, so we could share the knowledge.Domain Objects - How can I customize or extend Axeda provided domain objects? (Eg., I need to store whether a user is external or internal user) How can I achieve this?This is a perfect use case for the Axeda Extended Data API. Documentation on the API can be found in the Axeda Platform v1 API Developer's Reference Guide. A good, "Getting Started," topic is available on Axeda Mentor - Getting Started With the Axeda Extended Data API.To customize/extend/decorate Axeda-provided domain objects, use Extended Objects. Extended Objects can be thought of in the abstract as a collection of custom database table rows. The analogy isn't perfect, but it helps with understanding.The use case in the question is very common. Extended Objects can stand on their own, or they can be associated with an Axeda domain object with the setInternalID() method
Already have an account? Login
No account yet? Create an account
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.