Our customer has some LB machines in automated cells. Because the layout of the cell the operator has to stop the cell in order to make tool wear adjustments. They wanted to be able to adjust the wear offset from outside the cell using an external computer. Because these are dedicated machines and they only need to adjust two tools the user interface was pretty easy. The only thing of any interest on the user interface side is that I bound the Max and Min settings of the Numeric Up Down controls to a calculation based on the current comp and the max comp the machine will allow. So that if the current value for X is .7 MM and the maximum allowed on the machine is 1 mm the max for the control will be set to .3 mm.
The application shown in the video below runs on their PC. To handle the remote communication I went with a WCF service hosted on the machine. Here is the contract I used for the WCF service:
Imports System.ComponentModel Imports System.ServiceModel Imports System.ServiceModel.Web <ServiceContract()> Public Interface IOkuma <OperationContract()> Function GetMachineType() As Gosiger.Utilities.enumMachineType <OperationContract()> Function GetToolData(ToolGroupNumber As Integer, Turret As EnumTurret) As ToolInfo <OperationContract()> Sub AddOffset(OffsetNumber As Integer, Axis As EnumToolWearAxis, Turret As EnumTurret, NewValue As Double) <OperationContract()> Function IsInInch() As Boolean <OperationContract> Sub Close() End Interface
The GetToolData method returns an object containing information about the tool group such as tool life remaining, current tool in the group etc.
Microsoft has made it much easier to work with WCF in 4.0 by adding default endpoints automatically for you like the HTTP Basic endpoint that I’m using here. I call this sub everytime before I make a function call to make sure the channel is open and connected based on example found on SO. The “BasicHttpBinding_IOkuma” was automatically added to the app.config when I add the service reference. I only had to reference it by name.
Private Sub CreateChannel() If _Okuma IsNot Nothing Then If DirectCast(_Okuma, ICommunicationObject).State = CommunicationState.Opened Then Return End If End If Dim channel__1 = New OkumaServiceRef.OkumaClient("BasicHttpBinding_IOkuma", My.Settings.ConnectionAddress) '"http://192.198.191.144:8080/latheAPI" AddHandler DirectCast(channel__1, ICommunicationObject).Faulted, Sub(s, e) DirectCast(_Okuma, ICommunicationObject).Abort() Try DirectCast(channel__1, ICommunicationObject).Open() Catch generatedExceptionName As EndpointNotFoundException ' don't worry Return End Try _Okuma = channel__1 End Sub
Here is a short video to show how the application works.