コード例 #1
0
ファイル: DataConversions.cs プロジェクト: ltsoft-gmbh/LazyPI
        public static ResponseModels.DataPoint Convert(LazyObjects.PIPoint point)
        {
            ResponseModels.DataPoint result = new ResponseModels.DataPoint(point.ID, point.WebID, point.Name, point.Description, point.Path);
            result.PointClass = point.PointClass;
            result.PointType  = point.PointType;
            result.Future     = point.Future;

            return(result);
        }
コード例 #2
0
        //TODO: Implement GetAttributes

        //TODO: Implement GetCategories

        /// <summary>
        /// Assumes that the attribute is of type PIPoint and returns the PIPoint.
        /// </summary>
        /// <param name="Connection"></param>
        /// <param name="AttrID"></param>
        /// <returns></returns>
        /// <remarks>This is kind of hacky...</remarks>
        public LazyObjects.PIPoint GetPoint(LazyPI.Common.Connection Connection, string AttrID)
        {
            WebAPIConnection webConnection = (WebAPIConnection)Connection;
            var request = new RestRequest("/attributes/{webId}");

            request.AddUrlSegment("webId", AttrID);
            var attrResponse = webConnection.Client.Execute <ResponseModels.AFAttribute>(request);

            string pointLink = attrResponse.Data.Links["Point"];
            int    pos       = pointLink.LastIndexOf("/") + 1;
            string webID     = pointLink.Substring(pos, pointLink.Length - pos);

            request = new RestRequest("/points/{webId}");
            request.AddUrlSegment("webId", webID);
            var pointResponse = webConnection.Client.Execute <ResponseModels.DataPoint>(request);

            ResponseModels.DataPoint point = pointResponse.Data;

            LazyObjects.PIPoint result = new LazyObjects.PIPoint(Connection, point.WebId, point.Id, point.Name, point.Description, point.Path, point.PointType, point.PointClass, point.Future);
            return(result);
        }