public void Initialize(string serialId, UicProject project, List <EmbeddedDriverModule> edms)
        {
            WebApiRequestExecutor       webApiRequestExecutor  = new WebApiRequestExecutor();
            M2mgoUserTokenWebApiWrapper userTokenWebApiWrapper = new M2mgoUserTokenWebApiWrapper(_serializer, webApiRequestExecutor, _loggerFactory.GetLoggerFor(typeof(M2mgoUserTokenWebApiWrapper)));
            var m2MgoGatewayProjectWebApiWrapper     = new M2mgoGatewayProjectWebApiWrapper(_serializer, _loggerFactory, webApiRequestExecutor, userTokenWebApiWrapper);
            M2MgoProjectTranslator projectTranslator = new M2MgoProjectTranslator();
            var gatewayService = new GatewayService(m2MgoGatewayProjectWebApiWrapper, _loggerFactory.GetLoggerFor(typeof(GatewayService)), _serializer, projectTranslator);

            M2mgoGetwayProjectDto gatewayProject = gatewayService.RegisterProject(_configuration, serialId, project);

            M2mgoDeviceWebApiWrapper        apiWrapper          = new M2mgoDeviceWebApiWrapper(_serializer, webApiRequestExecutor, _loggerFactory.GetLoggerFor(typeof(M2mgoDeviceWebApiWrapper)), userTokenWebApiWrapper);
            M2mgoGatewayBlueprintTranslator blueprintTranslator = new M2mgoGatewayBlueprintTranslator(projectTranslator);

            _m2MgoProjectBlueprintTranslator = new M2MgoProjectBlueprintTranslator(project, edms);
            var blueprintService = new BlueprintService(apiWrapper, _loggerFactory.GetLoggerFor(typeof(BlueprintService)), blueprintTranslator, _m2MgoProjectBlueprintTranslator, projectTranslator, m2MgoGatewayProjectWebApiWrapper);

            _applianceBlueprints = blueprintService.SynchronizeWithCloud(_configuration, serialId, project, gatewayProject);

            _projectDataTopic      = new DataTopic(_applianceBlueprints.ProjectBlueprint.Identifier.ID, serialId);
            _projectAttributeTopic = new AttributeTopic(_applianceBlueprints.ProjectBlueprint.Identifier.ID, serialId);
            _gatewayDataTopic      = new DataTopic(_applianceBlueprints.GatewayBlueprint.Identifier.ID, serialId);
        }
Beispiel #2
0
        public ApplianceBlueprints SynchronizeWithCloud(M2MgoCloudAgentConfiguration config, string serialId, UicProject project, M2mgoGetwayProjectDto m2MgoGetwayProjectDto)
        {
            BlueprintDto gatewayBlueprint = EnsureGatewayBlueprint(config, project);

            EnsureDevice(config, serialId, gatewayBlueprint, m2MgoGetwayProjectDto.Gateway);
            UpdateGatewayAttributes(config, serialId, project, gatewayBlueprint);

            BlueprintDto projectBlueprint = EnsureProjectBlueprint(config, project);

            EnsureDevice(config, serialId, projectBlueprint, m2MgoGetwayProjectDto.Gateway);
            UpdateProjectDeviceAttributes(config, serialId, projectBlueprint);

            SetRelevantDevicesOfGateway(config, m2MgoGetwayProjectDto.Gateway.Identifier.ID, projectBlueprint, serialId);

            return(new ApplianceBlueprints(gatewayBlueprint, projectBlueprint));
        }