Exemplo n.º 1
0
        public float getSonar(int position)
        {
            ArrayList list = new ArrayList();

            if (!SensorsDictionary.TryGetValue(SensorTypes.UltraSonicSonar, out list))
            {
                throw new NoInstanceException();
            }

            if (list.Count <= position)
            {
                throw new IndexOutOfRangeException();
            }

            ListEntry le    = (ListEntry)list[position];
            float     value = Defines.INVALID_FLOAT;

            SonarAdapter adapter = (SonarAdapter)le.Adapter;

            value = adapter.get();

            if (value == Defines.INVALID_FLOAT)
            {
                throw new InvalidValueException("Cannot get true value.");
            }

            return(value);
        }
        public void AddInfra(string type, string name = null, string url = null)
        {
            if (string.IsNullOrEmpty(type))
            {
                return;
            }
            InfraAdapter ia = null;

            switch (type.ToLower())
            {
            case "server":
                ia = new ComputerAdapter(this);
                break;

            case "sonarqube":
                ia = new SonarAdapter(this);
                break;

            case "sql":
                ia = new SqlAdapter(this);
                break;

            //case "vpn":
            //    ia = _openvpnAdapter;
            //    break;
            //case "docker":
            //    ia = _dockerAdapter;
            //    break;
            case "team city":
                ia = new TeamCityAdapter(this);
                break;

            case "bitbucket":
                ia = new BitbucketAdapter(this);
                break;

            case "postgresql":
                ia = new PostGreAdapter(this);
                break;

            case "syncany":
                ia = new SyncanyAdapter(this);
                break;

            default:
                break;
            }

            if (ia != null)
            {
                try
                {
                    ia.Name = name != null ? name : ia.GetType().ToString().Split('.')[ia.GetType().ToString().Split('.').Length - 1].Replace("Adapter", string.Empty);
                    ia.Url  = url;
                    InfraFarm.Add(ia);
                    //GoAction("Infra_Save");
                }
                catch (Exception e)
                {
                }
            }
        }