项目作者: etiennelndr

项目描述 :
CCSDS MO MAL GO SERVICE
高级语言: Go
项目地址: git://github.com/etiennelndr/archiveservice.git
创建时间: 2018-03-09T15:35:09Z
项目社区:https://github.com/etiennelndr/archiveservice

开源协议:MIT License

下载


MAL GO ARCHIVE SERVICE

Introduction

This service is an implementation of the Archive Service described in the CCSDS Recommendation Mission Operations Common Object Model CCSDS 521.1-B-1. It uses the High level MAL GO API available here.

Download this repository

  1. go get github.com/juju/loggo
  2. go get github.com/ccsdsmo/malgo
  3. go get github.com/etiennelndr/archiveservice

Using the Archive Service

If you want to see the Archive Service in action, click here and run this project.

Use of the provider

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Variable to retrieve the error
  4. var err error
  5. // Create the Archive Service
  6. archiveService = archiveService.CreateService().(*ArchiveService)
  7. // Start the providers
  8. err = archiveService.StartProvider("maltcp://127.0.0.1:12400")
  9. if err != nil {
  10. fmt.Println("Error:", err)
  11. }

Use of the consumer

Retrieve

The retrieve operation retrieves a set of objects identified by their object instance identifier. In our service it can be used in that way:

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Create the Archive Service
  4. service := archiveService.CreateService()
  5. archiveService = service.(*ArchiveService)
  6. // Variable that defines the ArchiveService
  7. var objectType = ObjectType{
  8. Area: UShort(2),
  9. Service: UShort(3),
  10. Version: UOctet(1),
  11. Number: UShort(COM_VALUE_OF_SINE_TYPE_SHORT_FORM),
  12. }
  13. var identifierList = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice"), NewIdentifier("test")})
  14. var longList = LongList([]*Long{NewLong(0)})
  15. // Variables to retrieve the return of this function
  16. var archiveDetailsList *ArchiveDetailsList
  17. var elementList ElementList
  18. var errorsList *ServiceError
  19. var err error
  20. // Start the consumer
  21. archiveDetailsList, elementList, errorsList, err = archiveService.Retrieve(consumerURL, providerURL, objectType, identifierList, longList)
  22. // Check errors
  23. if err != nil {
  24. // Do Something
  25. } else if errorsList != nil {
  26. // Do something else
  27. }

Query

The query operation retrieves a set of object instance identifiers, and optionally the object
bodies, from a list of supplied queries. The PROGRESS interaction pattern is used as the
returned set of data may be quite large and this allows it to be split over several MAL
messages. A simple way to use this operation:

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Create the Archive Service
  4. service := archiveService.CreateService()
  5. archiveService = service.(*ArchiveService)
  6. // Create parameters
  7. var boolean = NewBoolean(true)
  8. var objectType = ObjectType{
  9. Area: UShort(2),
  10. Service: UShort(3),
  11. Version: UOctet(1),
  12. Number: UShort(COM_VALUE_OF_SINE_TYPE_SHORT_FORM),
  13. }
  14. archiveQueryList := NewArchiveQueryList(0)
  15. //var domain = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice"), NewIdentifier("test")})
  16. archiveQuery := &ArchiveQuery{
  17. Related: Long(0),
  18. SortOrder: NewBoolean(true),
  19. }
  20. archiveQueryList.AppendElement(archiveQuery)
  21. var queryFilterList *CompositeFilterSetList
  22. // Variables to retrieve the return of this function
  23. var responses []interface{}
  24. var errorsList *ServiceError
  25. var err error
  26. // Start the consumer
  27. responses, errorsList, err = archiveService.Query(consumerURL, providerURL, boolean, objectType, *archiveQueryList, queryFilterList)
  28. // Check errors
  29. if err != nil {
  30. // Do Something
  31. } else if errorsList != nil {
  32. // Do something else
  33. }

Count

The count operation counts the set of objects based on a supplied query.

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Create the Archive Service
  4. service := archiveService.CreateService()
  5. archiveService = service.(*ArchiveService)
  6. var objectType = &ObjectType{
  7. Area: UShort(2),
  8. Service: UShort(3),
  9. Version: UOctet(1),
  10. Number: UShort(COM_VALUE_OF_SINE_TYPE_SHORT_FORM),
  11. }
  12. archiveQueryList := NewArchiveQueryList(0)
  13. var domain = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice"), NewIdentifier("test")})
  14. archiveQuery := &ArchiveQuery{
  15. Domain: &domain,
  16. Related: Long(0),
  17. SortOrder: NewBoolean(true),
  18. }
  19. archiveQueryList.AppendElement(archiveQuery)
  20. var queryFilterList *CompositeFilterSetList
  21. // Variable to retrieve the return of this function
  22. var longList *LongList
  23. var errorsList *ServiceError
  24. var err error
  25. // Start the consumer
  26. longList, errorsList, err = archiveService.Count(consumerURL, providerURL, objectType, archiveQueryList, queryFilterList)
  27. // Check errors
  28. if err != nil {
  29. // Do Something
  30. } else if errorsList != nil {
  31. // Do something else
  32. }

Store

The store operation stores new objects in the archive and causes an ObjectStored event to be
published by the archive.

When new objects are being stored in an archive by a service provider the archive service
provider is capable of allocating an unused object instance identifier for the objects being
stored. The returned object instance identifier should be used by the service provider for
identifying the object instances to its consumer to ensure that only a single object instance
identifier
is used for each object instance.

