opcuaServer.c.orig 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. /*
  2. ============================================================================
  3. Name : opcuaServer.c
  4. Author :
  5. Version :
  6. Copyright : Your copyright notice
  7. Description :
  8. ============================================================================
  9. */
  10. #include <stdio.h>
  11. #include <stdlib.h>
  12. //#include "opcua_binaryEncDec.h"
  13. #include "opcua_builtInDatatypes.h"
  14. #include "opcua_transportLayer.h"
  15. #include "opcua_types.h"
  16. /*#include <sys/socket.h>
  17. #include <netinet/in.h>
  18. */
  19. int main(void)
  20. {
  21. puts("OPC ua Stack");
  22. //struct BED_ApplicationDescription nStruct;
  23. //UA_String s;
  24. puts("running tests...");
  25. TL_getMessageHeader_test();
  26. TL_getHELMessage_test();
  27. puts("...done");
  28. server_init();
  29. server_run();
  30. return EXIT_SUCCESS;
  31. }
  32. void server_init()
  33. {
  34. puts("starting demo Server");
  35. //call listen
  36. }
  37. void server_run()
  38. {
  39. int server_state = 0;
  40. int recv_data = 0;
  41. int send_data = 1;
  42. int new_client = 2;
  43. int new_request = 3;
  44. while(1)
  45. {
  46. //call recv (nonblocking)
  47. //call TL_getPacketType
  48. //if newData
  49. //
  50. UA_connection connection;
  51. AD_RawMessage *rawMessage;
  52. switch(server_state)
  53. {
  54. recv_data :
  55. {
  56. //call receive function
  57. break;
  58. }
  59. send_data :
  60. {
  61. //call send function
  62. break;
  63. }
  64. new_client :
  65. {
  66. if(connection->transportLayer.connectionState != connectionState_ESTABLISHED)
  67. {
  68. TL_open(connection,rawMessage);
  69. }
  70. /* else
  71. {
  72. SL_open(connection,rawMessage);
  73. }
  74. */
  75. }
  76. new_request :
  77. {
  78. break;
  79. }
  80. }
  81. //if newClient
  82. //TL_processHELMessage(&connection,);
  83. //--------
  84. //call listen
  85. }
  86. }