{"action":"created","comment":{"url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments/226035915","pull_request_review_id":165762526,"id":226035915,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyNjAzNTkxNQ==","diff_hunk":"@@ -16,67 +16,77 @@ namespace Microsoft.Azure.IoTSolutions.DeviceSimulation.SimulationAgent.DeviceCo\n     /// </summary>\n     public class Connect : IDeviceConnectionLogic\n     {\n-        private readonly IDevices devices;\n         private readonly IScriptInterpreter scriptInterpreter;\n         private readonly ILogger log;\n+        private readonly IInstance instance;\n         private string deviceId;\n         private DeviceModel deviceModel;\n-        private IDeviceConnectionActor context;\n+        private IDeviceConnectionActor deviceConnectionActor;\n \n         public Connect(\n-            IDevices devices,\n             IScriptInterpreter scriptInterpreter,\n-            ILogger logger)\n+            ILogger logger,\n+            IInstance instance)\n         {\n-            this.log = logger;\n             this.scriptInterpreter = scriptInterpreter;\n-            this.devices = devices;\n+            this.log = logger;\n+            this.instance = instance;\n         }\n \n-        public async Task SetupAsync(IDeviceConnectionActor context, string deviceId, DeviceModel deviceModel)\n+        public void Init(IDeviceConnectionActor actor, string deviceId, DeviceModel deviceModel)\n         {\n-            this.context = context;\n+            this.instance.InitOnce();\n+\n+            this.deviceConnectionActor = actor;\n             this.deviceId = deviceId;\n             this.deviceModel = deviceModel;\n \n-            // TODO: to be removed once SimulationContext is introduced\n-            await this.devices.InitAsync();\n+            this.instance.InitComplete();\n         }\n \n         public async Task RunAsync()\n         {\n+            this.instance.InitRequired();\n+\n             this.log.Debug(\"Connecting...\", () => new { this.deviceId });\n             var start = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();\n \n             try\n             {\n-                this.context.Client = this.devices.GetClient(this.context.Device, this.deviceModel.Protocol, this.scriptInterpreter);\n+                this.deviceConnectionActor.Client = this.deviceConnectionActor.SimulationContext.Devices.GetClient(","path":"SimulationAgent/DeviceConnection/Connect.cs","position":61,"original_position":61,"commit_id":"e73772545deb4140aee316118aa8b810ed512305","original_commit_id":"e73772545deb4140aee316118aa8b810ed512305","user":{"login":"peterfelts","id":5828480,"node_id":"MDQ6VXNlcjU4Mjg0ODA=","avatar_url":"https://avatars0.githubusercontent.com/u/5828480?v=4","gravatar_id":"","url":"https://api.github.com/users/peterfelts","html_url":"https://github.com/peterfelts","followers_url":"https://api.github.com/users/peterfelts/followers","following_url":"https://api.github.com/users/peterfelts/following{/other_user}","gists_url":"https://api.github.com/users/peterfelts/gists{/gist_id}","starred_url":"https://api.github.com/users/peterfelts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterfelts/subscriptions","organizations_url":"https://api.github.com/users/peterfelts/orgs","repos_url":"https://api.github.com/users/peterfelts/repos","events_url":"https://api.github.com/users/peterfelts/events{/privacy}","received_events_url":"https://api.github.com/users/peterfelts/received_events","type":"User","site_admin":false},"body":"Fixed.","created_at":"2018-10-17T17:59:25Z","updated_at":"2018-10-17T17:59:25Z","html_url":"https://github.com/Azure/device-simulation-dotnet/pull/270#discussion_r226035915","pull_request_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments/226035915"},"html":{"href":"https://github.com/Azure/device-simulation-dotnet/pull/270#discussion_r226035915"},"pull_request":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270"}},"in_reply_to_id":225709141},"pull_request":{"url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270","id":220815468,"node_id":"MDExOlB1bGxSZXF1ZXN0MjIwODE1NDY4","html_url":"https://github.com/Azure/device-simulation-dotnet/pull/270","diff_url":"https://github.com/Azure/device-simulation-dotnet/pull/270.diff","patch_url":"https://github.com/Azure/device-simulation-dotnet/pull/270.patch","issue_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/270","number":270,"state":"open","locked":false,"title":"Integrate SimulationManager","user":{"login":"peterfelts","id":5828480,"node_id":"MDQ6VXNlcjU4Mjg0ODA=","avatar_url":"https://avatars0.githubusercontent.com/u/5828480?v=4","gravatar_id":"","url":"https://api.github.com/users/peterfelts","html_url":"https://github.com/peterfelts","followers_url":"https://api.github.com/users/peterfelts/followers","following_url":"https://api.github.com/users/peterfelts/following{/other_user}","gists_url":"https://api.github.com/users/peterfelts/gists{/gist_id}","starred_url":"https://api.github.com/users/peterfelts/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/peterfelts/subscriptions","organizations_url":"https://api.github.com/users/peterfelts/orgs","repos_url":"https://api.github.com/users/peterfelts/repos","events_url":"https://api.github.com/users/peterfelts/events{/privacy}","received_events_url":"https://api.github.com/users/peterfelts/received_events","type":"User","site_admin":false},"body":"# Description and Motivation <!-- Info & Context so we can review your pull request -->\r\nThis change will integrate the SimulationManager and significantly refactor the SimulationAgent. The SimulationManager will be responsible for, you guessed it, managing individual simulations. There will be one SimulationManager per simulation. With this change, distributed simulations should work. \r\n\r\nI recommend starting reviewing this PR by looking at the simulation agent (SimulationAgent/Agent.cs). The agent has been significantly refactored though, so perhaps you should review it as a completely new file.\r\n\r\n# Change type <!-- [x] in all the boxes that apply -->\r\n\r\n- [ ] Bug fix\r\n- [x] New feature\r\n- [ ] Enhancement\r\n- [ ] Breaking change (breaks backward compatibility)\r\n\r\n**Checklist:**\r\n\r\n- [x] All tests passed\r\n- [x] The code follows the code style and conventions of this project\r\n- [x] The change requires a change to the documentation\r\n- [x] I have updated the documentation accordingly\n\n<!-- Reviewable:start -->\n---\nThis change is [<img src=\"https://reviewable.io/review_button.svg\" height=\"34\" align=\"absmiddle\" alt=\"Reviewable\"/>](https://reviewable.io/reviews/azure/device-simulation-dotnet/270)\n<!-- Reviewable:end -->\n","created_at":"2018-10-05T20:27:00Z","updated_at":"2018-10-17T17:59:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"05214063f11f33e0402561de2b375ac806cf4745","assignee":null,"assignees":[],"requested_reviewers":[{"login":"timlaverty","id":5084013,"node_id":"MDQ6VXNlcjUwODQwMTM=","avatar_url":"https://avatars2.githubusercontent.com/u/5084013?v=4","gravatar_id":"","url":"https://api.github.com/users/timlaverty","html_url":"https://github.com/timlaverty","followers_url":"https://api.github.com/users/timlaverty/followers","following_url":"https://api.github.com/users/timlaverty/following{/other_user}","gists_url":"https://api.github.com/users/timlaverty/gists{/gist_id}","starred_url":"https://api.github.com/users/timlaverty/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timlaverty/subscriptions","organizations_url":"https://api.github.com/users/timlaverty/orgs","repos_url":"https://api.github.com/users/timlaverty/repos","events_url":"https://api.github.com/users/timlaverty/events{/privacy}","received_events_url":"https://api.github.com/users/timlaverty/received_events","type":"User","site_admin":false},{"login":"avanikp","id":32693971,"node_id":"MDQ6VXNlcjMyNjkzOTcx","avatar_url":"https://avatars1.githubusercontent.com/u/32693971?v=4","gravatar_id":"","url":"https://api.github.com/users/avanikp","html_url":"https://github.com/avanikp","followers_url":"https://api.github.com/users/avanikp/followers","following_url":"https://api.github.com/users/avanikp/following{/other_user}","gists_url":"https://api.github.com/users/avanikp/gists{/gist_id}","starred_url":"https://api.github.com/users/avanikp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/avanikp/subscriptions","organizations_url":"https://api.github.com/users/avanikp/orgs","repos_url":"https://api.github.com/users/avanikp/repos","events_url":"https://api.github.com/users/avanikp/events{/privacy}","received_events_url":"https://api.github.com/users/avanikp/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270/commits","review_comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270/comments","review_comment_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/270/comments","statuses_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/e73772545deb4140aee316118aa8b810ed512305","head":{"label":"Azure:pfelts/integrate-simulation-manager","ref":"pfelts/integrate-simulation-manager","sha":"e73772545deb4140aee316118aa8b810ed512305","user":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":89741887,"node_id":"MDEwOlJlcG9zaXRvcnk4OTc0MTg4Nw==","name":"device-simulation-dotnet","full_name":"Azure/device-simulation-dotnet","private":false,"owner":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Azure/device-simulation-dotnet","description":"IoT Simulation service","fork":false,"url":"https://api.github.com/repos/Azure/device-simulation-dotnet","forks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/forks","keys_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/teams","hooks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/hooks","issue_events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/events","assignees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/tags","blobs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/languages","stargazers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/stargazers","contributors_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contributors","subscribers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscribers","subscription_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscription","commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/merges","archive_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/downloads","issues_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/labels{/name}","releases_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/deployments","created_at":"2017-04-28T20:20:08Z","updated_at":"2018-10-12T23:49:32Z","pushed_at":"2018-10-16T23:54:31Z","git_url":"git://github.com/Azure/device-simulation-dotnet.git","ssh_url":"git@github.com:Azure/device-simulation-dotnet.git","clone_url":"https://github.com/Azure/device-simulation-dotnet.git","svn_url":"https://github.com/Azure/device-simulation-dotnet","homepage":"","size":2190,"stargazers_count":32,"watchers_count":32,"language":"C#","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"archived":false,"open_issues_count":82,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":40,"open_issues":82,"watchers":32,"default_branch":"master"}},"base":{"label":"Azure:master","ref":"master","sha":"e4f1c79e694cfbc72a85eecc8ee5dafcc00c5aca","user":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"repo":{"id":89741887,"node_id":"MDEwOlJlcG9zaXRvcnk4OTc0MTg4Nw==","name":"device-simulation-dotnet","full_name":"Azure/device-simulation-dotnet","private":false,"owner":{"login":"Azure","id":6844498,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY4NDQ0OTg=","avatar_url":"https://avatars0.githubusercontent.com/u/6844498?v=4","gravatar_id":"","url":"https://api.github.com/users/Azure","html_url":"https://github.com/Azure","followers_url":"https://api.github.com/users/Azure/followers","following_url":"https://api.github.com/users/Azure/following{/other_user}","gists_url":"https://api.github.com/users/Azure/gists{/gist_id}","starred_url":"https://api.github.com/users/Azure/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Azure/subscriptions","organizations_url":"https://api.github.com/users/Azure/orgs","repos_url":"https://api.github.com/users/Azure/repos","events_url":"https://api.github.com/users/Azure/events{/privacy}","received_events_url":"https://api.github.com/users/Azure/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/Azure/device-simulation-dotnet","description":"IoT Simulation service","fork":false,"url":"https://api.github.com/repos/Azure/device-simulation-dotnet","forks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/forks","keys_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/teams","hooks_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/hooks","issue_events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/events{/number}","events_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/events","assignees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/assignees{/user}","branches_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/branches{/branch}","tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/tags","blobs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/refs{/sha}","trees_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/{sha}","languages_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/languages","stargazers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/stargazers","contributors_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contributors","subscribers_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscribers","subscription_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/subscription","commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/commits{/sha}","git_commits_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/git/commits{/sha}","comments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/comments{/number}","issue_comment_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/comments{/number}","contents_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/contents/{+path}","compare_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/merges","archive_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/downloads","issues_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues{/number}","pulls_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls{/number}","milestones_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/milestones{/number}","notifications_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/labels{/name}","releases_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/releases{/id}","deployments_url":"https://api.github.com/repos/Azure/device-simulation-dotnet/deployments","created_at":"2017-04-28T20:20:08Z","updated_at":"2018-10-12T23:49:32Z","pushed_at":"2018-10-16T23:54:31Z","git_url":"git://github.com/Azure/device-simulation-dotnet.git","ssh_url":"git@github.com:Azure/device-simulation-dotnet.git","clone_url":"https://github.com/Azure/device-simulation-dotnet.git","svn_url":"https://github.com/Azure/device-simulation-dotnet","homepage":"","size":2190,"stargazers_count":32,"watchers_count":32,"language":"C#","has_issues":true,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":40,"mirror_url":null,"archived":false,"open_issues_count":82,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit","node_id":"MDc6TGljZW5zZTEz"},"forks":40,"open_issues":82,"watchers":32,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270"},"html":{"href":"https://github.com/Azure/device-simulation-dotnet/pull/270"},"issue":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/270"},"comments":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/issues/270/comments"},"review_comments":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270/comments"},"review_comment":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/pulls/270/commits"},"statuses":{"href":"https://api.github.com/repos/Azure/device-simulation-dotnet/statuses/e73772545deb4140aee316118aa8b810ed512305"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"peterfelts"}}