Presenting a Robot’s Work Progress – Part 2

February 27, 2018 | Robotics

Robots Work Progress 2

In our previous article we described how to create a UiPath custom activity that a robot uses to communicate its progress to a potentially listening application. The chosen communication channel was NamedPipe. In this article we are going to present a sample Windows Form application that could receive the messages sent by the robot and visually present the enclosed information as:

  • A label’s caption

  • A progress bar

Like in the previous article for this sample we are also using helper class StreamString from “How to: Use Named Pipes for Network Interprocess Communication

Issues to be handled:

  • Application has to be responsive to user interactions (e.g. move, close)

  • There is no information about the number or frequency of incoming messages we have to wait for connection

So we are going to instantiate the NamedPipe server and asynchronously wait for the connection:

NamedPipeServerStream namedPipeServerStream = new NamedPipeServerStream(“TImpactUiPath”,

PipeDirection.InOut,

1,

                            PipeTransmissionMode.Byte,

                            PipeOptions.Asynchronous);

namedPipeServerStream.BeginWaitForConnection(WaitForConnectionCallBack, null);

When a message is received, in the callback function WaitForConnectionCallBack we end the asynchronous operation to wait for a client to connect and process the message updating in the form:

private void WaitForConnectionCallBack(IAsyncResult result)

{

try

       {

              namedPipeServerStream.EndWaitForConnection(result);

              StreamString ss = new StreamString(namedPipeServerStream);

              string message = ss.ReadString();

              UpdateFormState();

              worker.ReportProgress(0, message);

              namedPipeServerStream.Close();

}

       catch

       {

              return;

}

}

After closing the NamedPipe server, the application is not listening anymore for subsequent incoming messages, so we need to instantiate a new server.

When the application is being closed by the user, the asynchronous operation to wait for a client to connect should also be ended and the server closed to release all used resources.

The received message will be a JSON string that can be easily parsed using, for example the Newtonsoft Json.NET library.

Related Articles

7 ways in which the best law firms are attracting and retaining top talent

June 17, 2019 | Digital Transformation | Legal | Robotics

The best law firms understand that they have to treat their employees as customers, and that means really understanding what matters to them. This article will explore some of those key drivers and how the best firms are turning them to their advantage. 1 – Smart lawyers know that the future rests with the firms […]

The Six Factors Changing Local Government Forever

May 24, 2019 | Digital Transformation | Local Government | Robotics

Many Local Governments stand on the brink of bankruptcy after years of underfunding and budget cuts. Employees are overworked and underpaid, whilst Chief Executives are forced to make difficult decisions which affect the lives of their constituents. T-Impact have identified six key factors that are changing Local Government and senior staff need to adapt to […]

IBM & UiPath partner to offer the ultimate automation solution

May 15, 2019 | Digital Transformation | Robotics

IBM provides the world’s leading workflow solutions. Their business process management suite (BPMS) solution enables organisations to manage complex processes that span many organisations and IT systems. It supports processes that can run for long periods of time and provides dashboards to monitor and track processes, which is especially useful when there are numerous instances […]