コード例 #1
0
ファイル: InTouchTester.cs プロジェクト: chriswong11/Integram
        public override async Task<TestRepairRequirement> WaitForResponse(TestRepairRequirement req)
        {
            var waitTags = GetWaitResponseTags();
            CancellationTokenSource cts = new CancellationTokenSource();
            var task = OPCService.WaitResponseTags(waitTags, cts.Token);

            if (await Task.WhenAny(task, Task.Delay(waitForResponseTimeout, cts.Token)) == task)
            {
                var result = await task;

                if (result.Status == 1)
                {
                    var ackTags = GetAcknowledgmentTags();
                    OPCService.WriteTags(ackTags);

                    req.TestResult = new TestRepairResult
                    {
                        TestResult = 1,
                        TestStatus = 1,
                        TestResultDetails = new List<TestRepairResultDetail>()
                    };
                    req.Repaired = true;
                    req.Dtm = DateTime.Now;

                    return req;
                }
            }

            throw new HttpResponseException(
                HttpErrorResponse.GetHttpErrorResponse(
                HttpStatusCode.RequestTimeout, "Request Timeout", string.Format("Timeout Has Occured")));
        }
コード例 #2
0
        private List<TestRepairResultDetail> GetTestRepairResult(TestRepairRequirement req, int testResult, int testStatus)
        {
            var repairDefinitions = GetRepairTestDefinitions(req.TestId);

            List<TestRepairResultDetail> testdetails = new List<TestRepairResultDetail>();
            foreach (var test in repairDefinitions)
            {
                var status = string.Empty;
                var repaired = false;

                if ((testResult & (int)Math.Pow(2, test.BitNo)) == Math.Pow(2,test.BitNo)) {
                    status = "PASSED";
                    repaired = true;
                }
                else
                {
                    status = ((testStatus & (int)Math.Pow(2, test.BitNo)) != Math.Pow(2, test.BitNo)) ? "NOT REQUIRED" : "FAILED";
                }

                testdetails.Add(new TestRepairResultDetail
                {
                    BitNo = test.BitNo,
                    Description = test.TestDescription,
                    Result = repaired ? 1 : 0,
                    Status = status,
                });
            }

            return testdetails;
        }