In our case, this operation can be used in that way:

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Create the Archive Service
  4. service := archiveService.CreateService()
  5. archiveService = service.(*ArchiveService)
  6. // Start the store consumer
  7. // Create parameters
  8. // Object that's going to be stored in the archive
  9. var elementList = NewValueOfSineList(1)
  10. (*elementList)[0] = NewValueOfSine(0)
  11. var boolean = NewBoolean(true)
  12. var objectType = ObjectType{
  13. Area: UShort(2),
  14. Service: UShort(3),
  15. Version: UOctet(1),
  16. Number: UShort(COM_VALUE_OF_SINE_TYPE_SHORT_FORM),
  17. }
  18. var identifierList = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice")})
  19. // Object instance identifier
  20. var objectInstanceIdentifier = *NewLong(81)
  21. // Variables for ArchiveDetailsList
  22. var objectKey = ObjectKey{
  23. Domain: identifierList,
  24. InstId: objectInstanceIdentifier,
  25. }
  26. var objectID = ObjectId{
  27. Type: &objectType,
  28. Key: &objectKey,
  29. }
  30. var objectDetails = ObjectDetails{
  31. Related: NewLong(1),
  32. Source: &objectID,
  33. }
  34. var network = NewIdentifier("network")
  35. var timestamp = NewFineTime(time.Now())
  36. var provider = NewURI("main/start")
  37. var archiveDetailsList = ArchiveDetailsList([]*ArchiveDetails{NewArchiveDetails(objectInstanceIdentifier, objectDetails, network, timestamp, provider)})
  38. // Variable to retrieve the return of this function
  39. var longList *LongList
  40. var err error
  41. var errorsList *ServiceError
  42. // Start the consumer
  43. longList, errorsList, err = archiveService.Store(consumerURL, providerURL, boolean, objectType, identifierList, archiveDetailsList, elementList)
  44. // Check errors
  45. if err != nil {
  46. // Do Something
  47. } else if errorsList != nil {
  48. // Do something else
  49. }

Update

The update operation updates an object (or set of objects) and causes an ObjectUpdated event
to be published by the archive.

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Create the Archive Service
  4. service := archiveService.CreateService()
  5. archiveService = service.(*ArchiveService)
  6. // Start the update consumer
  7. // Create parameters
  8. // ---- ELEMENTLIST ----
  9. // Object that's going to be updated in the archive
  10. var elementList = NewValueOfSineList(1)
  11. (*elementList)[0] = NewValueOfSine(0.5)
  12. // ---- OBJECTTYPE ----
  13. var objectType = ObjectType{
  14. Area: UShort(2),
  15. Service: UShort(3),
  16. Version: UOctet(1),
  17. Number: UShort((*elementList)[0].GetTypeShortForm()),
  18. }
  19. // ---- IDENTIFIERLIST ----
  20. var identifierList = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice"), NewIdentifier("test")})
  21. // Object instance identifier
  22. var objectInstanceIdentifier = *NewLong(1)
  23. // Variables for ArchiveDetailsList
  24. // ---- ARCHIVEDETAILSLIST ----
  25. var objectKey = ObjectKey{
  26. Domain: identifierList,
  27. InstId: objectInstanceIdentifier,
  28. }
  29. var objectID = ObjectId{
  30. Type: &objectType,
  31. Key: &objectKey,
  32. }
  33. var objectDetails = ObjectDetails{
  34. Related: NewLong(1),
  35. Source: &objectID,
  36. }
  37. var network = NewIdentifier("new.network")
  38. var fineTime = NewFineTime(time.Now())
  39. var uri = NewURI("main/start")
  40. var archiveDetailsList = ArchiveDetailsList([]*ArchiveDetails{NewArchiveDetails(objectInstanceIdentifier, objectDetails, network, fineTime, uri)})
  41. // Variable to retrieve the return of this function
  42. var errorsList *ServiceError
  43. var err error
  44. // Start the consumer
  45. errorsList, err = archiveService.Update(consumerURL, providerURL, objectType, identifierList, archiveDetailsList, elementList)
  46. // Check errors
  47. if err != nil {
  48. // Do Something
  49. } else if errorsList != nil {
  50. // Do something else
  51. }

Delete

The delete operation deletes an object (or set of objects) and causes an ObjectDeleted event
to be published by the archive. A simple way to use this operation:

  1. // Variable that defines the ArchiveService
  2. var archiveService *ArchiveService
  3. // Create the Archive Service
  4. service := archiveService.CreateService()
  5. archiveService = service.(*ArchiveService)
  6. var objectType = ObjectType{
  7. Area: UShort(2),
  8. Service: UShort(3),
  9. Version: UOctet(1),
  10. Number: UShort(COM_VALUE_OF_SINE_TYPE_SHORT_FORM),
  11. }
  12. var identifierList = IdentifierList([]*Identifier{NewIdentifier("fr"), NewIdentifier("cnes"), NewIdentifier("archiveservice"), NewIdentifier("test")})
  13. var longList = NewLongList(0)
  14. longList.AppendElement(NewLong(15))
  15. // Variable to retrieve the return of this function
  16. var respLongList *LongList
  17. var errorsList *ServiceError
  18. var err error
  19. // Start the consumer
  20. respLongList, errorsList, err = archiveService.Delete(consumerURL, providerURL, objectType, identifierList, *longL
  21. // Check errors
  22. if err != nil {
  23. // Do Something
  24. } else if errorsList != nil {
  25. // Do something else
  26. }