Example #1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            checkBox_hexCommand.Checked = Properties.Settings.Default.checkBox_hexCommand;
            textBox_command.Text        = Properties.Settings.Default.textBox_command;
            checkBox_hexParam.Checked   = Properties.Settings.Default.checkBox_hexParam;
            textBox_param.Text          = Properties.Settings.Default.textBox_param;
            serialPort1.Encoding        = Encoding.GetEncoding(Properties.Settings.Default.CodePage);
            button_openport.Enabled     = SerialPopulate(comboBox_portname1, comboBox_portspeed1, comboBox_databits1, comboBox_handshake1, comboBox_parity1, comboBox_stopbits1);

            _logger = new TextLogger.TextLogger(this)
            {
                Channels       = _directions,
                FilterZeroChar = false,
            };
            textBox_terminal.DataBindings.Add("Text", _logger, "Text", false, DataSourceUpdateMode.OnPropertyChanged);

            _logger.LineTimeLimit     = Properties.Settings.Default.LineBreakTimeout;
            _logger.LineLimit         = Properties.Settings.Default.LogLinesLimit;
            _logger.AutoSave          = checkBox_saveTo.Checked;
            _logger.LogFileName       = textBox_saveTo.Text;
            _logger.DefaultTextFormat = checkBox_hexTerminal.Checked
                ? TextLogger.TextLogger.TextFormat.Hex
                : TextLogger.TextLogger.TextFormat.AutoReplaceHex;
            _logger.DefaultTimeFormat =
                checkBox_saveTime.Checked ? TextLogger.TextLogger.TimeFormat.LongTime : TextLogger.TextLogger.TimeFormat.None;
            _logger.DefaultDateFormat =
                checkBox_saveTime.Checked ? TextLogger.TextLogger.DateFormat.ShortDate : TextLogger.TextLogger.DateFormat.None;
            _logger.AutoScroll = checkBox_autoscroll.Checked;
            CheckBox_autoscroll_CheckedChanged(null, EventArgs.Empty);
        }
Example #2
0
        private void Form1_Load(object sender, EventArgs e)
        {
            checkBox_hexCommand.Checked = Settings.Default.checkBox_hexCommand;
            textBox_command.Text        = Settings.Default.textBox_command;
            checkBox_hexParam.Checked   = Settings.Default.checkBox_hexParam;
            textBox_param.Text          = Settings.Default.textBox_param;
            textBox_ipAddress.Text      = Settings.Default.DefaultAddress;
            textBox_port.Text           = Settings.Default.DefaultPort;
            timer1.Interval             = Settings.Default.TCPDataRefreshInterval;

            _logger = new TextLogger.TextLogger(this)
            {
                Channels       = _directions,
                FilterZeroChar = false
            };
            textBox_terminal.DataBindings.Add("Text", _logger, "Text", false, DataSourceUpdateMode.OnPropertyChanged);

            _logger.LineTimeLimit = Settings.Default.LineBreakTimeout;
            _logger.LineLimit     = Settings.Default.LogLinesLimit;
            _logger.AutoSave      = checkBox_saveInput.Checked;
            _logger.LogFileName   = textBox_saveTo.Text;

            _logger.DefaultTextFormat = checkBox_hexTerminal.Checked
                ? TextLogger.TextLogger.TextFormat.Hex
                : TextLogger.TextLogger.TextFormat.AutoReplaceHex;

            _logger.DefaultTimeFormat =
                checkBox_saveTime.Checked
                    ? TextLogger.TextLogger.TimeFormat.LongTime
                    : TextLogger.TextLogger.TimeFormat.None;

            _logger.DefaultDateFormat =
                checkBox_saveTime.Checked
                    ? TextLogger.TextLogger.DateFormat.ShortDate
                    : TextLogger.TextLogger.DateFormat.None;

            _logger.AutoScroll = checkBox_autoscroll.Checked;

            CheckBox_autoscroll_CheckedChanged(null, EventArgs.Empty);
        }
