예제 #1
0
        private static void SetUp()
        {
            FacadePipe myPipe = new FacadePipe(myConfig.Station[0]);

            myMaster = new FacadeApplicationLayerMaster();
            myFacadeISegmentStatistics = new FacadeISegmentStatistics();

            SegmentTiming();

            myMachine = new SegmentStateMachine(myMaster, parameters, false, myFacadeISegmentStatistics, myTimeList);
            myMachine.ResetCounter();
            myMachine.DisconnectedAfterFailureEntered += new EventHandler(myMachine_DisconnectedAfterFailureEntered);
            FacadeSegment myFacadeSegment   = new FacadeSegment();
            int           myMaxNumberOfTags = int.MaxValue;

            Statistics.ChannelStatistics myChanel  = new Statistics.ChannelStatistics(myConfig.Channels[0]);
            DiagnosticSegment            mySegment = new DiagnosticSegment(myConfig.Segments[0], myChanel);

            myInterface = (new FacadeSegment.FacadePipeInterface(new InterfaceParameters(myConfig.Interfaces[0]), myPipe, mySegment));
            myInterface.ResetCounter();
            FacadeSegment.FacadeDataDescription myDataDescription = new FacadeSegment.FacadeDataDescription(myConfig.DataBlocks[0], ref myMaxNumberOfTags);
            myDataDescription.ResetCounter();
            myPipeDataBlock = new FacadeSegment.FacadePipeInterface.FacadePipeDataBlock(myFacadeSegment, myDataDescription, myInterface);
            myPipeDataBlock.ResetCounter();
        }
예제 #2
0
        public void GoTest()
        {
            FacadeApplicationLayerMaster m_Master = new FacadeApplicationLayerMaster();
            string m_MasterToString  = m_Master.ToString();
            GuardedDataProvider m_gp = new GuardedDataProvider("GoTest", m_Master);
            string m_gpToString      = m_gp.ToString();

            Assert.AreEqual(m_gpToString, m_MasterToString, "ToString error");
            StringAddress m_address = new StringAddress("DummyAddress");

            Assert.IsFalse(m_gp.Connected, "State error");
            m_gp.ConnectReq(m_address);
            Assert.IsTrue(m_gp.Connected, "State error");
            FacadeBlockDescription m_block = new FacadeBlockDescription(int.MaxValue, 100, short.MaxValue);
            IReadValue             m_readVal;

            switch (m_gp.ReadData(m_block, int.MaxValue, out m_readVal, byte.MaxValue))
            {
            case AL_ReadData_Result.ALRes_DatTransferErrr:
            case AL_ReadData_Result.ALRes_DisInd:
                Assert.Fail("incorrect return value from ReadData");
                break;

            case AL_ReadData_Result.ALRes_Success:
                Assert.IsNotNull(m_readVal, "ReadData returned null");
                m_readVal.ReturnEmptyEnvelope();
                break;
            }
            Assert.IsTrue(m_gp.Connected, "State error");
            IWriteValue m_writeVal = m_gp.GetEmptyWriteDataBuffor(m_block, int.MaxValue);

            m_writeVal.WriteValue(int.MaxValue, 0);
            switch (m_gp.WriteData(ref m_writeVal, byte.MaxValue))
            {
            case AL_ReadData_Result.ALRes_DatTransferErrr:
            case AL_ReadData_Result.ALRes_DisInd:
                Assert.Fail("incorrect return value from ReadData");
                break;

            case AL_ReadData_Result.ALRes_Success:
                Assert.IsNull(m_writeVal, "WriteData has not returned the envelope to a pool");
                break;
            }
            Assert.IsTrue(m_gp.Connected, "State error");
            m_gp.DisReq();
            Assert.IsFalse(m_gp.Connected, "State error");
            m_gp.Dispose();
        }