Ejemplo n.º 1
0
        public static DeviceProperty CreateFrom(JObject inputNode)
        {
            var deviceProperty = new DeviceProperty
            {
                ID   = inputNode.Value <int>("id"),
                Name = inputNode.Value <string>("name"),
                Type = StringToDataTypeMap.Value[inputNode.Value <string>("type")]
            };

            string accessString = inputNode.Value <string>("access");

            deviceProperty.Access = AccessMode.None;

            if (accessString.Contains("r"))
            {
                deviceProperty.Access |= AccessMode.CanRead;
            }

            if (accessString.Contains("rw"))
            {
                deviceProperty.Access |= AccessMode.CanWrite;
            }

            return(deviceProperty);
        }
Ejemplo n.º 2
0
        public static IDeviceMember ParseMember(DeviceObject parentObject, JObject inputNode)
        {
            switch (inputNode.Value <string>("type"))
            {
            case "object":
                return(DeviceObject.CreateFrom(parentObject, inputNode));

            case "function":
                return(DeviceFunction.CreateFrom(inputNode));

            default:
                return(DeviceProperty.CreateFrom(inputNode));
            }
        }
Ejemplo n.º 3
0
        public static DeviceFunction CreateFrom(int id, string name, JArray argumentNodes, JArray inputNodes, JArray outputNodes)
        {
            var deviceFunction = new DeviceFunction
            {
                ID   = id,
                Name = name,
                Type = DataType.Function
            };

            var arguments = new List <DeviceProperty>();
            var inputs    = new List <DeviceProperty>();
            var outputs   = new List <DeviceProperty>();

            if (argumentNodes != null)
            {
                foreach (dynamic node in argumentNodes)
                {
                    arguments.Add(DeviceProperty.CreateFrom(node));
                }
            }

            if (inputNodes != null)
            {
                foreach (dynamic node in inputNodes)
                {
                    inputs.Add(DeviceProperty.CreateFrom(node));
                }
            }

            if (outputNodes != null)
            {
                foreach (dynamic node in outputNodes)
                {
                    outputs.Add(DeviceProperty.CreateFrom(node));
                }
            }

            deviceFunction.Arguments = arguments;
            deviceFunction.Inputs    = inputs;
            deviceFunction.Outputs   = outputs;

            return(deviceFunction);
        }