Esempio n. 1
0
        public static NodeDevice BuildWith(
            FieldIdentifier Code, FieldGuid TypeId,
            FieldString Address, FieldBase64 Configuration,
            FieldDeviceName DeviceName)
        {
            //build fields
            Dictionary <FieldIdentifier, FieldBase> mutableFields =
                new Dictionary <FieldIdentifier, FieldBase>();

            mutableFields.Add(new FieldIdentifier(m_CodeName), Code);
            mutableFields.Add(new FieldIdentifier(m_TypeIdName), TypeId);
            mutableFields.Add(new FieldIdentifier(m_AddressName), Address);
            mutableFields.Add(new FieldIdentifier(m_ConfigurationName), Configuration);
            mutableFields.Add(new FieldIdentifier(m_DeviceNameName), DeviceName);
            //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code);

            //build children
            KeyedNodeCollection <NodeBase> mutableChildren =
                new KeyedNodeCollection <NodeBase>();
            //Add Children here: mutableChildren.Add(SomeChild);

            //build node
            NodeDevice Builder = new NodeDevice(
                new ReadOnlyDictionary <FieldIdentifier, FieldBase>(mutableFields),
                new ReadOnlyCollection <NodeBase>(mutableChildren));

            return(Builder);
        }
Esempio n. 2
0
 public NodeDevice SetDeviceName(FieldDeviceName DeviceName)
 {
     if (DeviceName == null)
     {
         throw new ArgumentNullException(m_DeviceNameName);
     }
     return(new NodeDevice(this.SetField(new FieldIdentifier(m_DeviceNameName), DeviceName), ChildCollection));
 }
Esempio n. 3
0
        public static NodeDevice StaticBuild()
        {
            FieldIdentifier code;
            FieldGuid typeId;
            FieldString address;
            FieldBase64 configuration;
            FieldDeviceName deviceName;

            code = new FieldIdentifier(CODE);
            typeId = new FieldGuid(TYPE_ID);
            address = new FieldString(string.Empty);
            configuration = new FieldBase64(string.Empty);
            deviceName = new FieldDeviceName(Resources.Strings.Unknown_Phidget_Name);

            NodeDevice device = NodeDevice.BuildWith(code, typeId, address, configuration, deviceName);

            return device;
        }
Esempio n. 4
0
        public static NodeDevice StaticBuildHelper(string deviceName, int serialNumber, string code, string typeId, 
            int discreteInputs, int discreteOutputs, int analogInputs, int analogOutputs, int stringInputs, int stringOutputs,
            string analogOutputNameOverride, string discreteOutputNameOverride)
        {
            FieldIdentifier c;
            FieldGuid typ;
            FieldString address;
            FieldBase64 configuration;
            FieldDeviceName dName;

            c = new FieldIdentifier(code);
            typ = new FieldGuid(typeId);
            address = new FieldString(serialNumber.ToString());
            configuration = new FieldBase64(string.Empty);
            dName = new FieldDeviceName(deviceName);

            NodeDevice device = NodeDevice.BuildWith(c, typ, address, configuration, dName);

            // Add the inputs
            var inputsMutable = new Collection<NodeDiscreteInput>();
            for (int i = 0; i < discreteInputs; i++)
            {
                inputsMutable.Add(NodeDiscreteInput.BuildWith(
                    new FieldIdentifier(Resources.Strings.Input + i),
                    new FieldString(i.ToString()),
                    new FieldSignalName(Resources.Strings.Input + " " + i)));
            }
            var inputs = new ReadOnlyCollection<NodeDiscreteInput>(inputsMutable);
            device = device.NodeDiscreteInputChildren.Append(inputs);

            var analogInputsMutable = new Collection<NodeAnalogInput>();
            for (int i = 0; i < analogInputs; i++)
            {
                analogInputsMutable.Add(NodeAnalogInput.BuildWith(
                    new FieldIdentifier(Resources.Strings.AnalogInput + i),
                    new FieldString(i.ToString()),
                    new FieldSignalName(Resources.Strings.AnalogInput + " " + i)));
            }
            device = device.NodeAnalogInputChildren.Append(new ReadOnlyCollection<NodeAnalogInput>(analogInputsMutable));

            var stringInputsMutable = new Collection<NodeStringInput>();
            for (int i = 0; i < stringInputs; i++)
            {
                stringInputsMutable.Add(NodeStringInput.BuildWith(
                    new FieldIdentifier(Resources.Strings.StringInput + i),
                    new FieldString(i.ToString()),
                    new FieldSignalName(Resources.Strings.StringInput + " " + i)));
            }
            device = device.NodeStringInputChildren.Append(new ReadOnlyCollection<NodeStringInput>(stringInputsMutable));

            // Add the outputs
            var outputsMutable = new Collection<NodeDiscreteOutput>();
            for (int i = 0; i < discreteOutputs; i++)
            {
                outputsMutable.Add(NodeDiscreteOutput.BuildWith(
                    new FieldIdentifier(Resources.Strings.Output + i),
                    new FieldString(i.ToString()),
                    new FieldSignalName(discreteOutputNameOverride + " " + i)));
            }
            var outputs = new ReadOnlyCollection<NodeDiscreteOutput>(outputsMutable);
            device = device.NodeDiscreteOutputChildren.Append(outputs);

            var analogOutputsMutable = new Collection<NodeAnalogOutput>();
            for (int i = 0; i < analogOutputs; i++)
            {
                analogOutputsMutable.Add(NodeAnalogOutput.BuildWith(
                    new FieldIdentifier(Resources.Strings.AnalogOutput + i),
                    new FieldString(i.ToString()),
                    new FieldSignalName(analogOutputNameOverride + " " + i)));
            }
            device = device.NodeAnalogOutputChildren.Append(new ReadOnlyCollection<NodeAnalogOutput>(analogOutputsMutable));

            var stringOutputsMutable = new Collection<NodeStringOutput>();
            for (int i = 0; i < stringOutputs; i++)
            {
                stringOutputsMutable.Add(NodeStringOutput.BuildWith(
                    new FieldIdentifier(Resources.Strings.StringOutput + i),
                    new FieldString(i.ToString()),
                    new FieldSignalName(Resources.Strings.StringOutput + " " + i)));
            }
            device = device.NodeStringOutputChildren.Append(new ReadOnlyCollection<NodeStringOutput>(stringOutputsMutable));

            return device;
        }
