Showing results for 
Search instead for 
Did you mean: 
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Have a PTC product question you need answered fast? Chances are someone has asked it before. Learn about the community search. X

Monitor an SMT Assembly Line Part 1

100% helpful (1/1)



Build a remote monitoring application with our developer toolkit for real-time insight into a simulated SMT assembly line.


Guide Concept


This project will introduce methods to creating your IoT application with the ability to analyze real time information as the goal.

Following the steps in this guide, you will create an IoT application with the ThingWorx Java SDK that is based on the functionality of an SMT assembly line.

We will teach you how to use the ThingWorx Java SDK, ThingWorx Composer, and the ThingWorx Mashup Builder to connect and build a fully functional IoT application running numerous queues and "moving parts".


You'll learn how to


  • Use ThingWorx Composer to build an application that uses simulated data
  • Track diagnostics and performance in real-time


NOTE: The estimated time to complete this guide is 60 minutes




Step 1: Completed Example


Download the completed files for this tutorial attached here:


In this tutorial, we walk through a real-world scenario for a Raspberry Pi assembly line. The file provided to you contains a completed example of an SMT application. Utilize this file to see a finished example and return to it as a reference if you become stuck creating your own fully flushed out application.

Keep in mind, this download uses the exact names for Entities used in this tutorial. If you would like to import this example and also create Entities on your own, change the names of the Entities you create.

The download contains the following Java classes that support this scenario:


 Name                          Description
MotherboardAbstract representation of a Thing inheriting from a MotherboardTemplate
AssemblyLineAbstract representation of a Thing inheriting from a SMTAssemblyLineTemplate
AssemblyMachineAbstract representation of a Thing inheriting from a AssemblyMachineTemplate


Once you complete the Java environment setup by installing a Java JDK, import the Entities/ThingWorxEntities.xml file into ThingWorx Composer. This file contains various Data Shapes, Mashups, Value Streams, Things, and Thing Templates necessary to support the application. The more important Entities are as follows:


 Feature                                                 Entity Type          Description
RaspberryPi 1 - 6ThingThings that inherit from the motherboard template
SolderPasteAssemblyMachineThingA Thing that inherits from the assembly machine template
PickPlaceAssemblyMachineThingA Thing that inherits from the assembly machine template
ReflowSolderAssemblyMachineThingA Thing that inherits from the assembly machine template
InspectionAssemblyMachineThingA Thing that inherits from the assembly machine template
RaspberryPiSMTAssemblyLineThingA Thing that inherits from the assembly line template
MotherboardTemplateThingTemplateA template used for building motherboard devices
AssemblyMachineTemplateThingTemplateA template used to create the various types of SMT assembly machines
SMTAssemblyLineTemplateThingTemplateA template used to represent the entire assembly line and all devices in it
AdvisorUserUser created to be used with the Java SDK examples


NOTE: An Application Key is NOT included in the zip file you downloaded. You will need to create your Application Key and assign it to the Advisor user provided in the ThingWorxEntities.xml file, the Administrator (which is not recommended for production applications), or any user you've created. If you do not know how to create one or just need a refresher, visit the Create An Application Key guide, then come back to this guide.




Step 2: Run Application


The Java code provided in the download is pre-configured to run and connect to the entities in the ThingWorxEntities.xml file.

  1. Open the Executable/Script in a text editor, and edit the script with your host and port.

     Operating System   File Name
  2. Update the <HOST> and <PORT> arguments to that of your ThingWorx Composer and update the Application Key argument to the one you have created. Use the examples in the file for assistance.


    NOTE: If you are using the hosted trial server, follow the HTTPS example and use 443 as the port.

  3. After updating the script that pertains to your operating system, double-click or run (Linux, Mac) or Script.bat (Windows) to run the Java program.

  4. In your browser, proceed to the following URL (replace the host field with your ThingWorx Composer host) in order to see the application work:




You can also open the RaspberryPiAssemblyLine Mashup in the Composer and click View Mashup.


You should be able to see rows of assembly machines with buttons. Click the Start button to start the assembly line. Click the Add Board button to add Raspberry Pi motherboards.


NOTE: The screen will not update and properties cannot be changed until the Java backend starts running. Ensure the connection is made before attempting to start the assembly line.


Functional Breakdown


At runtime, the Mashup executes the following functions:




           Mashup Component        Function
1 Assembly MachinesSelecting an assembly machine will provide you with information on the diagnostic status of that assembly machine and access to charts highlighting its performance.

2 Start ButtonStart up the assembly line and all assembly machines.
3 Shutdown ButtonStop the assembly line and shutdown all assembly machines. Queues will not be purged.
4 Motherboard Add DropdownA dropdown that shows the available motherboards that can be added to the assembly line.

