コード例 #1
0
        private IMsgUart CreateMsg(RegisterTypeByPosition registerType, ushort[] registers)
        {
            IMsgUart msg = null;

            switch (registerType)
            {
            case RegisterTypeByPosition.PumpStatus:
            case RegisterTypeByPosition.OperationMode:

                int pumpStauts    = registers[(int)RegisterTypeByPosition.PumpStatus];
                int operationMode = registers[(int)RegisterTypeByPosition.OperationMode];
                msg = new MsgTelegram100(pumpStauts, operationMode);

                break;

            case RegisterTypeByPosition.MinWaterTankLevel1:
            case RegisterTypeByPosition.MinWaterTankLevel2:

                int minWaterTankLevel1 = registers[(int)RegisterTypeByPosition.MinWaterTankLevel1];
                int minWaterTankLevel2 = registers[(int)RegisterTypeByPosition.MinWaterTankLevel2];
                msg = new MsgTelegram101(minWaterTankLevel1, minWaterTankLevel2);

                break;

            case RegisterTypeByPosition.WaterTankLevel1:
            case RegisterTypeByPosition.WaterTankLevel2:

                int waterTankLevel1 = registers[(int)RegisterTypeByPosition.WaterTankLevel1];
                int waterTankLevel2 = registers[(int)RegisterTypeByPosition.WaterTankLevel2];
                msg = new MsgTelegram102(waterTankLevel1, waterTankLevel2);

                break;
            }
            return(msg);
        }
コード例 #2
0
        public static void TreatTelegram(IMsgUart msg)
        {
            try
            {
                MsgTelegram101 tel = (MsgTelegram101)msg;

                LocalRepository localRepository = LocalRepository.GetInstance();

                WaterTank[] waterTanks = localRepository.Tanks;
                waterTanks[(int)WaterTankPosition.Tank1].MinLevel = tel.MinLevelTank1;
                waterTanks[(int)WaterTankPosition.Tank2].MinLevel = tel.MinLevelTank2;
            }
            catch (Exception e)
            {
            }
        }