<?xml version="1.0" encoding="Shift_JIS"?>
<?xml-stylesheet type="text/xsl" href="../Fmethod_xsl/fmethod_he_c.xsl"?>

<root>
  <func>
    <title>cnc_dnc2</title>


    <declare>
      <vc>
        <include>#include "fwlib32.h"</include>
        <prottype>FWLIBAPI short WINAPI cnc_dnc2(unsigned short FlibHndl, long *length, char *data);</prottype>
      </vc>
    </declare>



    <doc>
        <cmn>
            <p>Outputs the NC part program for DNC operation or M198 operation to CNC.</p>
            <p>
                This function outputs the characters of NC program as long as it is specified by '*length'('length').<br/>
                However, if there is no room to store the specified number of character, this function stores the
                characters as many as possible to fill the buffer and then sets '*length'('length') with the real number                of characters which are stored in the buffer.
            </p>
            <p>
                In case that this function cannot output at least one character, 
                it returns EW_BUFFER, so again call this function with the same arguments.
            </p>

            <p>
                When DNC operation or M198 operation is aborted on CNC side, this function returns EW_RESET.<br/>
                In this case, call <a href="Program/cnc_dncend2.htm" target="_parent">cnc_dncend2</a> with
                DNC_CANCEL as the output result in order to terminate  the output of NC program.
            </p>
            <p>Following shows the format of NC part program to be output.</p>
            <p class="dd">
                EOB CMD1 EOB CMD2 EOB ..... CMDn EOB Mxx EOB<br/>
                <table class="dd">
                    <tr>
                        <td>CMD1...n    </td><td>ASCII character string</td>
                    </tr>
                    <tr>
                        <td>EOB         </td><td>LF(0x0A)</td>
                    </tr>
                    <tr>
                        <td>Mxx         </td><td>M code that shows the termination of
                                                    DNC operation. (M02 or M30, etc.)</td>
                    </tr>
                </table>
            </p>
            <p>In case of M198 operation, 'M99' must be specified to 'Mxx'.</p>
            <table  border="2" bordercolorlight="Black" bordercolordark="Black">
                <tr><td>Note1) Please be careful !!!   When dnc function is used with Ethernet,  the transfer rate is not secured by the state of the network.</td></tr>
            </table>
        </cmn>
    </doc>



    <argument>
        <common>
            <cmn>
                <item>
                    <name>FlibHndl</name>
                    <type>in</type>
                    <content>
                        <p>
                            Specify the library handle.
                            See "<a href="handle.htm" target="_parent">Library handle</a>" for details.
                        </p>
                    </content>
                </item>
                <item>
                    <name>length</name>
                    <type>in/out</type>
                    <content>
                        <p>
                            The pointer of long type variable where the number of the
                            characters that are output from MMC function is set.<br/>
                            When this function returns, the actual number of characters
                            that are output to CNC will be set.
                        </p>
                        <p>
                            This function returns EW_LENGTH if '*length'('length') has the value of zero or negative.
                        </p>
                    </content>
                </item>
                <item>
                    <name>data</name>
                    <type>in</type>
                    <content>
                        <p>
                            The pointer of the area where NC part program to be output is stored.
                        </p>
                    </content>
                </item>
            </cmn>
        </common>
    </argument>



    <errcode>
        <item>
            <name>EW_RESET</name>
            <content>
                Reset or stop request<br/>
                'RESET or STOP' was pushed.<br/>
                Call the <a href="Program/cnc_dncend2.htm" target="_parent">cnc_dncend2</a> function.
            </content>
        </item>
        <item>
            <name>EW_FUNC</name>
            <content>
                <a href="Program/cnc_dncstart2.htm" target="_parent">cnc_dncstart2</a> function has not been executed.
            </content>
        </item>
        <item>
            <name>EW_LENGTH</name>
            <content>
                Data block length error<br/>
                The size of character string is negative.
            </content>
        </item>
        <item>
            <name>EW_BUFFER</name>
            <content>
                Buffer empty/full<br/>
                Retry because the buffer is full.<br/>
            </content>
        </item>
        <item>
            <name>EW_PARAM</name>
            <content>
                CNC parameter error<br/>
                the following CNC parameter must be set.<br/>
                Series 150, 150i<br/>
                <span class="dd">7713#0 = 1</span><br/>
                Series 160/180/210, 160i/180i/210i, 0i<br/>
                <span class="dd">8706#1 = 1</span><br/>
            </content>
        </item>
        <item>
            <name>EW_NOOPT</name>
            <content>
                No option<br/>
                The extended driver/library function is necessary.
            </content>
        </item>

        <is>
            <item>
                <name>EW_RESET</name>
                <content>
                    Reset or stop request<br/>
                    Call the <a href="Program/cnc_dncend2.htm" target="_parent">cnc_dncend2</a> function.
                </content>
            </item>
            <item>
                <name>EW_FUNC</name>
                <content>
                    <a href="Program/cnc_dncstart2.htm" target="_parent">cnc_dncstart2</a> function has not been executed.
                </content>
            </item>
            <item>
                <name>EW_LENGTH</name>
                <content>
                    Data block length error<br/>
                    The size of character string is negative.
                </content>
            </item>
            <item>
                <name>EW_BUFFER</name>
                <content>
                    Buffer empty/full<br/>
                    Retry because the buffer is full.<br/>
                </content>
            </item>
            <item>
                <name>EW_NOOPT</name>
                <content>
                    No option<br/>
                    The extended driver/library function is necessary.
                </content>
            </item>
        </is>
    </errcode>



    <option>
        <hssb>The extended driver/library function is necessary.</hssb>
        <ethr><p>The Ethernet function and the extended driver/library function are necessary.</p>
              <p>However, in case of Series 160i/180i/210i, 0i MODEL B and 300i/310i/320i, the required CNC option is as follows.</p>
              <p>When Embedded Ethernet is used,</p>
              <p><ul>above two optional functions are not required.</ul></p>
              <p>When Ethernet board is used,</p>
              <p><ul>only Ethernet function is required.</ul></p>
        </ethr>
    </option>



    <parameter>
        <type>
            <ul>
            <li>HSSB</li>
                <ul>
                <li>Series 150</li>
                        0000#0 (influenced by setting)<br/>
                        7713#0 = 1 (must be set)<br/>
                        0020 = 15 (must be set)<br/>
                <br/>
                <li>Series 150i</li>
                        0000#0 (influenced by setting)<br/>
                        0020 = 15 (must be set)<br/>
                <br/>
                <li>Series 160/180/210, 160i/180i/210i, 0i</li>
                        0000#0 (influenced by setting)<br/>
                        8706#0 (influenced by setting) (This parameter is effective only in path 1. Set 0 except the 1st path.)<br/>
                        8706#1 = 1 (must be set)<br/>
                        0020 = 15 (must be set)<br/>
                        0020 = 16 (must be set)(In case of HSSB PORT2 function)<br/>
                <br/>
                <li>Series 300i/310i/320i</li>
                        0000#0 (influenced by setting)<br/>
                        0020 = 15 (must be set)<br/>
                        0020 = 16 (must be set)(In case of HSSB PORT2 function)<br/>
                <br/>
                </ul>
            <li>Ethernet</li>
                <ul>
                <li>Series 150i</li>
                        0000#0 (influenced by setting)<br/>
                        0020 = 6 (must be set)<br/>
                <br/>
                <li>Series 160i/180i/210i, 0i, 300i/310i/320i<!--, Power Mate i--></li>
                        0000#0 (influenced by setting)<br/>
                        0020 = 6 (must be set)
                </ul>
            </ul>
        </type>
    </parameter>

    <is_parameter>
        <type>
            <ul>
                0000#0 (influenced by setting)<br/>
                0020 = 15 (must be set)
            </ul>
        </type>
    </is_parameter>



    <mode>
        <cmn>
            <ul>
            <li>HSSB</li>
                <ul>
                    <li>Series 150</li>
                        It is necessary to be set in TAPE mode.<br/>
                    <br/>
                    <li>Series 150i</li>
                        It is necessary to be set in DNC mode.<br/>
                    <br/>
                    <li>Series 160/180, 160i/180i/210i, 0i</li>
                        It is necessary to be set in MEM mode, and "DMMC" signal(DI),
                        G042#7=1 in case of DNC operation.<br/>
                    <br/>
                    <li>Series 300i/310i/320i, 160i/180i/210i(In case of HSSB PORT2 function)</li>
                        It is necessary to be set in MEM mode, and "DNCI" signal(DI),
                        G043#5=1 in case of DNC operation. <br/>
                </ul>
            <br/>
            <li>Ethernet</li>
                <ul>
                    <li>Series 150i</li>
                        It is necessary to be set in DNC mode. <br/>
                    <br/>
                    <li>Series 160i/180i/210i, 0i, 300i/310i/320i<!--, Power Mate i--></li>
                        It is necessary to be set in MEM mode, and "DNCI" signal(DI), G043#5=1 in case of DNC operation.
                </ul>
            </ul>
        </cmn>
    </mode>

    <is_mode>
        <cmn>
            It is necessary to be set in MEM mode, and "DNCI" signal(DI), G043#5=1 in case of DNC operation.
        </cmn>
    </is_mode>



    <support>
        <m>
            <fs0ia>H</fs0ia>
            <fs0ib>O</fs0ib>
            <fs15>H</fs15>
            <fs15i>O</fs15i>
            <fs16>H</fs16>
            <fs18>H</fs18>
            <fs21>X</fs21>
            <fs16ia>O</fs16ia>
            <fs18ia>O</fs18ia>
            <fs21ia>O</fs21ia>
            <fs16ib>O</fs16ib>
            <fs18ib>O</fs18ib>
            <fs21ib>O</fs21ib>
            <fs30i>O</fs30i>
        </m>
        <t>
            <fs0ia>H</fs0ia>
            <fs0ib>O</fs0ib>
            <fs15>H</fs15>
            <fs15i>X</fs15i>
            <fs16>H</fs16>
            <fs18>H</fs18>
            <fs21>X</fs21>
            <fs16ia>O</fs16ia>
            <fs18ia>O</fs18ia>
            <fs21ia>O</fs21ia>
            <fs16ib>O</fs16ib>
            <fs18ib>O</fs18ib>
            <fs21ib>O</fs21ib>
            <fs30i>O</fs30i>
        </t>
        <lc>
            <fs0ia>X</fs0ia>
            <fs0ib>X</fs0ib>
            <fs15>X</fs15>
            <fs15i>X</fs15i>
            <fs16>X</fs16>
            <fs18>X</fs18>
            <fs21>X</fs21>
            <fs16ia>X</fs16ia>
            <fs18ia>X</fs18ia>
            <fs21ia>X</fs21ia>
            <fs16ib>X</fs16ib>
            <fs18ib>X</fs18ib>
            <fs21ib>X</fs21ib>
            <fs30i>X</fs30i>
        </lc>
        <p>
            <fs16i>O</fs16i>
            <fs18i>O</fs18i>
        </p>
        <l>
            <fs16i>O</fs16i>
            <fs18i>X</fs18i>
        </l>
        <w>
            <fs16i>H</fs16i>
            <fs18i>H</fs18i>
        </w>
        <pw>
            <d>X</d>
            <h>X</h>
        </pw>
        
        <is>
            <m>
                <fs30is>O</fs30is>
            </m>
            <t>
                <fs30is>O</fs30is>
            </t>
        </is>
    </support>



    <reference>
        <item>
            <name>cnc_dncstart2</name>
            <file>Program/cnc_dncstart2.htm</file>
        </item>
        <item>
            <name>cnc_dncend2</name>
            <file>Program/cnc_dncend2.htm</file>
        </item>
        <item>
            <name>cnc_rddncdgndt</name>
            <file>Program/cnc_rddncdgndt.htm</file>
        </item>
    </reference>



    <example>
<vc>
The following program executes the NC commands by DNC operation.

        M3 S1500 ;
        G28 U0 W0 ;
        T0101 ;
        G0 X35. Z-10. ;
        M30 ;

#include "fwlib32.h"

short example( void )
{
        char* prg =
                "\n"
                "M3S1500\n"
                "G28U0W0\n"
                "T0101\n"
                "G0X35.Z-10.\n"
                "M30\n"
                "%";

        char fname[16];
        long len, n;
        short ret;

        ret = cnc_dncstart2( h, fname ) ;
        if ( ret ) return ( ret ) ;

        len = strlen( prg ) ;
        while ( len > 0 ) {
                n = len ;
                ret = cnc_dnc2( h, &#38;n, prg ) ;
                if ( ret == EW_BUFFER ) {
                        continue ;
                }
                if ( ret == EW_OK ) {
                        prg += n ;
                        len -= n ;
                }
                if ( ret != EW_OK ) {
                        break ;
                }
        }
        if ( ret == EW_RESET )
                ret = cnc_dncend2( h, DNC_CANCEL ) ;
        else
                ret = cnc_dncend2( h, DNC_NORMAL ) ;
        return ( ret ) ;
}
</vc>
    </example>



  </func>
</root>