5 Add Boards ButtonIf a MotherboardTemplate Entity is selected in the Motherboard Add dropdown, that Raspberry Pi will be added to the assembly line. If no Motherboard is selected, this will add a new Raspberry Pi Thing to the assembly line.
6 Motherboard ImageShow all motherboards currently inside the assembly line queue of Raspberry Pi.
7 Motherboard Pick Up DropdownA dropdown that shows the motherboards in the assembly line that are not in a Complete Stage.
8 Add Pick Up ButtonIf a MotherboardTemplate entity is selected in the Motherboard Pick Up dropdown, that Raspberry Pi will be removed from the assembly line and no longer be available. This can be done if a Raspberry Pi is slowing down the other queues.
9 Box ImageShow all motherboards currently in the Complete Stage.





Step 3: Services and Java Implementation


JavaScript using ThingWorx Services


To support and run the application quickly, ThingWorx Services are utilized as much as possible. This ensures the speed and quality of the application are maintained while also ensuring code changes can be made quickly.


Opening and Starting Up


Open the RaspberryPiAssemblyLine Mashup by going to the URL provided in the last section. The machines will all be in a shut-down (RED) state. This is ensured by a call to the Shutdown service within the SMTAssemblyLineTemplate ThingTemplate. This method begins the process of resetting the Motherboards to their default states and AssemblyMachines to a shutdown state.


Click the Start button to call the StartUp Service. This call will notify the Java Code to turn the simulated machines on and begin waiting for any motherboards to be added to the queue.


INFO: The StartUp and Shutdown services call other services, some of which can be overrided. If you would like to make a change to the implementation, make the change in an implementation of the SMTAssemblyLineTemplate ThingTemplate. You can use RaspberryPiSMTAssemblyLine as an example.


New Raspberry Pi Names


The CommonServices Entity provides services that can be reused by other entities easily. The GenerateRandomThingName service is utilized to create a psuedo-random name for a new Motherboard. You can use this service to create names - names may start with “Raspberry,” but not necessarily - they are based on how you set the parameters.


Creating and Adding Boards


Select the Add Board button to make a call to the AddBoard service of the SMTAssemblyLineTemplate ThingTemplate. This service will call the CommonServices Thing to create a new name for the Motherboard, then begin the process of creating, enabling, and adding that Motherboard to the simulated devices in the Java code.


Pickup Boards


Select the Pickup Board button to make a call to the PickUpMotherboard service of the SMTAssemblyLineTemplate ThingTemplate. This service will remove a Motherboard from the assembly line, update the status to having been picked up, and ensure the simulated devices are updated with this new information.


Queue Processing


Add a Motherboard to the available queue of a machine when the Motherboard is ready to be worked on that machine. A machine will NOT know information about a Motherboard until that motherboard is ready for that stage of processing.


The Motherboard is then added to the internal queue of the machine based on the size of the internal queue of that machine. Being in the internal queue of a machine does not mean it is being worked on. The Motherboard is ONLY being worked on when the machine has added the Motherboard to it’s working queue. The size of the working queue is based on the machine’s placement heads. You can play with these values to increase or descrease queue performance.


INFO: The heads, speeds, and queue sizes of the machines are created in the RaspberryPiSMTAssemblyLine Thing. To change these configurations, update the AddStartingMachines service with new values or new machines.


Java Implementation using ThingWorx Java SDK


The Java code we created for the Assembly Line scenario creates a connection to the ThingWorx Composer as any ThingWorx SDK utility would. This code is used to allow extended functionality for the application, and mimics the behavior of devices or machines connected to the ThingWorx Composer.


Motherboard Class


The Motherboard Class contains several methods to ensure the location of the motherboard is known at all times. It also updates the status level from 0 to 100 as the motherboard is being assembled.


AssemblyMachine Class


The fields in the AssemblyMachine class ensure that the queues handled by the machine are working correctly. When an AssemblyMachine is created, it will load both the available queue and the internal queue if the machine will be the first stage in the assembly line (Soldering).

If not a solder machine, the queues will be empty, as no device is pending its task. If the machine is on, it will continue to work based on its current status of the motherboards in its queue. When a machine is turned on or the current task is complete, the AssemblyMachine will re-evaluate the queues to optimize timing and decrease idle time.


Challenge: Find a way to improve the timing of the queue and reduce the idle time even more. Think of a problem an assembly line might have when machines are waiting on a prior machine to complete a task.


SMTAssemblyLine Class


The SMTAssemblyLine class handles the overall process and controls how motherboards are handled when entering and exiting the assembly line. There are also listeners to start up the assembly machines.


When a board is added to the queue of the assembly line, it will instantly be added to the available queue for a solder machine to begin processing. This is the only machine that will have immediate access to the motherboard. When a board is picked up from the assembly line queue, the status of the board is set to “PICKED UP”. That motherboard will be available later for processing by the assembly line.



Click here to view Part 2 of this guide.




This looks interesting project.

Could you upload again?


Best Regards,


Version history
Last update:
‎Mar 07, 2023 08:35 AM
Updated by:
Labels (1)