Beispiel #1
0
        private BlueprintDto EnsureProjectBlueprint(M2MgoCloudAgentConfiguration config, UicProject project)
        {
            string blueprintCode = _projectBlueprintTranslator.GetBlueprintCodeFrom(project);

            BlueprintDto[] searchResult = _apiWrapper.SearchBlueprint(config, _projectTranslator.GetProjectDomain(project), blueprintCode);

            if (searchResult.Count() > 1)
            {
                throw new Exception(String.Format("found more than 1 project blueprints {0} in Domain {1}", _projectTranslator.GetProjectDomain(project),
                                                  blueprintCode));
            }
            if (searchResult.Any())
            {
                BlueprintDto blueprint = _projectBlueprintTranslator.UpdateProjectDomain(searchResult.Single());
                string       result    = _apiWrapper.UpdateBlueprint(config, blueprint);
                _logger.Information("Updateing Blueprint: " + result);
                return(blueprint);
            }
            else
            {
                BlueprintDto projectBlueprintDto = _projectBlueprintTranslator.GetProjectBlueprintDto(project, _projectTranslator.GetProjectDomain(project));
                projectBlueprintDto.PrepareMasterForCreation();

                string result = _apiWrapper.CreateBlueprint(config, _projectTranslator.GetProjectDomain(project), projectBlueprintDto);
                _logger.Information("CreateBlueprint Blueprint: " + result);
                return(_apiWrapper.SearchBlueprint(config, _projectTranslator.GetProjectDomain(project), blueprintCode).Single());
            }
        }
Beispiel #2
0
        internal BlueprintDto GetGatewayBlueprintDefiniton(UicProject project)
        {
            const string name  = "CloudMapper Gateway";
            const string code  = CloudMapperGatewayAnchorBlueprintCode;
            const string label = name;

            var sensors = new List <Sensor>
            {
                new Sensor
                {
                    DataType    = (int)SensorDataType.String,
                    Description = String.Empty,
                    Icon        = String.Empty,
                    Name        = "Debug Channel",
                    SensorKey   = SensorKeyDebug,
                    Units       = String.Empty,
                },
                new Sensor
                {
                    DataType    = (int)SensorDataType.Boolean,
                    Description = String.Empty,
                    Icon        = String.Empty,
                    Name        = "Debug Enabled",
                    SensorKey   = SensorKeyDebugEnabled,
                    Units       = String.Empty,
                },
            };
            var commands = new List <CommandDto>
            {
                new CommandDto
                {
                    Command = "board.debug@on",
                    Name    = CommandKeyDebugOn,
                },
                new CommandDto
                {
                    Command = "board.debug@off",
                    Name    = CommandKeyDebugOff,
                },
            };
            var attributes = new List <Attribute> {
                new Attribute
                {
                    Name = AttributeKeySerialId,
                },
                new Attribute
                {
                    Name = AttributeKeyProjectKey,
                },
                new Attribute
                {
                    Name = AttributeKeyProjectName,
                },
                new Attribute
                {
                    Name = AttributeKeyCustomer,
                },
            };

            return(new BlueprintDto
            {
                Attributes = attributes,
                Commands = commands,
                CreationDate = null,
                Description = null,
                DomainIdentifier = new Identifier
                {
                    ID = _projectTranslator.GetProjectDomain(project)
                },
                IsSelfRegisteringAllowed = true,
                Label = label,
                MaxDevices = 50,
                Code = code,
                Name = name,
                Sensors = sensors,
            });
        }