Example #1
0
 private void CheckForErrors(string PLCError, MYSCOM SCom)
 {
     if (errorReset)
     {
         GetFirstError();
         Console.WriteLine("New Error");
     }
 }
Example #2
0
        public void CreateConnection(int Com, string ip, string port)
        {
            MYSCOM SCom = new MYSCOM(Com); //<<< Set COM channel here <<<

            com = SCom;

            SCom.ComType  = ComType.COMTYPE_WINSOCK_CLIENT;
            SCom.PortOpen = true;

            SCom.ConnectAddress = ip + ":" + port;
            SCom.ConnectTimeout = SuperCom.SEC_10;

            SCom.Connect = true;

            // lazy busy wait. It is better to let the events run and enable buttons, menus etc.
            while (SCom.JobProcessing == true)
            {
                SuperCom.RS_Delay(10);
            }

            if (SCom.Connected == false)
            {
                Console.Out.WriteLine("Server not found.");
                Console.ReadLine();
                return;
            }

            // Config LSV2
            SuperCom.PLSV2.RS_SetBCCType(SCom.CommId, SuperCom.PLSV2.BCC_HEIDENHAIN, 0);

            // Config LSV2 Heidenhain
            SuperCom.PLSV2.Heidenhain.HN_GetSetMasterFlag(SCom.CommId, SuperCom.IS_TRUE);

            // Start
            // if HN_SetConfig is also setting SET_BUF, then the privilege to INSPECT is required!
            SCom.DoLogIn(SuperCom.PLSV2.Heidenhain.AREA_INSPECT);

            byte[] szHNConfig = new byte[128];
            SuperCom.CopyStringToByteArray(ref szHNConfig, "IsMASTER=1;IsML=1;SetBuf=255;TOReply=1000;");
            SuperCom.PLSV2.Heidenhain.HN_SetConfig(SCom.CommId, szHNConfig);

            // At some early point bevor it is used to show version or read memory addresses
            SCom.SysPars = new SuperCom.PLSV2.Heidenhain.HN_SYSTEM_PARAMS(SCom.CommId); // needs area INSPECT

            SCom.DoLogIn(SuperCom.PLSV2.Heidenhain.AREA_DATA);

            SCom.DoLogIn(SuperCom.PLSV2.Heidenhain.AREA_PLCDEBUG);

            errorReset = true;
            SetTimer();
            Console.WriteLine("started connection");
        }