VC + + connection Fanuc machine tool real-time data acquisition using FOCAS4.0 version of the development library __c++

Source: Internet
Author: User

VC + + connection Fanuc machine tool real-time data acquisition using FOCAS4.0 version of the development library

FoCas protocol, tested successfully on HSSB's fanuc15i.


int main (int argc, char *argv[]) {
if (ARGC < 2)
{
fprintf (stderr, "Usage:%s + optional \ n", argv[0]);
Exit (1);
}


unsigned short hfanuc;
Short Fanret, Funcret; Do we have a handle + did function succeed?
Odbst Fanbuf; CNC Status
Odbact Spspeed; Spindle speed (selected spindle)
ODBACT2 Spspeed2; Spindle speed
Prgdir Progdir; Program Directory
Odbaxis buf; Axis Position (test)


Long node = 9; Simulator
Short method = 0; Defaults to Ethernet


if (argv[2]!= NULL)
method = Atoi (argv[2]);


Switch (method)
{
Case 1:
Fanret = Cnc_allclibhndl (&AMP;HFANUC); HSSB Real Machine
Break
Case 2:
Fanret = CNC_ALLCLIBHNDL2 (node, &AMP;HFANUC); HSSB Simulator Ncguide
Break
Default
Fanret = Cnc_allclibhndl3 (argv[1], 8193, 5, &AMP;HFANUC); Ethernet
Break
}


if (!fanret)
{
Funcret = Cnc_statinfo (Hfanuc, &fanbuf);
if (Funcret)
printf ("ERROR (%d) cnc_statinfo Controller%s \ n", Funcret, argv[1]);
Else
printf (' Fanuc%s replied:\nautomatic-manual Mode (AUT): \t\t%d\nstatus of Automatic Operation (run): \t%d\nstatus of Emerg Ency (Emergency): \t%d\nstatus of Alarm (Alarm): \t\t%d\nstatus of program Editing (edit): \t%d\n ", argv[1], Fanbuf.aut, fan Buf.run, Fanbuf.emergency, Fanbuf.alarm, Fanbuf.edit);


Funcret = Cnc_acts (Hfanuc, &spspeed);
if (Funcret)
printf ("ERROR (%d) cnc_acts Controller%s \ n", Funcret, argv[1]);
Else
printf ("Spindle speed (selected spindle): \t\t%ld\n", spspeed.data); ... Cnc_rdcommand

}







if (!cnc_rdparam (Stat.hfanuc, 15051,-1, 4 + 4 * max_axis, &fanparam))//Read tool offset (15051 = 18i)
{
for (int i = 0; i < 4; i++)//4 Values
{
sprintf (buf, "%.3f%.1s", (float) fanparam.u.ldatas[i]/1000, cdelim); Add Value + |
strcat (Stat.corder, buf); Add to Stat.corder
}


}
else//Did not work
for (int i = 0; i < 4; i++)//4 Values
strcat (Stat.corder, Cnoresult); 0|0|0|0|



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.