예제 #1
0
        private Dictionary <string, string> GetApiArgs(bool cost, EnergyDataType data_type, int?mtu = null)
        {
            Dictionary <string, string> args;
            string key;

            key = cost.ToString() + data_type.ToString() + ((mtu != null) ? mtu.Value.ToString() : "1");
            if (args_cache.TryGetValue(key, out args))
            {
                return(args);
            }

            args = new Dictionary <string, string>();
            if (cost)
            {
                args.Add("T", "1");
            }
            else
            {
                args.Add("T", "0");
            }
            args.Add("D", ((int)data_type).ToString());
            if (data_type == EnergyDataType.MTU)
            {
                if (mtu != null)
                {
                    args.Add("M", mtu.Value.ToString());
                }
                else
                {
                    args.Add("M", "1");
                }
            }
            args_cache.Add(key, args);
            return(args);
        }
예제 #2
0
        public SpyderData GetSpyderData(bool cost, EnergyDataType data_type, int?mtu = null)
        {
            RestClient.RestResponse <SpyderData> response;

            response = client.Execute <SpyderData>("SpyderData.xml", "GET", null, GetApiArgs(cost, data_type, mtu));
            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(response.Data);
            }

            UpdateStatus <SpyderData>(response);
            return(null);
        }
예제 #3
0
        public DialDataDetail GetSystemOverview(bool cost, EnergyDataType data_type, int?mtu = null)
        {
            RestClient.RestResponse <DialDataDetail> response;

            response = client.Execute <DialDataDetail>("SystemOverview.xml", "GET", null, GetApiArgs(cost, data_type, mtu));
            if (response.StatusCode == System.Net.HttpStatusCode.OK)
            {
                return(response.Data);
            }

            UpdateStatus <DialDataDetail>(response);
            return(null);
        }
예제 #4
0
        public DashData GetDashData(bool cost, EnergyDataType data_type, int?mtu = null)
        {
            RestClient.RestResponse <DashData> response;

            response = client.Execute <DashData>("DashData.xml", "GET", null, GetApiArgs(cost, data_type, mtu));
            if ((response.StatusCode == HttpStatusCode.OK) && (response.Data != null))
            {
                response.Data.Type = data_type;
                response.Data.Cost = cost;
                if (mtu != null)
                {
                    response.Data.MTU = mtu.Value;
                }
                return(response.Data);
            }

            UpdateStatus <DashData>(response);
            return(null);
        }