예제 #1
0
        private void WriteModbus()
        {
            foreach (Registre registre in Registres)
            {
                switch ((REGISTRE)Enum.Parse(typeof(REGISTRE), registre.Nom))
                {
                case REGISTRE.ConsigneA:
                {
                    ModBusMaster.WriteSingleRegister(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), (ushort)ConsigneA);
                }
                break;

                case REGISTRE.ConsigneV:
                {
                    ModBusMaster.WriteSingleRegister(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), (ushort)ConsigneV);
                }
                break;

                case REGISTRE.LectureA:
                {
                    ushort[] readLectureA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), 1);
                    LectureA = readLectureA[0];
                }
                break;

                case REGISTRE.LectureV:
                {
                    ushort[] readLectureV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), 1);
                    LectureV = readLectureV[0];
                }
                break;
                }
            }
        }
예제 #2
0
        private void LocaleRecette()
        {
            foreach (Registre registre in Registres)
            {
                switch ((REGISTRE)Enum.Parse(typeof(REGISTRE), registre.Nom))
                {
                case REGISTRE.ConsigneA:
                {
                    ushort[] readConsigneA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    ConsigneA = readConsigneA[0];
                }
                break;

                case REGISTRE.ConsigneV:
                {
                    ushort[] readConsigneV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    ConsigneV = readConsigneV[0];
                    if (ValuesA.Count < 500)
                    {
                        ValuesA.Add(ConsigneV);
                    }
                    else
                    {
                        for (int i = 0; i < ValuesA.Count - 1; i++)
                        {
                            ValuesA[i] = ValuesA[i + 1];
                        }
                        ValuesA[ValuesA.Count - 1] = ConsigneV;
                    }
                }
                break;

                case REGISTRE.LectureA:
                {
                    ushort[] readLectureA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    LectureA = readLectureA[0];
                    if (ValuesB.Count < 500)
                    {
                        ValuesB.Add(ConsigneA);
                    }
                    else
                    {
                        for (int i = 0; i < ValuesA.Count - 1; i++)
                        {
                            ValuesB[i] = ValuesB[i + 1];
                        }
                        ValuesB[ValuesA.Count - 1] = ConsigneA;
                    }
                }
                break;

                case REGISTRE.LectureV:
                {
                    ushort[] readLectureV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    LectureV = readLectureV[0];
                }
                break;
                }
            }
        }
예제 #3
0
        private void LocaleManuel()
        {
            foreach (Registre registre in Registres)
            {
                switch ((REGISTRE)Enum.Parse(typeof(REGISTRE), registre.Nom))
                {
                case REGISTRE.ConsigneA:
                {
                    ushort[] readConsigneA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    ConsigneA = readConsigneA[0];
                }
                break;

                case REGISTRE.ConsigneV:
                {
                    ushort[] readConsigneV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    ConsigneV = readConsigneV[0];
                }
                break;

                case REGISTRE.LectureA:
                {
                    ushort[] readLectureA = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    LectureA = readLectureA[0];
                }
                break;

                case REGISTRE.LectureV:
                {
                    ushort[] readLectureV = ModBusMaster.ReadHoldingRegisters(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), Cst_NbRedresseurs);
                    LectureV = readLectureV[0];
                }
                break;
                }
            }
        }