Exemplo n.º 1
0
	    private int sampleCompare (tst sample1, tst sample2)
	    {
	        int result;
	
	        if ( (sample1.long_1 == sample2.long_1) &&
	             (sample1.long_2 == sample2.long_2) &&
	             (sample1.long_3 == sample2.long_3) ) {
	            result = C_EQ;
	        } else if ( sample1.long_1 != sample2.long_1 ) {
	            if ( sample1.long_1 < sample2.long_1 ) {
	                result = C_LT;
	            } else {
	                result = C_GT;
	            }
	        } else if ( sample1.long_2 != sample2.long_2 ) {
	            if ( sample1.long_2 < sample2.long_2 ) {
	                result = C_LT;
	            } else {
	                result = C_GT;
	            }
	        } else  {
	            if ( sample1.long_3 < sample2.long_3 ) {
	                result = C_LT;
	            } else {
	                result = C_GT;
	            }
	        }
	
	        return result;
	    }
Exemplo n.º 2
0
	    private void init()
	    {
	        tstTypeSupport typeSupport;
	        string errMsg = "Unknown error";
	        
	        for ( int i = 0; i < MAX_INSTANCE; i++ ) {
	            testData[i] = new tst();
	            testData[i].long_1 = i;
	            testData[i].long_2 = 0;
	            testData[i].long_3 = 0;
	        }
	        initialiseInstanceData();
	
	        
	        /**
	         * @addtogroup group_dds1290
	         *
	         * \b Test \b ID: \b saj_invalid_data_000
	         *
	         * \b Test \b Objectives:
	         *
	         * Create and initialise all required DDS entities
	         *
	         * \b Test \b Procedure:
	         *
	         * \e Action
	         *
	         * The following entities are obtained/created
	         * \arg \c DomainParticipantFactory
	         * \arg \c DomainParticipant with default QoS settings
	         * \arg \c Publisher with default QoS settings
	         * \arg \c Subscriber with default QoS settings
	         * \arg \c The mod::tst type is registered
	         * \arg \c A topic T1 of type tstModule::tst is created with default QoS settings
	         * \arg \c A DataWriter W for T1 with default QoS settings, writer_data_lifecycle.autodispose_unregistered_instances = FALSE
	         * \arg \c A DataReader for T1 with default QoS settings
	         *
	         * \e Result
	         * It is expected that all entities are created/initialized correctly and without any failures. \n
	         * If a failure occurs at any of the above stages, the test fails, this is reported and no further testing is performed
	         */
	        /*- INITIALIZATION ---------------------------------------------------------*/
	        tfw.TestStart ("sacs_sampleInfo_000","SampleInfo","initialization");
	        tfw.TestTitle ("Test SampleInfo initialization.");
	        tfw.TestPurpose ("Test SampleInfo initialization.");
	
	        factory = DomainParticipantFactory.Instance;
	        
	        if(factory == null){
	            errMsg = "DomainParticipantFactory could NOT be resolved";
	            proceed = false;
	        } else {
	            participant = factory.CreateParticipant(domainId);
	
	            if(participant == null){
	                errMsg = "DomainParticipant could NOT be created";
	                proceed = false;
	            } else {
	                typeSupport = new tstTypeSupport();
	
	                result = typeSupport.RegisterType(participant, "tst");
	                if(result == ReturnCode.Ok){
	                    topic = participant.CreateTopic("my_topic", "tst");
	
	                    if(topic != null){
	                        subscriber = participant.CreateSubscriber();
	
	                        if(subscriber != null){
	                            subscriber.GetDefaultDataReaderQos(ref drQos);
	                            
	                            if(drQos != null){
	                                drQos.History.Kind  = HistoryQosPolicyKind.KeepLastHistoryQos;
	                                drQos.History.Depth = MAX_DEPTH;
	                                reader = subscriber.CreateDataReader(topic, drQos) as tstDataReader;
	    
	                                if(reader != null){
	                                    publisher = participant.CreatePublisher();
	    
	                                    if(publisher != null){
	                                        result = publisher.GetDefaultDataWriterQos(ref dwQos);
	                                        if(dwQos != null && result == ReturnCode.Ok){
	                                            dwQos.WriterDataLifecycle.AutodisposeUnregisteredInstances = false;
	                                            writer = publisher.CreateDataWriter(topic, dwQos) as tstDataWriter;
	                                            if(writer == null){
	                                                errMsg = "DataWriter could NOT be created";
	                                                proceed = false;
	                                            }
	                                        } else {
	                                            reportResultCode(result);
	                                            errMsg = "Default DataWriterQos could NOT be retrieved";
	                                            proceed = false;
	                                        }
	                                    } else {
	                                        errMsg = "Publisher could NOT be created";
	                                        proceed = false;
	                                    }
	    
	                                } else {
	                                    errMsg = "DataReader could NOT be created";
	                                    proceed = false;
	                                }
	                            } else {
	                                errMsg = "Default DataReaderQos could not be resolved.";
	                                proceed = false;
	                            }
	                        } else {
	                            errMsg = "Subscriber could NOT be created";
	                            proceed = false;
	                        }
	                    } else {
	                        errMsg = "Topic could NOT be created";
	                        proceed = false;
	                    }
	                } else {
	                    errMsg = "Typesupport NOT loaded into DomainParticipant";
	                    proceed = false;
	                }
	            }
	        }
	        
	        if(proceed == true){
	            tfw.TestResult("Initialization OK", "Initialization OK", TestVerdict.Pass, TestVerdict.Pass);
	            tfw.TestFinish();
	        } else {
	            tfw.TestResult("Initialization OK", errMsg, TestVerdict.Pass, TestVerdict.Fail);
	            tfw.TestFinish();
	        }
	        /*- END OF INITIALIZATION --------------------------------------------------*/
	    }
