using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DotNettyFrom.db;

namespace DotNettyFrom.config
{
    public class ConfigChange
    {
        public static void ChangeDevice(int type)
        {
            switch (type)
            {
                case SystemConfig.Dtu:
                    changeDTU();
                    break;
                case SystemConfig.Water2:
                    changeWater2();
                    break;
            }
        }

        private static void changeWater2()
        {
            SystemConfig.CurrentType = SystemConfig.Water2;

            SystemConfig.FunctionCodeStartPos = Water2Config.FunctionCodeStartPos;
            SystemConfig.FunctionCodeLength = Water2Config.FunctionCodeLength;

            SystemConfig.HeartbeatDownCmdCode = Water2Config.HeartbeatDownCmdCode;

            SystemConfig.LengthFieldOffset = Water2Config.LengthFieldOffset;
            SystemConfig.LengthFieldLength = Water2Config.LengthFieldLength;
            SystemConfig.LengthAdjustment = Water2Config.LengthAdjustment;
            SystemConfig.InitialBytesToStrip = Water2Config.InitialBytesToStrip;

            SystemConfig.MeasurePointLen = Water2Config.MeasurePointLen;
            SystemConfig.MessageFlowLen = Water2Config.MessageFlowLen;


            SystemConfig.DefaultNo = Water2Config.DefaultWater2No;
            SystemConfig.DefaultPort = Water2Config.DefaulWater2tPort;
            
            
            
            
        }

        private static void changeDTU()
        {
            SystemConfig.CurrentType = SystemConfig.Dtu;

            SystemConfig.FunctionCodeStartPos = DtuConfig.FunctionCodeStartPos;
            SystemConfig.FunctionCodeLength = DtuConfig.FunctionCodeLength;

            SystemConfig.HeartbeatDownCmdCode = DtuConfig.HeartbeatDownCmdCode;

            SystemConfig.LengthFieldOffset = DtuConfig.LengthFieldOffset;
            SystemConfig.LengthFieldLength = DtuConfig.LengthFieldLength;
            SystemConfig.LengthAdjustment = DtuConfig.LengthAdjustment;
            SystemConfig.InitialBytesToStrip = DtuConfig.InitialBytesToStrip;

            SystemConfig.MeasurePointLen = DtuConfig.MeasurePointLen;
            SystemConfig.MessageFlowLen = DtuConfig.MessageFlowLen;

            SystemConfig.DefaultNo = DtuConfig.DefaultDtuNo;
            SystemConfig.DefaultPort = DtuConfig.DefaulDtutPort;
        }
    }
}