예제 #1
0
 public GatewayService(M2mgoGatewayProjectWebApiWrapper apiWrapper, ILogger logger, ISerializer serializer, M2MgoProjectTranslator projectTranslator)
 {
     _apiWrapper        = apiWrapper;
     _logger            = logger;
     _serializer        = serializer;
     _projectTranslator = projectTranslator;
 }
예제 #2
0
 public BlueprintService(M2mgoDeviceWebApiWrapper apiWrapper, ILogger logger, M2mgoGatewayBlueprintTranslator m2MgoGatewayBlueprintTranslator, M2MgoProjectBlueprintTranslator projectBlueprintTranslator, M2MgoProjectTranslator projectTranslator, M2mgoGatewayProjectWebApiWrapper gatewayApiWrapper)
 {
     _apiWrapper = apiWrapper;
     _logger     = logger;
     _m2MgoGatewayBlueprintTranslator = m2MgoGatewayBlueprintTranslator;
     _projectBlueprintTranslator      = projectBlueprintTranslator;
     _projectTranslator = projectTranslator;
     _gatewayApiWrapper = gatewayApiWrapper;
 }
        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);
        }