Esempio n. 5
0
 public NodeDevice SetDeviceName(FieldDeviceName DeviceName)
 {
     if (DeviceName == null)
     {
         throw new ArgumentNullException(m_DeviceNameName);
     }
     return new NodeDevice(this.SetField(new FieldIdentifier(m_DeviceNameName), DeviceName), ChildCollection);
 }
Esempio n. 6
0
        public static NodeDevice BuildWith(
            FieldIdentifier Code, FieldGuid TypeId,
            FieldString Address, FieldBase64 Configuration,
            FieldDeviceName DeviceName)
        {
            //build fields
            Dictionary<FieldIdentifier, FieldBase> mutableFields =
                new Dictionary<FieldIdentifier, FieldBase>();
            mutableFields.Add(new FieldIdentifier(m_CodeName), Code);
            mutableFields.Add(new FieldIdentifier(m_TypeIdName), TypeId);
            mutableFields.Add(new FieldIdentifier(m_AddressName), Address);
            mutableFields.Add(new FieldIdentifier(m_ConfigurationName), Configuration);
            mutableFields.Add(new FieldIdentifier(m_DeviceNameName), DeviceName);
            //Add Fields here: mutableFields.Add(new FieldIdentifier(m_CodeName), Code);

            //build children
            KeyedNodeCollection<NodeBase> mutableChildren =
                new KeyedNodeCollection<NodeBase>();
            //Add Children here: mutableChildren.Add(SomeChild);

            //build node
            NodeDevice Builder = new NodeDevice(
                new ReadOnlyDictionary<FieldIdentifier, FieldBase>(mutableFields),
                new ReadOnlyCollection<NodeBase>(mutableChildren));

            return Builder;
        }
        public static NodeDevice StaticBuildHelper(string deviceName, string typeId, Guid instanceId, string code,
            int buttons, int axes, int povhats)
        {
            FieldIdentifier c;
            FieldGuid typ;
            FieldString address;
            FieldBase64 configuration;
            FieldDeviceName dName;

            c = new FieldIdentifier(code);
            typ = new FieldGuid(typeId);
            address = new FieldString(instanceId.ToString());
            configuration = new FieldBase64(string.Empty);
            dName = new FieldDeviceName(deviceName);

            NodeDevice device = NodeDevice.BuildWith(c, typ, address, configuration, dName);

            // Add the inputs
            var inputsMutable = new Collection<NodeDiscreteInput>();
            for (int i = 0; i < buttons; i++)
            {
                int buttonNumber = i + 1;
                inputsMutable.Add(NodeDiscreteInput.BuildWith(
                    new FieldIdentifier(Resources.Strings.Button + buttonNumber),
                    new FieldString(i.ToString()),
                    new FieldSignalName(Resources.Strings.Button + " " + buttonNumber)));
            }
            var inputs = new ReadOnlyCollection<NodeDiscreteInput>(inputsMutable);
            device = device.NodeDiscreteInputChildren.Append(inputs);

            var analogInputsMutable = new Collection<NodeAnalogInput>();
            for (int i = 0; i < axes; i++)
            {
                if (i == 3) break; // only supports up to 3 axes

                int axisNumber = i + 1;
                string axisName =
                    axisNumber == 1 ? "X" :
                    axisNumber == 2 ? "Y" :
                    axisNumber == 3 ? "Z" :
                    null;

                analogInputsMutable.Add(NodeAnalogInput.BuildWith(
                    new FieldIdentifier(axisName),
                    new FieldString(axisName),
                    new FieldSignalName(axisName)));

                string rotationName = "Rotation" + axisName;
                analogInputsMutable.Add(NodeAnalogInput.BuildWith(
                    new FieldIdentifier(rotationName),
                    new FieldString(rotationName),
                    new FieldSignalName(rotationName)));

            }
            for (int i = 0; i < povhats; i++)
            {
                int povNumber = i + 1;
                analogInputsMutable.Add(NodeAnalogInput.BuildWith(
                    new FieldIdentifier(Resources.Strings.PoVHat + povNumber.ToString()),
                    new FieldString(i.ToString()),
                    new FieldSignalName(Resources.Strings.PoVHat + " " + povNumber.ToString())));
            }
            device = device.NodeAnalogInputChildren.Append(new ReadOnlyCollection<NodeAnalogInput>(analogInputsMutable));

            return device;
        }