Ejemplo n.º 1
0
        public bool Homing(string hostIp, int port)
        {
            Socket           s = ModbusSocket.GetConnection(hostIp, port);
            ModesOfOperation modesOfOperation = new ModesOfOperation();

            modesOfOperation.Write(s, ModesOfOperation.ModesEnum.Homing);
            while (modesOfOperation.ReadDisplay(s) != ModesOfOperation.ModesEnum.Homing)
            {
                Thread.Sleep(100);
            }
            ControlWord controlWord = new ControlWord();

            // Byte 19: 31
            controlWord.Bit00 = true; // 1
            controlWord.Bit01 = true; // 2
            controlWord.Bit02 = true; // 4
            controlWord.Bit03 = true; // 8
            controlWord.Bit04 = true; // 16
            controlWord.Write(s);

            StatusWord statusWord = new StatusWord();

            while (!(statusWord.Bit00 && statusWord.Bit01 && statusWord.Bit02 && statusWord.Bit05 && // 39
                     statusWord.Bit09 && statusWord.Bit10 && statusWord.Bit12)) // 22
            {
                statusWord.Read(s);
                Thread.Sleep(100);
            }
            return(true);
        }
Ejemplo n.º 2
0
        private void ShutDown(Socket s)
        {
            ControlWord controlWord = new ControlWord();

            // Byte 19: 6
            controlWord.Bit01 = true; // 2
            controlWord.Bit02 = true; // 4
            controlWord.Write(s);

            StatusWord statusWord = new StatusWord();

            while (!(statusWord.Bit00 && statusWord.Bit05 && // 33
                     statusWord.Bit09)) // 2
            {
                statusWord.Read(s);
                Thread.Sleep(100);
            }
        }
Ejemplo n.º 3
0
        private void EnableOperation(Socket s)
        {
            ControlWord controlWord = new ControlWord();

            // Byte 19: 15
            controlWord.Bit00 = true; // 1
            controlWord.Bit01 = true; // 2
            controlWord.Bit02 = true; // 4
            controlWord.Bit03 = true; // 8
            controlWord.Write(s);

            StatusWord statusWord = new StatusWord();

            while (!(statusWord.Bit00 && statusWord.Bit01 && statusWord.Bit02 && statusWord.Bit05 && // 39
                     statusWord.Bit09)) // 2
            {
                statusWord.Read(s);
                Thread.Sleep(100);
            }
        }
Ejemplo n.º 4
0
        public void SetControlWord(string hostIp, int port, [FromBody] ControlWord controlWord)
        {
            Socket s = ModbusSocket.GetConnection(hostIp, port);

            controlWord.Write(s);
        }