3

I am writing a program that will run on both lathe and machining centers. How best can I initialize the API without doing during loading. Should I call a class for each machine type or can I call each (and close them) within the same class?

Added example of current method for just Lathe...

 using Okuma.CLDATAPI.DataAPI;
 using Okuma.CLDATAPI.Enumerations;
 using Okuma.CLDATAPI.Structures;
 using Okuma.CLDATAPI.DataAPI.MacMan;

 public class LatheDutyOnline
 {
 private CMachine Objl;
 private CVariables Objlv;
 private CIO IO;
 private CATC ObjAtc;
 private CAxis objaxis;
 private CBallScrew objBS;
 private CProgram objProgram;
 private CSpec objSpec;
 private CSpindle objSpindle;

 private void Form1_Load(System.Object sender, System.EventArgs e)
    {
        Objl = new CMachine();
        Objl.Init();
        Objlv = new CVariables();
        IO = new CIO();
        ObjAtc = new CATC();
        objaxis = new CAxis();
        objBS = new CBallScrew();
        objProgram = new CProgram();
        objSpec = new CSpec();
        objSpindle = new CSpindle();
    }
Hans Passant
  • 922,412
  • 146
  • 1,693
  • 2,536
chris heeg
  • 67
  • 4

2 Answers2

3

You need a routine to check the current machine type. Something like this:

Private Sub CheckMachineType()  
    If System.IO.File.Exists("C:\OSP-P\SHAREDDLL\LDATAPI.DLL") And   System.IO.File.Exists("C:\OSP-P\VOLANTE\CRAD\LCMDAPI.EXE") Then  
        MachineType = Lathe  
    ElseIf System.IO.File.Exists("C:\OSP-P\SHAREDDLL\MDATAPI.DLL") And System.IO.File.Exists("C:\OSP-P\VOLANTE\CRAD\MCMDAPI.EXE") Then    
        MachineType = MachiningCenter  
    Else  
        MachineType = NonOSP  
    End If
End Sub

Then you can initialize the correct API type based on the value of MachineType.


UPDATE

We now have a standard machine agnostic library that is perfect for this.
Please have a look at the sample program for SCOUT.

Community
  • 1
  • 1
Scott Solmer
  • 3,871
  • 6
  • 44
  • 72
2

Take a look at c# intro to Interfaces and this video using .Net interfaces for machine neutral applications. Using interfaces allows you to program against the interface instead of directly against the API.

jweaver
  • 661
  • 5
  • 15