Exemplo n.º 3
0
	    private bool checkReceivedInstanceSample (tst[] data, SampleInfo[] info, int len)
	    {
	        SampleData sampleData = null;
	        bool noError = true;
	
	        for ( int i = 0; noError && (i < len); i++ ) {
	            int x = data[i].long_1;
	
	            if ( x < MAX_INSTANCE ) {
	                if ( instanceDataList[x].expected != null) {
	                    foreach (SampleData index in instanceDataList[x].expected) {
	                        if (sampleCompare(index.data, data[i]) == C_EQ) {
	                            sampleData = index;
	                            break;
	                        }
	                    }
	                    if ( sampleData != null) {
	                        sampleData.seen = true;
	                        noError = checkSampleInfo(info[i], sampleData);
	                    } else {
	                        noError = false;
	                    }
	                } else {
	                    noError = false;
	                }
	            } else {
	                noError = false;
	            }
	        }
	
	        if ( noError ) {
	            noError = allSamplesReceived();
	        }
	
	        return noError;
	    }
Exemplo n.º 4
0
	    private ReturnCode disposeSample (ItstDataWriter writer, tst data)
	    {
	        ReturnCode result;
	
	        result = writer.Dispose(data, InstanceHandle.Nil);
	
	        if ( result == ReturnCode.Ok ) {
	            markDisposed(data.long_1);
	        }
	        return result;
	    }
Exemplo n.º 5
0
	    private ReturnCode writeSample (ItstDataWriter writer, tst data)
	    {
	        ReturnCode result;
	
	        result = writer.Write(data, InstanceHandle.Nil);
	
	        if ( result == ReturnCode.Ok ) {
	            addSample(data);
	        }
	        return result;
	    }
Exemplo n.º 6
0
	    private void markRead (tst[] data, int len)
	    {
	        for ( int i = 0; i < len; i++ ) {
	            InstanceData instanceData = null;
	            SampleData sampleData = null;
	
	            instanceData = instanceDataList[data[i].long_1];
	
	            instanceData.viewState = ViewStateKind.NotNew;
	
	            foreach (SampleData index in instanceData.samples) {
	                if (sampleCompare(index.data, data[i]) == C_EQ) {
	                    sampleData = index;
	                    break;
	                }
	            }
	            
	            if ( sampleData != null) {
	                sampleData.SampleState = SampleStateKind.Read;
	            }
	        }
	    }
Exemplo n.º 7
0
	    private void addSample (tst data)
	    {
	        InstanceData instanceData;
	        SampleData   sampleData = new SampleData();
	
	        instanceData = instanceDataList[data.long_1];
	
	        sampleData.data = new tst();
	        sampleData.data.long_1 = data.long_1;
	        sampleData.data.long_2 = data.long_2; 
	        sampleData.data.long_3 = data.long_3;
	
	        sampleData.SampleState = SampleStateKind.NotRead;
	
	        if ( instanceData.samples.Count > 0 ) {
	            if ( instanceData.instanceState != InstanceStateKind.Alive ) {
	                instanceData.viewState = ViewStateKind.New;
	            } else {
	                instanceData.viewState = ViewStateKind.NotNew;
	            }
	        }
	
	        instanceData.instanceState = InstanceStateKind.Alive;
	
	        sampleData.DisposedGenerationCount   = instanceData.DisposedGenerationCount;
	        sampleData.NoWritersGenerationCount = instanceData.NoWritersGenerationCount;
	
	        instanceData.numSamples++;
	        if ( instanceData.numSamples > MAX_DEPTH ) {
	            instanceData.samples.RemoveLast();
	            instanceData.numSamples = MAX_DEPTH;
	        }
	        instanceData.samples.AddFirst(sampleData);
	    }