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; } } }
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; } } }
public void Disconnect() { if (ClientTcp.Connected) { Mode = MODES.Disconnected.ToString(); ModbusPoolingTask.Abort(); ModBusMaster.Dispose(); ClientTcp.Close(); Redresseurs = null; } }
public void Process(ModBusMaster modbus_master) { foreach (RecipeDosings rd in resipeDosings) { if (m_objActionMapping.ContainsKey(rd.Bunker)) { int result = m_objActionMapping[rd.Bunker].Invoke(rd); modbus_master.SetValue(result); } else { throw new ApplicationException("Couldn't parse bunker!"); } } }
public void DeleteUnexistingGroupe() { foreach (Registre registre in Registres) { if ((REGISTRE)Enum.Parse(typeof(REGISTRE), registre.Nom) == REGISTRE.ExistenceGroupe) { bool[] ExistenceGroupe = ModBusMaster.ReadCoils(Cst_SlaveNb, Convert.ToUInt16(registre.AdresseDebut), 10); for (int i = 0; i < ExistenceGroupe.Count(); i++) { if (!ExistenceGroupe[i]) { SimpleIoc.Default.GetInstance <Model.IRedresseurService>().Delete(i + 1); } } break; } } }
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; } } }