Example #3
0
        bool synchronModeRKorrActive_; // true if the RKorr synchron mode is active

        #endregion Fields

        #region Constructors

        /* ----------------------------------------------------------------------------------------------------------------------------------------------- */
        /**
         *  @brief     Constructor of connector object
         *
         *  @param     pathToCommandXMLDocument ... here you will have to give the path for the command xml document; the easiest way is to place it in
         *                                          the same directory as the dll is then you only have to enter the name here; otherwise give the full
         *                                          path;
         *             listenIPAddress ... IP-Address as string where the wrapper has to listen for the robot connection; normally its an LAN adapter
         *                                 address; try to figure it out with Windows Start Button -> Run -> cmd Enter; then enter ipconfig and press
         *                                 Enter => search for the local area network adapter an its ip address
         *             listenPort ... Normally this value has to be set to 6008 if not other set in KUKA Config XML file on controller (INIT directory)
         *
         *  @retval    none...
         */
        /* ----------------------------------------------------------------------------------------------------------------------------------------------- */
        public ConnectorObject(String pathToCommandXMLDocument, String listenIPAddress, uint listenPort)
        {
            int iError = 0;

            // ------------------------------------------------
            // initialize all other needed instances
            // ------------------------------------------------
            logger_ = new TextLogger.TextLogger( 255 ); // 255 is buffer size of logger

            // ------------------------------------------------------------------------
            // initialize all communication variables and check if valid (if possible)
            // ------------------------------------------------------------------------
            if ((listenPort > 1024) && (listenPort < 65535))
            {
                robotCommunicationPort_ = listenPort;
            }
            else
            {
                robotCommunicationPort_ = 6008;
            }

            // check if the ipAddress is correct otherwise write a logMessage and exit
            try
            {
                robotListenIPAddress_ = System.Net.IPAddress.Parse(listenIPAddress);
            }
            catch
            {
                makeLoggingEntry("please give a correct IP-address...");
                iError = 1;
            }

            // --------------------------------------------------
            // initialize comBuffer and according variables
            // --------------------------------------------------
            comBufferReadPointer_ = 0;
            comBufferWritePointer_ = 0;
            comBuffer_ = new byte[comBufferSize_];

            // ---------------------------------------------------------------------------------------------------
            // check if the path is correct otherwise take a file located in the same folder as the client is
            // ---------------------------------------------------------------------------------------------------
            if ((pathToCommandXMLDocument != null) && (pathToCommandXMLDocument.Length != 0))
            {
                pathToCommandXMLDocument_ = pathToCommandXMLDocument;
            }
            else
            {
                pathToCommandXMLDocument_ = "commanddoc.xml";
            }

            // -----------------------------------------
            // initialize the connection states
            // -----------------------------------------
            robotConnectionState_ = new ConnectionState();
            setRobotConnectionState(ConnectionState.init);

            // -----------------------------------------
            // initialize the stop watches
            // -----------------------------------------
            stopWatch_ = new System.Diagnostics.Stopwatch();
            stopWatchReceive_ = new System.Diagnostics.Stopwatch();
            stopWatchSend_ = new System.Diagnostics.Stopwatch();

            // -----------------------------------------
            // reset all statistical variables
            // -----------------------------------------
            receivedPackagesCount_ = 0;
            sendPackagesCount_ = 0;
            communicationTimeMilliSeconds_ = 0;
            communicationTimeTicks_ = 0;
            delayedPackagesCount_ = 0;

            // allow commands from initial state
            lockCorrectionCommands_ = false;

            // -----------------------------------------
            // reset synchron mode flags
            // -----------------------------------------
            synchronModeAKorrActive_ = false;
            synchronModeRKorrActive_ = false;
            synchronKorrBufferReadPointer_ = 0;
            synchronKorrBufferWritePointer_ = 0;
            synchronKorrBuffer_ = new synchronKorrBufferStruct[synchronKorrBufferSize_];

            // ------------------------------------------------------------------------------------
            // initilize all mutexes
            // ------------------------------------------------------------------------------------
            mutexRobotCommandString_ = new System.Threading.Mutex(false, "robotCommandString");
            mutexRobotInfoString_ = new System.Threading.Mutex(false, "robotInfoString");
            mutexRobotCommandXML_ = new System.Threading.Mutex(false, "robotCommandXML");
            mutexRobotInfoXML_ = new System.Threading.Mutex(false, "robotInfoXML");

            // -----------------------------------------------
            // initialize the xml container
            // -----------------------------------------------
            receiveXML_ = new System.Xml.XmlDocument();
            commandXML_ = new System.Xml.XmlDocument();

            // -----------------------------------------------------------------
            // try to load the given xml document for commands
            // -----------------------------------------------------------------
            commandXML_ = getXMLCommandDocument(pathToCommandXMLDocument_);
            if (commandXML_ == null)
            {
                makeLoggingEntry("could not find command XML-file...");
                iError = 2;
            }

            // ---------------------------------------------------------------
            // only return constructor done if everything is done correctly
            // ---------------------------------------------------------------
            if (iError == 0)
            {
                makeLoggingEntry("constructor done...");
            }
        }