diff --git a/LFtid1056.rar b/LFtid1056.rar deleted file mode 100644 index 966afb3..0000000 Binary files a/LFtid1056.rar and /dev/null differ diff --git a/LFtid1056.zip b/LFtid1056.zip new file mode 100644 index 0000000..5eb149c Binary files /dev/null and b/LFtid1056.zip differ diff --git a/LFtid1056/LFtid1056.vcxproj b/LFtid1056/LFtid1056.vcxproj index 93bdaf4..206e6b8 100644 --- a/LFtid1056/LFtid1056.vcxproj +++ b/LFtid1056/LFtid1056.vcxproj @@ -86,6 +86,9 @@ + + + @@ -267,6 +270,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -299,23 +339,263 @@ + + - $(RemoteRootDir)/cloudfront/code;$(RemoteRootDir)/cloudfront/code/nlohmann;$(RemoteRootDir)/cloudfront/code/curl;$(RemoteRootDir)/cloudfront/code/log4cplus;$(RemoteRootDir)/cloudfront/code/rocketmq;$(RemoteRootDir)/lib/libuv-v1.51.0/include;$(RemoteRootDir);D:\Git代码\frontlinux\LFtid1056\cloudfront\code;D:\Git代码\frontlinux\LFtid1056;D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include;D:\Git代码\frontlinux\LFtid1056\cloudfront\code\curl;D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus;D:\Git代码\frontlinux\LFtid1056\cloudfront\code\nlohmann;D:\Git代码\frontlinux\LFtid1056\cloudfront\code\rocketmq;./cloudfront/code;./cloudfront/code/nlohmann;./cloudfront/code/curl;./cloudfront/code/log4cplus;./cloudfront/code/rocketmq;./lib/libuv-v1.51.0/include;.;%(AdditionalIncludeDirectories) + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) -std=c++11 -O2 -static-libstdc++ -static-libgcc -pthread %(AdditionalOptions) - D:\Git代码\frontlinux;D:\Git代码\frontlinux\LFtid1056\cloudfront\lib;$(RemoteRootDir)/cloudfront/lib;$(RemoteRootDir);/usr/lib64;/usr/local/lib;D:\Git代码\frontlinux\LFtid1056;./cloudfront/lib;./usr/lib64;./usr/local/lib;%(AdditionalLibraryDirectories) + /root/projects/LFtid1056/pqdif/lib uv;pthread;dl;rt;stdc++fs;z;%(LibraryDependencies) - /root/projects/LFtid1056/cloudfront/lib/librocketmq.a;/root/projects/LFtid1056/cloudfront/lib/libcurl.so;/root/projects/LFtid1056/cloudfront/lib/libssl.so;/root/projects/LFtid1056/cloudfront/lib/libcrypto.so;/root/projects/LFtid1056/cloudfront/lib/liblog4cplus.so;/root/projects/LFtid1056/libuv.a;%(AdditionalDependencies) - -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + + + + $(RemoteRootDir); +$(RemoteRootDir)/cloudfront/code; +$(RemoteRootDir)/cloudfront/code/log4cplus; +$(RemoteRootDir)/cloudfront/code/log4cplus/include; +$(RemoteRootDir)/lib/libuv-v1.51.0/include; +$(RemoteRootDir)/pqdif; +$(RemoteRootDir)/pqdif/include; +D:\Git代码\frontlinux\LFtid1056; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus; +D:\Git代码\frontlinux\LFtid1056\cloudfront\code\log4cplus\include; +D:\Git代码\frontlinux\LFtid1056\lib\libuv-v1.51.0\include; +D:\Git代码\frontlinux\LFtid1056\pqdif; +D:\Git代码\frontlinux\LFtid1056\pqdif\include; +.; +./cloudfront/code; +./cloudfront/code/log4cplus; +./cloudfront/code/log4cplus/include; +./lib/libuv-v1.51.0/include; +./pqdif; +./pqdif/include; +%(AdditionalIncludeDirectories) + + + /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a;/root/projects/LFtid1056/pqdif/lib/libz.a;%(AdditionalDependencies) + -Wl,-rpath=/root/projects/LFtid1056/cloudfront/lib -Wl,--start-group /root/projects/LFtid1056/pqdif/lib/libpqdiflib.a /root/projects/LFtid1056/pqdif/lib/libz.a -Wl,--end-group %(AdditionalOptions) + /root/projects/LFtid1056/pqdif/lib + + \ No newline at end of file diff --git a/LFtid1056/LFtid1056.vcxproj.filters b/LFtid1056/LFtid1056.vcxproj.filters index 96eaa06..4ac9a20 100644 --- a/LFtid1056/LFtid1056.vcxproj.filters +++ b/LFtid1056/LFtid1056.vcxproj.filters @@ -26,6 +26,13 @@ cloudfront\code + + pqdif + + + pqdif\include + + @@ -559,6 +566,115 @@ cloudfront\code\log4cplus\thread\impl + + pqdif + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + + pqdif\include + + @@ -633,6 +749,15 @@ {ca2cfaa3-ac76-42f8-a17f-67b4f693b719} + + {d602780e-e7fa-4253-b532-afd407583f88} + + + {0e3fb7c4-4107-4518-b2ed-857f8c659fa0} + + + {721d48b7-af7b-4e48-84d2-21220c6534c3} + @@ -714,5 +839,11 @@ cloudfront\lib + + pqdif\lib + + + pqdif\lib + \ No newline at end of file diff --git a/LFtid1056/build.sh b/LFtid1056/build.sh index 6be6c39..743a70a 100644 --- a/LFtid1056/build.sh +++ b/LFtid1056/build.sh @@ -19,7 +19,10 @@ $SRC_DIR/tinyxml2.cpp \ ./client2.cpp \ ./dealMsg.cpp \ ./main_thread.cpp \ -./PQSMsg.cpp " +./PQSMsg.cpp \ +./pqdif_thread_processor.cpp \ +./pqdif/PQDIF.cpp \ +./pqdif/include/cjson.c " INCLUDE_DIRS="-I$SRC_DIR \ -I$SRC_DIR/nlohmann \ @@ -28,7 +31,9 @@ INCLUDE_DIRS="-I$SRC_DIR \ -I$SRC_DIR/rocketmq \ -I$SRC_DIR \ -I./lib/libuv-v1.51.0/include \ --I. " +-I./pqdif \ +-I./pqdif/include \ +-I. " LIB_DIRS="-L$LIB_DIR -L/usr/lib64 -L/usr/local/lib" @@ -36,6 +41,8 @@ LIBS="./cloudfront/lib/libcurl.so \ ./cloudfront/lib/libssl.so \ ./cloudfront/lib/libcrypto.so \ ./cloudfront/lib/liblog4cplus.so \ +./pqdif/lib/libpqdiflib.a \ +./pqdif/lib/libz.a \ -lpthread -ldl -lrt \ -lstdc++fs \ -lz \ diff --git a/LFtid1056/main_thread.cpp b/LFtid1056/main_thread.cpp index af43e85..624a965 100644 --- a/LFtid1056/main_thread.cpp +++ b/LFtid1056/main_thread.cpp @@ -7,6 +7,7 @@ #include "client2.h" #include "cloudfront/code/interface.h" +#include "pqdif_thread_processor.h" #include #include #include @@ -35,7 +36,7 @@ typedef struct { #endif extern std::atomic INITFLAG;//̨˵ȳʼɱ־ -//extern void cleanup_args(ThreadArgs* args); +//extern void cleanup_args(ThreadArgs* args);00:B7:8D:A8:00:D6 00:B7:8D:00:A9:03 void init_daemon(void) { @@ -66,53 +67,9 @@ void init_daemon(void) thread_info_t thread_info[THREAD_CONNECTIONS]; // ߳Ϣ pthread_mutex_t global_lock = PTHREAD_MUTEX_INITIALIZER; // ȫֻ extern SafeMessageQueue message_queue; -// ɲװ -std::vector generate_test_devices(int count) { - std::vector devices; - - for (int i = 1; i <= count; ++i) { - // װID - std::string dev_id = "D" + std::to_string(1000 + i).substr(1); // D001, D002, ..., D100 - std::string dev_name = "Device " + std::to_string(i); - - // ɲ - std::vector points = { - { - "P" + dev_id.substr(1) + "01", // ID P00101 - "Voltage " + dev_name, - dev_id, - 1, - 0.0, // ѹֵ - 0.0, - 100.0, - 80.0 - }, - { - "P" + dev_id.substr(1) + "02", // ID P00102 - "Current " + dev_name, - dev_id, - 2, - 0.0, // ֵ - 0.0, - 20.0, - 15.0 - } - }; - - // װ - devices.push_back({ - dev_id, - dev_name, - (i % 2 == 0) ? "Model-X" : "Model-Y", // ʹͺ - "00-B7-8D-A8-00-D6", // MACַ - 1, // ״̬ (1=) - points - }); - } - - return devices; -} +bool PQD_FLAG = false;//pqd߳־ ߳رй߳ ⲿ +//̨˴ӡ void PrintDevices(const std::vector& devices) { std::cout << "==== Devices List (" << devices.size() << ") ====\n"; for (const auto& dev : devices) { @@ -139,7 +96,7 @@ void PrintDevices(const std::vector& devices) { } } -/* ̹߳ 0߳*/ +/* ̹߳ 1߳*/ /* ͻӹ̺߳*/ void* client_manager_thread(void* arg) { int index = *(int*)arg; @@ -171,9 +128,6 @@ void* client_manager_thread(void* arg) { // } //}; - // 100װ - //std::vector test_devices = generate_test_devices(100); - //lnk̨˶ȡ豸 std::vector devices = GenerateDeviceInfoFromLedger(terminal_devlist);//lnk @@ -192,7 +146,7 @@ void* client_manager_thread(void* arg) { pthread_mutex_unlock(&thread_info[index].lock); return NULL; } -/* ̹߳ 1߳*/ +/* ̹߳ 2߳*/ /* Ϣ̺߳ */ void* message_processor_thread(void* arg) { int index = *(int*)arg; @@ -230,6 +184,39 @@ void* message_processor_thread(void* arg) { pthread_mutex_unlock(&thread_info[index].lock); return NULL; } +/* ̹߳ 3߳*/ +/* PQDIF̺߳*/ +void* pqd_thread(void* arg) +{ + int index = *(int*)arg; + free(arg); + + pthread_mutex_lock(&thread_info[index].lock); + printf("PQDIF Thread %d started\n", index); + thread_info[index].state = THREAD_RUNNING; + pthread_mutex_unlock(&thread_info[index].lock); + + try + { + // PQDIF ɨ߳ + RunPqdifScanLoop(); + } + catch (const std::exception& ex) + { + printf("PQDIF Thread %d exception: %s\n", index, ex.what()); + } + catch (...) + { + printf("PQDIF Thread %d exception: unknown\n", index); + } + + pthread_mutex_lock(&thread_info[index].lock); + thread_info[index].state = THREAD_STOPPED; + printf("PQDIF Thread %d stopped\n", index); + pthread_mutex_unlock(&thread_info[index].lock); + return NULL; +} + /* ߳ */ void restart_thread(int index) { @@ -270,7 +257,7 @@ void restart_thread(int index) { thread_info[index].state = THREAD_CRASHED; pthread_mutex_unlock(&global_lock); } - } else if (index == 1) { + } else if (index == 1 && !PQD_FLAG) { // ͻ˹߳ int* new_index = (int*)malloc(sizeof(int)); if (!new_index) { @@ -282,15 +269,14 @@ void restart_thread(int index) { } *new_index = index; - if (pthread_create(&thread_info[index].tid, NULL, - client_manager_thread, new_index) != 0) { + if (pthread_create(&thread_info[index].tid, NULL,client_manager_thread, new_index) != 0) { pthread_mutex_lock(&global_lock); printf("Failed to restart client manager thread %d\n", index); thread_info[index].state = THREAD_CRASHED; pthread_mutex_unlock(&global_lock); free(new_index); // ʧܲԼ freeɹʱ߳ free } - } else if (index == 2) { + } else if (index == 2 && !PQD_FLAG) { // Ϣ߳ int* new_index = (int*)malloc(sizeof(int)); if (!new_index) { @@ -302,61 +288,36 @@ void restart_thread(int index) { } *new_index = index; - if (pthread_create(&thread_info[index].tid, NULL, - message_processor_thread, new_index) != 0) { + if (pthread_create(&thread_info[index].tid, NULL,message_processor_thread, new_index) != 0) { pthread_mutex_lock(&global_lock); printf("Failed to restart message processor thread %d\n", index); thread_info[index].state = THREAD_CRASHED; pthread_mutex_unlock(&global_lock); free(new_index); } + } else if(index == 3 && PQD_FLAG){ + //PQDIF߳ ๤̲߳ + int* new_index = (int*)malloc(sizeof(int)); + if (!new_index) { + pthread_mutex_lock(&global_lock); + printf("Failed to malloc for message processor thread %d\n", index); + thread_info[index].state = THREAD_CRASHED; + pthread_mutex_unlock(&global_lock); + return; + } + *new_index = index; + + if (pthread_create(&thread_info[index].tid, NULL, pqd_thread, new_index) != 0) { + pthread_mutex_lock(&global_lock); + printf("Failed to restart message processor thread %d\n", index); + thread_info[index].state = THREAD_CRASHED; + pthread_mutex_unlock(&global_lock); + free(new_index); + } + } else { // ߳ݲ - } - - /*// ߳ - int* new_index = (int*)malloc(sizeof(int)); - *new_index = index; - - if (index == 1) { - // ͻ˹߳ - if (pthread_create(&thread_info[index].tid, NULL, client_manager_thread, new_index) != 0) { - pthread_mutex_lock(&global_lock); - printf("Failed to restart client manager thread %d\n", index); - thread_info[index].state = THREAD_CRASHED; - pthread_mutex_unlock(&global_lock); - free(new_index); - } - } - else if (index == 2) { - // Ϣ߳ - if (pthread_create(&thread_info[index].tid, NULL, message_processor_thread, new_index) != 0) { - pthread_mutex_lock(&global_lock); - printf("Failed to restart message processor thread %d\n", index); - thread_info[index].state = THREAD_CRASHED; - pthread_mutex_unlock(&global_lock); - free(new_index); - } - } - else if (index == 0) { - // ӿڣmq - //char* argv[] = { (char*)new_index };//Ҫ̺Ų - // ThreadArgs* args = new ThreadArgs{1, argv}; - if (pthread_create(&thread_info[index].tid, NULL, cloudfrontthread, new_index) != 0) { - pthread_mutex_lock(&global_lock); - printf("Failed to restart message processor thread %d\n", index); - thread_info[index].state = THREAD_CRASHED; - pthread_mutex_unlock(&global_lock); - //delete args; // ߳ûɹֶͷ - free(new_index); - } - } - else { - // ߳ - // ΪգʵӦп߳ - }*/ - } /* ̴߳ */ @@ -364,16 +325,6 @@ int is_thread_alive(pthread_t tid) { return pthread_tryjoin_np(tid, NULL) == EBUSY; // EBUSYʾ߳ } -//lnk -/*ThreadArgs* make_thread_args_from_strs(const std::vector& args_vec) { - char** argv = new char*[args_vec.size() + 1]; // һ nullptr β - for (size_t i = 0; i < args_vec.size(); ++i) { - argv[i] = strdup(args_vec[i].c_str()); // strdup malloc - } - argv[args_vec.size()] = nullptr; - return new ThreadArgs{static_cast(args_vec.size()), argv}; -}*/ - /* */ int main(int argc ,char** argv) {//Ӳ if(!parse_param(argc,argv)){ @@ -407,29 +358,26 @@ int main(int argc ,char** argv) {// int* index = (int*)malloc(sizeof(int)); *index = i; - if (i == 1) { + if (i == 1 && !PQD_FLAG) { // ͻ˹߳ - if (pthread_create(&thread_info[i].tid, NULL, client_manager_thread, index) != 0) { + if (pthread_create(&thread_info[i].tid, NULL, client_manager_thread, index) != 0 ) { printf("Failed to create client manager thread %d\n", i); free(index); } } - else if (i == 2) { + else if (i == 2 && !PQD_FLAG) { // Ϣ߳ - if (pthread_create(&thread_info[i].tid, NULL, message_processor_thread, index) != 0) { + if (pthread_create(&thread_info[i].tid, NULL, message_processor_thread, index) != 0 ) { printf("Failed to create message processor thread %d\n", i); free(index); } } - else if (i == 3){ - /*//ӿںmq - char* argv[] = { (char*)index };//Ҫ̺Ų - ThreadArgs* args = new ThreadArgs{1, argv}; - if (pthread_create(&thread_info[i].tid, NULL, cloudfrontthread, args) != 0) { - printf("Failed to create message processor thread %d\n", i); - delete args; // ߳ûɹֶͷ + else if (i == 3 && PQD_FLAG){ + //PQDIF߳ ʱ๤ֹ߳ͣ + if (pthread_create(&thread_info[i].tid, NULL, pqd_thread, index) != 0) { + printf("Failed to create pqd_thread %d\n", i); free(index); - }*/ + } } else { // ߳ @@ -465,59 +413,12 @@ int main(int argc ,char** argv) {// } } - /*// - std::vector points2 = { - {"P101", "Generator Output", "D002",1 ,1, 1, 1, 1,"0.38k",0} - }; - //00B78DA800D6 00-B7-8D-01-79-06 00-B7-8D-A8-00-D6 - // װб - std::vector devices = { - { - "D002", "Backup Device", "Model-Y", "00-B7-8D-A8-00-D6", - 1, points2,true - } - };*/ - - // - //std::vector points1 = { - // {"P001", "Main Voltage", "D001",1 ,1, 1, 1, 1,"0.38k",0}, - // {"P002", "Backup Voltage", "D001",2 ,1, 1, 1, 1,"0.38k",0} - //}; - //std::vector points2 = { - // {"P003", "Main Voltage", "D002",1 ,1, 1, 1, 1,"0.38k",0}, - // {"P004", "Backup Voltage", "D002",2 ,1, 1, 1, 1,"0.38k",0} - //}; - ////00B78DA800D6 00-B7-8D-01-79-06 00-B7-8D-A8-00-D6 00-B7-8D-01-71-09 00-B7-8D-01-88-7f - //// װб - //std::vector devices = { - // { - // "D001", "Primary Device", "Model-X", "00-B7-8D-01-88-7f", - // 1, points1,true - // }, - // { - // "D002", "Primary Device1", "Model-X1", "00-B7-8D-01-71-09", - // 1, points2,true - // } - //}; - // socket״̬ static int queue_monitor = 0; static bool flag = false; - //static int count = 3; - if (++queue_monitor >= 60) { // һ豸 + if (++queue_monitor >= 60) { printf("Message queue size: %zu\n", message_queue.size()); queue_monitor = 0; - /*if (flag) { - flag = false; - for (const auto& device : devices) { - ClientManager::instance().add_device(device); - } - } - else { - flag = true; - ClientManager::instance().remove_device("D001"); - ClientManager::instance().remove_device("D002"); - }*/ } } diff --git a/LFtid1056/pqdif/PQDIF.cpp b/LFtid1056/pqdif/PQDIF.cpp new file mode 100644 index 0000000..6760d68 --- /dev/null +++ b/LFtid1056/pqdif/PQDIF.cpp @@ -0,0 +1,1562 @@ +#include "PQDIF.h" +#include "pqdsupport.h" +#include "cjson.h" +#include +#include +#include +#include +#include + +CPQDIF::CPQDIF() +{ + // Init + m_percont = (CPQDIF_PC_FlatFile *)theFactory.NewPersistController(PFPC_FlatFile); +} + +CPQDIF::~CPQDIF() +{ + // Destroy + delete m_percont; +} + +void CPQDIF::GetTime(DATE dt, time_t* tm) +{ + *tm = (time_t)((double)(dt - EXCEL_DAYCOUNT_ADJUST + 1) * (double)SECONDS_PER_DAY - 8 * 60 * 60);//EXCEL_DAYCOUNT_ADJUSTΪ19701900 8*60*60ΪUTCʱ + +} + +void CPQDIF::put_FlatFileName(string strFileName) +{ + // // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + m_percont->SetFileName(strFileName.c_str()); + +} + +bool CPQDIF::Read() +{ + // QT Ŀ ReadHeaders() int ״̬ + // 0 ʾɹʾʧ + int rc = m_percont->ReadHeaders(); + +#ifdef __linux__ + printf("[PQDIF] ReadHeaders rc=%d\n", rc); +#endif + + return (rc == 0); +} + +bool CPQDIF::Close() +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + return New(); +} + +bool CPQDIF::New() +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + bool ret = false; + // Destroy & re-create + if (m_percont) + delete m_percont; + + m_percont = (CPQDIF_PC_FlatFile *)theFactory.NewPersistController(PFPC_FlatFile); + + if (m_percont) + ret = true; + else + ret = false; + + return ret; +} + +long CPQDIF::RecordGetCount() +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + return (long)m_percont->GetRecordCount(); + +} + + +bool CPQDIF::RecordGetInfo +( + long index, + GUID * tagRecordType, + string & nameRecordType +) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + + CPQDIFRecord * prec; + GUID tagRecord; + string nameTag; + + try + { + prec = m_percont->GetRecord(index); + if (prec) + { + //ASSERT_VALID(prec); + + // Get header info + prec->HeaderGetTag(tagRecord); + + // Return the data... + // The GUID itself + *tagRecordType=tagRecord; + + // The GUID name + nameTag = theInfo.GetNameOfTag(tagRecord); + nameRecordType=nameTag; + + + status = true; + } + } + // catch( ... ) + catch (...) + { + // // e->Delete(); + status = false; + } + + return status; +} + +bool CPQDIF::RecordRequestObservation(long index, long * pRecordObserv) +{ + + bool status = false; + CPQDIFRecord * precBase; + CPQDIFRecord * precCurrent = NULL; + CPQDIFRecord * precDS = NULL; + CPQDIFRecord * precSett = NULL; + CPQDIF_R_Observation * pobs = NULL; + + GUID tagRecord; + long idxRec; + + try + { + // Find the observation and associated data source + precBase = m_percont->GetRecordFull(index); + if (precBase) + { + // Is this an observation? + precBase->HeaderGetTag(tagRecord); + if (PQDIF_IsEqualGUID(tagRecord, tagRecObservation)) + { + // Find its data source... + // Search backward through the record list. + for (idxRec = index - 1; idxRec >= 0; idxRec--) + { + + // Are we still looking for the DS? + if (!precDS) + { + precCurrent = m_percont->GetRecord(idxRec); + precCurrent->HeaderGetTag(tagRecord); + if (PQDIF_IsEqualGUID(tagRecord, tagRecDataSource)) + { + // Found it! + precDS = m_percont->GetRecordFull(idxRec); + status = true; + // We're cool even if we just find this one. We should break at this point, + // because we won't find any valid settings records *before* it! + break; + } + } + + // Are we still looking for the settings? + if (!precSett) + { + precCurrent = m_percont->GetRecord(idxRec); + precCurrent->HeaderGetTag(tagRecord); + if (PQDIF_IsEqualGUID(tagRecord, tagRecMonitorSettings)) + { + // Found it! + precSett = m_percont->GetRecordFull(idxRec); + // precSett is not required, so we don't change + // the value of status. + } + } + } // for( records ) + } + } // if( found obs record ) + + if (status && precBase && precDS) + { + pobs = theFactory.NewObservationWrapper2(precBase, precDS, precSett); + if (pobs) + { + *pRecordObserv = (long)pobs; + status = true; + } + } + else + { + if (precBase) + { + pobs = theFactory.NewObservationWrapper2(precBase, precDS, precSett); + if (pobs) + { + *pRecordObserv = (long)pobs; + status = true; + } + } + } + } + catch (...) + { + // e->Delete(); + status = false; + } + + return status; +} + + +bool CPQDIF::ObservationGetInfo(long pRecordObserv, DATE& timeStart, string& name, long& countChannels) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + CPQDIF_R_Observation * pobs; + TIMESTAMPPQDIF timeStartLocal; + TIMESTAMPPQDIF timeCreateLocal; + // string nameLocal; + string nameLocal; + + countChannels = 0; + timeStart = -1; + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + // Get channel count + countChannels = pobs->GetCountChannels(); + + // Get time & name + status = pobs->GetInfo(timeStartLocal, timeCreateLocal, nameLocal); + + // Transfer info over + if (status) + { + status = SetDateFromTimeStamp(timeStart, timeStartLocal); + //status = theSupport.SetDateFromTimeStamp( *timeCreate, timeCreateLocal ); + + name = nameLocal; + } + + } + + + } + catch (...) + { + // e->Delete(); + status = false; + } + + + return status; +} + +bool CPQDIF::ObservationGetTriggerInfo(long pRecordObserv, long * idTriggerMethod, DATE * timeTriggered) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + CPQDIF_R_Observation * pobs; + + UINT4 idTriggerMethodLocal; + CPQDIF_E_Vector * pvectTriggerChanIdx = NULL; + TIMESTAMPPQDIF timeTriggeredLocal; + + *idTriggerMethod = -1; + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + status = pobs->GetTriggerInfo(idTriggerMethodLocal, &pvectTriggerChanIdx, timeTriggeredLocal); + if (status) + { + status = SetDateFromTimeStamp(*timeTriggered, timeTriggeredLocal); + } + + // Copy this one anyway... + *idTriggerMethod = (long)idTriggerMethodLocal; + } + + + } + catch (...) + { + // e->Delete(); + status = false; + } + + return status; +} + +bool CPQDIF::ObservationGetChannelInfo(long pRecordObserv, long idxChannel, string &name, long * countSeries) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + CPQDIF_R_Observation * pobs; + + string nameLocal; + UINT4 idPhaseLocal; + GUID idQuantityTypeLocal; + UINT4 idQuantityMeasuredLocal; + + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + // Make sure we're in the right range. + if (idxChannel >= 0 && idxChannel < pobs->GetCountChannels()) + { + *countSeries = pobs->GetCountSeries(idxChannel); + + // Get full channel info + status = pobs->GetChannelInfo(idxChannel, nameLocal, idPhaseLocal, idQuantityTypeLocal, idQuantityMeasuredLocal); + if (status) + { + name = nameLocal; + } + } + } + + + } + catch (...) + { + // e->Delete(); + status = false; + } + + + return status; +} + +bool CPQDIF::ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long idxSeries, long * idQuantityUnits, GUID * idQuantityCharacteristic, GUID * idValueType) +{ + bool status = false; + CPQDIF_R_Observation * pobs; + + UINT4 idQuantityUnitsLocal; + GUID idValueTypeLocal; + GUID idQuantityCharacteristicLocal; + + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + status = pobs->GetSeriesInfo(idxChannel, idxSeries, idQuantityUnitsLocal, idQuantityCharacteristicLocal, idValueTypeLocal); + if (status) + { + // Translate information + *idQuantityUnits = (long)idQuantityUnitsLocal; + *idValueType=idValueTypeLocal; + *idQuantityCharacteristic=idQuantityCharacteristicLocal; + } + } + + + } + catch (...) + { + // e->Delete(); + status = false; + } + + return status; +} + +//עҪdouble* Ϊڲ̬ڴ棬ʹҪͷ +bool CPQDIF::ObservationGetSeriesData(long pRecordObserv, long idxChannel, long idxSeries, double ** values,long* varCount) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + CPQDIF_R_Observation * pobs; + double * pvalues; + long countPoints; + + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + pvalues = pobs->NewResolvedSeries(idxChannel, idxSeries, countPoints); + if (pvalues) + { + *values= pvalues; + status = true; + *varCount = countPoints; + //delete[] pvalues; + } + } + + + } + catch (...) + { + // e->Delete(); + status = false; + } + + return status; +} + +bool CPQDIF::ObservationGetChannelFreq(long pRecObs, long idxChannel, double * freq) +{ + bool status = false; + + CPQDIF_R_Observation * pobs; + + try + { + pobs = ValidateObservation(pRecObs); + if (pobs) + { + CPQDIF_E_Collection * pcol = pobs->GetOneChannel(idxChannel); + + if (pcol) + { + CPQDIF_E_Scalar * psc = pobs->FindScalarInCollection(pcol, tagChannelFrequency); + if (psc) + { + double val; + psc->GetValueREAL8(val); + if (freq) + { + *freq = val; + status = true; + } + } + } + } + } + catch (...) + { + // e->Delete(); + status = false; + } + + return status; +} + +bool CPQDIF::ObservationGetChannelGroupID(long pRecObs, long idxChannel, int *GroupID) +{ + + bool status = false; + + CPQDIF_R_Observation * pobs; + + try + { + pobs = ValidateObservation(pRecObs); + if (pobs) + { + CPQDIF_E_Collection * pcol = pobs->GetOneChannel(idxChannel); + + if (pcol) + { + CPQDIF_E_Scalar * psc = pobs->FindScalarInCollection(pcol, tagChannelGroupID); + if (psc) + { + INT2 val = 0; + bool bOk = psc->GetValueINT2(val); + if (bOk == true) + { + if (GroupID) + { + *GroupID = val; + status = true; + } + } + else + { + UINT2 val = 0; + psc->GetValueUINT2(val); + if (GroupID) + { + *GroupID = val; + status = true; + } + } + } + } + } + } + catch (...) + { + // e->Delete(); + status = false; + } + + + return status; +} + + +bool CPQDIF::ObservationGetSeriesPhasicType(long pRecordObserv, long idxChannel, long idxSeries, long *valuetypes) +{ + + bool status = false; + CPQDIF_R_Observation * pobs; + + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + long lvalue = 0; + status = pobs->GetSeriesBaseType(idxChannel, idxSeries, lvalue); + if (status) + *valuetypes = lvalue; + + } + + + } + catch (...) + { + // e->Delete(); + status = false; + } + + return status; +} + + +bool CPQDIF::ObservationGetSeriesScale(long pRecObs, long idxChannel, long idxSeries, double * scale, double * offset) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + + CPQDIF_R_Observation * pobs; + + try + { + pobs = ValidateObservation(pRecObs); + if (pobs) + { + status = pobs->GetSeriesScale(idxChannel, idxSeries, *scale, *offset); + } + } + catch (...) + { + // e->Delete(); + status = false; + } + + + return status; +} + + +bool CPQDIF::RecordReleaseObservation(long pRecordObserv) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + bool status = false; + CPQDIF_R_Observation * pobs; + + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + delete pobs; + status = true; + } + + return status; +} +//protected + +bool CPQDIF::SetDateFromTimeStamp(DATE& date, const TIMESTAMPPQDIF& ts) +{ + date = (double)ts.day + + ((double)ts.sec / (double)SECONDS_PER_DAY); + + return true; +} + +CPQDIF_Element * CPQDIF::ValidateElement(long pElement) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + CPQDIF_Element * pel; + + pel = (CPQDIF_Element *)pElement; + //ASSERT_VALID(pel); + + return pel; +} + + +CPQDIF_E_Collection * CPQDIF::ValidateCollection(long pElement) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + CPQDIF_Element * pel; + CPQDIF_E_Collection * pcoll = NULL; + + pel = (CPQDIF_Element *)pElement; + //ASSERT_VALID(pel); + if (pel) + { + if (pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION) + { + pcoll = (CPQDIF_E_Collection *)pel; + //ASSERT_VALID(pcoll); + } + } + + return pcoll; +} + + +// Validates a scalar handle and returns the object pointer. +// For internal use. +// +// Returns +// ------- +// Valid object pointer The object is valid and of the correct type +// NULL The object is invalid or has an incorrect type +// +CPQDIF_E_Scalar * CPQDIF::ValidateScalar(long pElement) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + CPQDIF_Element * pel; + CPQDIF_E_Scalar * pscalar = NULL; + + pel = (CPQDIF_Element *)pElement; + //ASSERT_VALID(pel); + if (pel) + { + if (pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR) + { + pscalar = (CPQDIF_E_Scalar *)pel; + //ASSERT_VALID(pscalar); + } + } + + return pscalar; +} + + +// Validates a vector handle and returns the object pointer. +// For internal use. +// +// Returns +// ------- +// Valid object pointer The object is valid and of the correct type +// NULL The object is invalid or has an incorrect type +// +CPQDIF_E_Vector * CPQDIF::ValidateVector(long pElement) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + CPQDIF_Element * pel; + CPQDIF_E_Vector * pvector = NULL; + + pel = (CPQDIF_Element *)pElement; + //ASSERT_VALID(pel); + if (pel) + { + if (pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR) + { + pvector = (CPQDIF_E_Vector *)pel; + //ASSERT_VALID(pvector); + } + } + + return pvector; +} + + +// Validates a observation record handle and returns the object pointer. +// For internal use. +// +// Returns +// ------- +// Valid object pointer The object is valid and of the correct type +// NULL The object is invalid or has an incorrect type +// +CPQDIF_R_Observation * CPQDIF::ValidateObservation(long pRecObserv) +{ + // AFX_MANAGE_STATE(AfxGetStaticModuleState()) + + CPQDIFRecord * prec; + CPQDIF_R_Observation * pobs = NULL; + GUID tagThisRecord; + + prec = (CPQDIFRecord *)pRecObserv; + //ASSERT_VALID(prec); + if (prec) + { + prec->HeaderGetTag(tagThisRecord); + if (PQDIF_IsEqualGUID(tagThisRecord, tagRecObservation)) + { + pobs = (CPQDIF_R_Observation *)prec; + //ASSERT_VALID(pobs); + } + } + + return pobs; +} + +void testjson() +{ + //{ "emspq1":[{ "type":1,"min":"{str}" },{ "type":2,"min":"{str2}" }],"emspq2":[{ "type":3,"min":"{str3}" },{ "type":4,"min":"{str4}" }] } + // + cJSON* root = cJSON_CreateObject(); + + // emspq1 + cJSON* emspq1_array = cJSON_CreateArray(); + cJSON_AddItemToObject(root, "emspq1", emspq1_array); + + // emspq1Ӷ + cJSON* emspq1_obj1 = cJSON_CreateObject(); + cJSON_AddNumberToObject(emspq1_obj1, "type", 1); + cJSON_AddStringToObject(emspq1_obj1, "min", "{str}"); + cJSON_AddItemToArray(emspq1_array, emspq1_obj1); + + cJSON* emspq1_obj2 = cJSON_CreateObject(); + cJSON_AddNumberToObject(emspq1_obj2, "type", 2); + cJSON_AddStringToObject(emspq1_obj2, "min", "{str2}"); + cJSON_AddItemToArray(emspq1_array, emspq1_obj2); + + // emspq2 + cJSON* emspq2_array = cJSON_CreateArray(); + cJSON_AddItemToObject(root, "emspq2", emspq2_array); + + // emspq2Ӷ + cJSON* emspq2_obj1 = cJSON_CreateObject(); + cJSON_AddNumberToObject(emspq2_obj1, "type", 3); + cJSON_AddStringToObject(emspq2_obj1, "min", "{str3}"); + cJSON_AddItemToArray(emspq2_array, emspq2_obj1); + + cJSON* emspq2_obj2 = cJSON_CreateObject(); + cJSON_AddNumberToObject(emspq2_obj2, "type", 4); + cJSON_AddStringToObject(emspq2_obj2, "min", "{str4}"); + cJSON_AddItemToArray(emspq2_array, emspq2_obj2); + + // лJSONΪַ + char* json_string = cJSON_Print(root); + printf("%s\n", json_string); + + // ͷڴ + free(json_string); // ͷ JSON ַռõڴ + cJSON_Delete(root); // ͷ cJSON ռõڴ + + printf("testjson \n"); + + +} + +char* CDeal::AssJson(char* Id) //װjsonṹ +{ + // + cJSON* root = cJSON_CreateObject(); + + for (std::list::iterator tableIt = DataTableList.begin(); tableIt != DataTableList.end(); ++tableIt) { + CTable* table = *tableIt; + //printf("TableName = %s || table->DateSeqList siez = %d\n", table->TableName.c_str(), table->DateSeqList.size()); + // emspq1 + cJSON* emspq1_array = cJSON_CreateArray(); + cJSON_AddItemToObject(root, table->TableName.c_str(), emspq1_array); + + // б + for (std::list::iterator seqIt = table->DateSeqList.begin(); seqIt != table->DateSeqList.end(); ++seqIt) { + CSeq* seq = *seqIt; + //printf("telemetryType = %s || seq->DateItemList siez = %d\n", seq->telemetryType.c_str(), seq->DateItemList.size()); + + // emspq1Ӷ + cJSON* emspq1_obj1 = cJSON_CreateObject(); + cJSON_AddStringToObject(emspq1_obj1, seq->jsonname.c_str(), seq->telemetryType.c_str()); + // б + for (std::list::iterator itemIt = seq->DateItemList.begin(); itemIt != seq->DateItemList.end(); ++itemIt) { + CItem* item = *itemIt; + //printf("KeyName = %s || DateName = %s\n", item->KeyName.c_str(), item->DateName.c_str()); + + if (item->Type == "Avg") + { + std::map< std::string, std::list >::iterator it = AvgData.find(item->DateName); + if (it != AvgData.end()) + { + int i = 1; + if (stringToTimeT(dataDate) != -1) { + std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName); + if (it != aggCydeMinList.end()) + { + i = getCurrentGroup(stringToTimeT(dataDate), it->second); + } + else + { + i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin); + } + } + bool isFirst = true; // ǷǵһԪ + std::ostringstream count; + count << "{"; + for (std::list::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) { + if (!isFirst) { + // ǵһԪأ + count << ","; + } + count << "\"P" << i++ << "\":" << *itm; + isFirst = false; // ѾǵһԪ + } + count << "}"; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + } + } + if (item->Type == "Max") + { + std::map< std::string, std::list >::iterator it = MaxData.find(item->DateName); + if (it != MaxData.end()) + { + int i = 1; + if (stringToTimeT(dataDate) != -1) { + std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName); + if (it != aggCydeMinList.end()) + { + i = getCurrentGroup(stringToTimeT(dataDate), it->second); + } + else + { + i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin); + } + } + bool isFirst = true; // ǷǵһԪ + std::ostringstream count; + count << "{"; + for (std::list::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) { + if (!isFirst) { + // ǵһԪأ + count << ","; + } + count << "\"P" << i++ << "\":" << *itm; + isFirst = false; // ѾǵһԪ + } + count << "}"; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + } + } + if (item->Type == "Min") + { + std::map< std::string, std::list >::iterator it = MinData.find(item->DateName); + if (it != MinData.end()) + { + int i = 1; + if (stringToTimeT(dataDate) != -1) { + std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName); + if (it != aggCydeMinList.end()) + { + i = getCurrentGroup(stringToTimeT(dataDate), it->second); + } + else + { + i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin); + } + } + bool isFirst = true; // ǷǵһԪ + std::ostringstream count; + count << "{"; + for (std::list::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) { + if (!isFirst) { + // ǵһԪأ + count << ","; + } + count << "\"P" << i++ << "\":" << *itm; + isFirst = false; // ѾǵһԪ + } + count << "}"; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + } + } + if (item->Type == "CP95") + { + std::map< std::string, std::list >::iterator it = CP95Data.find(item->DateName); + if (it != CP95Data.end()) + { + int i = 1; + if (stringToTimeT(dataDate) != -1) { + std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName); + if (it != aggCydeMinList.end()) + { + i = getCurrentGroup(stringToTimeT(dataDate), it->second); + } + else + { + i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin); + } + } + bool isFirst = true; // ǷǵһԪ + std::ostringstream count; + count << "{"; + for (std::list::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) { + if (!isFirst) { + // ǵһԪأ + count << ","; + } + count << "\"P" << i++ << "\":" << *itm; + isFirst = false; // ѾǵһԪ + } + count << "}"; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + } + } + if (item->Type == "Val") + { + std::map< std::string, std::list >::iterator it = ValData.find(item->DateName); + if (it != ValData.end()) + { + int i = 1; + if (stringToTimeT(dataDate) != -1) { + std::map< std::string, int >::iterator it = aggCydeMinList.find(item->DateName); + if (it != aggCydeMinList.end()) + { + i = getCurrentGroup(stringToTimeT(dataDate), it->second); + } + else + { + i = getCurrentGroup(stringToTimeT(dataDate), aggCydeMin); + } + } + bool isFirst = true; // ǷǵһԪ + std::ostringstream count; + count << "{"; + for (std::list::iterator itm = it->second.begin(); itm != it->second.end(); ++itm) { + if (!isFirst) { + // ǵһԪأ + count << ","; + } + count << "\"P" << i++ << "\":" << *itm; + isFirst = false; // ѾǵһԪ + } + count << "}"; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + } + } + if (item->Type == "Null") + { + if (item->DateName == "monitorId") // ID + { + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), Id); + } + + // ַԭʼַеλ + size_t pos = item->DateName.find("-dataDate-pt"); + // ҵַ + if (pos != std::string::npos) { + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), convertToDateOnly(dataDatePT).c_str()); + continue; + } + pos = item->DateName.find("-dataDate-all"); + // ҵַ + if (pos != std::string::npos) { + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), convertToDateOnly(dataDate).c_str()); + continue; + } + pos = item->DateName.find("-aggCydeMin-pst"); + // ҵַ + if (pos != std::string::npos && ShortFlag == 1) { + std::ostringstream count; + count << aggCycleMinShort; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + continue; + } + pos = item->DateName.find("-aggCydeMin-plt"); + // ҵַ + if (pos != std::string::npos && LongFlag == 1) { + std::ostringstream count; + count << aggCycleMinLong; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + continue; + } + pos = item->DateName.find("-aggCydeMin-flu"); + // ҵַ + if (pos != std::string::npos && FluFlag == 1) { + std::ostringstream count; + count << fluCydeMin; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + continue; + } + pos = item->DateName.find("-aggCydeMin-all"); + // ҵַ + if (pos != std::string::npos) { + std::ostringstream count; + count << aggCydeMin; + std::string count_str = count.str(); + cJSON_AddStringToObject(emspq1_obj1, item->KeyName.c_str(), count_str.c_str()); + continue; + } + } + } + cJSON_AddItemToArray(emspq1_array, emspq1_obj1); + } + } + + // лJSONΪַ + char* json_string = cJSON_Print(root); + //printf("%s\n", json_string); + + // ͷڴ + //free(json_string); // ͷ JSON ַռõڴ + cJSON_Delete(root); // ͷ cJSON ռõڴ + return json_string; +} + +bool CDeal::ExtractNumbersBetweenPercent(const std::string& str, int& start, int& end) { + size_t pos_start = str.find('%'); + if (pos_start == std::string::npos) { + // ûҵ'%'ַ + return false; + } + + size_t pos_end = str.find('%', pos_start + 1); + if (pos_end == std::string::npos) { + // ûҵڶ'%'ַ + return false; + } + + std::istringstream iss(str.substr(pos_start + 1, pos_end - pos_start - 1)); + char comma; + if (!(iss >> start >> comma >> end)) { + // ޷ַȡ + return false; + } + + return true; +} + +void CDeal::CheckDataTableList() +{ + for (std::list::iterator tableIt = DataTableList.begin(); tableIt != DataTableList.end(); ++tableIt) { + CTable* table = *tableIt; + // б + for (std::list::iterator seqIt = table->DateSeqList.begin(); seqIt != table->DateSeqList.end(); ++seqIt) { + CSeq* seq = *seqIt; + // б + for (std::list::iterator itemIt = seq->DateItemList.begin(); itemIt != seq->DateItemList.end(); ++itemIt) { + CItem* item = *itemIt; + if (item->Type == "Null") + { + { + std::string str = item->DateName; + std::string substr = "-dataDate-pt"; + + // ַԭʼַеλ + size_t pos = str.find(substr); + + // ҵַ + if (pos != std::string::npos) { + // ҵλÿʼɾַȵַ + str.erase(pos, substr.length()); + std::map< std::string, std::string >::iterator it = DateData.find(str); + if (it != DateData.end()) + { + std::ostringstream count; + count << it->second; + std::string count_str = count.str(); + dataDatePT = count_str; + } + continue; + } + } + { + std::string str = item->DateName; + std::string substr = "-dataDate-all"; + + // ַԭʼַеλ + size_t pos = str.find(substr); + + // ҵַ + if (pos != std::string::npos) { + // ҵλÿʼɾַȵַ + str.erase(pos, substr.length()); + std::map< std::string, std::string >::iterator it = DateData.find(str); + if (it != DateData.end()) + { + std::ostringstream count; + count << it->second; + std::string count_str = count.str(); + dataDate = count_str; + } + continue; + } + } + { + std::string str = item->DateName; + std::string substr = "-aggCydeMin-pst"; + + // ַԭʼַеλ + size_t pos = str.find(substr); + + // ҵַ + if (pos != std::string::npos) { + // ҵλÿʼɾַȵַ + str.erase(pos, substr.length()); + std::map< std::string, std::list >::iterator it = TimeData.find(str); + if (it != TimeData.end()) + { + ShortFlag = 1;//ôڶ + // ȡlist + const std::list& list_values = it->second; + + // ȡlistĸ + std::list::size_type list_size = list_values.size(); + + // listԪأȡǰֵ + if (list_size >= 2) { + // ʹõʵһԪ + std::list::const_iterator it_first = list_values.begin(); + // ʹõʵڶԪ + std::list::const_iterator it_second = it_first; + ++it_second; // ָڶԪ + + aggCycleMinShort = *it_second - *it_first; + aggCycleMinShort = aggCycleMinShort / 60; + } + aggCydeMinList[str] = aggCycleMinShort; + } + continue; + } + } + { + std::string str = item->DateName; + std::string substr = "-aggCydeMin-plt"; + + // ַԭʼַеλ + size_t pos = str.find(substr); + + // ҵַ + if (pos != std::string::npos) { + // ҵλÿʼɾַȵַ + str.erase(pos, substr.length()); + std::map< std::string, std::list >::iterator it = TimeData.find(str); + if (it != TimeData.end()) + { + LongFlag = 1;//ôڶ + // ȡlist + const std::list& list_values = it->second; + + // ȡlistĸ + std::list::size_type list_size = list_values.size(); + + // listԪأȡǰֵ + if (list_size >= 2) { + // ʹõʵһԪ + std::list::const_iterator it_first = list_values.begin(); + // ʹõʵڶԪ + std::list::const_iterator it_second = it_first; + ++it_second; // ָڶԪ + + aggCycleMinLong = *it_second - *it_first; + aggCycleMinLong = aggCycleMinLong / 60; + } + aggCydeMinList[str] = aggCycleMinLong; + } + continue; + } + } + { + std::string str = item->DateName; + std::string substr = "-aggCydeMin-flu"; + + // ַԭʼַеλ + size_t pos = str.find(substr); + + // ҵַ + if (pos != std::string::npos) { + // ҵλÿʼɾַȵַ + str.erase(pos, substr.length()); + std::map< std::string, std::list >::iterator it = TimeData.find(str); + if (it != TimeData.end()) + { + FluFlag = 1;//ôڶ + // ȡlist + const std::list& list_values = it->second; + + // ȡlistĸ + std::list::size_type list_size = list_values.size(); + + // listԪأȡǰֵ + if (list_size >= 2) { + // ʹõʵһԪ + std::list::const_iterator it_first = list_values.begin(); + // ʹõʵڶԪ + std::list::const_iterator it_second = it_first; + ++it_second; // ָڶԪ + + fluCydeMin = *it_second - *it_first; + fluCydeMin = fluCydeMin / 60; + } + aggCydeMinList[str] = fluCydeMin; + } + continue; + } + } + { + std::string str = item->DateName; + std::string substr = "-aggCydeMin-all"; + + // ַԭʼַеλ + size_t pos = str.find(substr); + + // ҵַ + if (pos != std::string::npos) { + // ҵλÿʼɾַȵַ + str.erase(pos, substr.length()); + std::map< std::string, std::list >::iterator it = TimeData.find(str); + if (it != TimeData.end()) + { + // ȡlist + const std::list& list_values = it->second; + + // ȡlistĸ + std::list::size_type list_size = list_values.size(); + + // listԪأȡǰֵ + if (list_size >= 2) { + // ʹõʵһԪ + std::list::const_iterator it_first = list_values.begin(); + // ʹõʵڶԪ + std::list::const_iterator it_second = it_first; + ++it_second; // ָڶԪ + + aggCydeMin = *it_second - *it_first; + aggCydeMin = aggCydeMin / 60; + } + + } + continue; + } + } + } + } + } + } +} + +void CDeal::ResJsonCfg(char* json) +{ + // ļ· + std::ifstream file(json); + + // ļǷɹ + if (!file.is_open()) { + printf("can not open file:%s \n", json); + return; + } + + // ȡļݵַ + std::ostringstream ss; + ss << file.rdbuf(); + std::string json_string = ss.str(); + + //printf("%s \n", json_string.c_str()); + + // رļ + file.close(); + + cJSON* root = cJSON_Parse(json_string.c_str()); + + if (root == NULL) { + printf("Error before: [%s]\n", cJSON_GetErrorPtr()); + return; + } + + // JSONеÿ + int count = cJSON_GetArraySize(root); + for (int i = 0; i < count; i++) { + cJSON* item = cJSON_GetArrayItem(root, i); + + // ȡ"table"ֶ + const char* table = cJSON_GetObjectItemCaseSensitive(item, "table")->valuestring; + CTable* ctable = new CTable(table); + DataTableList.push_back(ctable); + //printf("Table: %s\n", ctable->TableName.c_str()); + + // "cfg"ֶ + cJSON* cfg = cJSON_GetObjectItemCaseSensitive(item, "cfg"); + // "TELEMETRYTYPE" + cJSON* telemetry_types = cJSON_GetObjectItemCaseSensitive(cfg, "TELEMETRYTYPE"); + int telemetry_count = cJSON_GetArraySize(telemetry_types); + for (int i = 0; i < telemetry_count; i++) { + cJSON* telemetry = cJSON_GetArrayItem(telemetry_types, i); + const char* seq = cJSON_GetObjectItemCaseSensitive(telemetry, "seq")->valuestring; + const char* key_name = cJSON_GetObjectItemCaseSensitive(telemetry, "KeyName")->valuestring; + const char* json_name = cJSON_GetObjectItemCaseSensitive(telemetry, "JsonName")->valuestring; + CSeq* cseq = new CSeq(seq, key_name, json_name); + ctable->DateSeqList.push_back(cseq); + //printf(" Telemetry: Seq=%s, KeyName=%s\n", seq, key_name); + + // "Item"飨ƵشֶΣ + cJSON* items = cJSON_GetObjectItemCaseSensitive(cfg, "Item"); + int item_count = cJSON_GetArraySize(items); + for (int i = 0; i < item_count; i++) { + cJSON* item = cJSON_GetArrayItem(items, i); + const char* key_name = cJSON_GetObjectItemCaseSensitive(item, "KeyName")->valuestring; + const char* data_name = cJSON_GetObjectItemCaseSensitive(item, "DataName")->valuestring; //const char* data_name = "V HRMS A[%2,25%]" + const char* type = cJSON_GetObjectItemCaseSensitive(item, "Type")->valuestring; + std::string str_key_name(key_name); // const char*תΪstd::string + std::string str_data_name(data_name); // const char*תΪstd::string + size_t pos; + while ((pos = str_data_name.find('*')) != std::string::npos) { + str_data_name.replace(pos, 1, seq); + } + int start = 0, end = 0; + if (ExtractNumbersBetweenPercent(str_data_name,start,end)) + { + //printf(" Item: start=%d, end=%d\n", start,end); + for (int i = start; i <= end; i++) { + std::string str_key_name_temp = str_key_name; + std::string str_data_name_temp = str_data_name; + std::ostringstream oss; + oss << "%" << start << "," << end << "%"; + std::string result = oss.str(); + + std::ostringstream count; + count << i; + std::string count_str = count.str(); + + size_t pos = str_data_name.find(result); + if (pos != std::string::npos) { + str_data_name_temp.replace(pos, result.length(), count_str); // 滻6ַȵӴ + //str_key_name_temp.replace(pos, result.length(), count_str); + } + pos = str_key_name.find(result); + if (pos != std::string::npos) { + //str_data_name_temp.replace(pos, result.length(), count_str); // 滻6ַȵӴ + str_key_name_temp.replace(pos, result.length(), count_str); + } + + CItem* citem = new CItem(str_key_name_temp.c_str(), str_data_name_temp.c_str(), type); + cseq->DateItemList.push_back(citem); + //printf(" Item: KeyName=%s, DataName=%s, Type=%s\n", str_key_name_temp.c_str(), str_data_name_temp.c_str(), type); + } + } + else + { + CItem* citem = new CItem(key_name, str_data_name.c_str(), type); + cseq->DateItemList.push_back(citem); + //printf(" Item: KeyName=%s, DataName=%s, Type=%s\n", key_name, str_data_name.c_str(), type); + } + } + } + + } + + // ͷcJSONռõڴ + cJSON_Delete(root); +} + +cJSON* CDeal::cJSON_GetObjectItemCaseSensitive(cJSON* object, const char* string) { + cJSON* c = object->child; + while (c) { + if (strcmp(c->string, string) == 0) { + return c; + } + c = c->next; + } + return NULL; +} + +std::string CDeal::convertToDateOnly(const std::string& dateTime) { + size_t spacePos = dateTime.find(' '); // ѰҿոλãԷָںʱ + if (spacePos != std::string::npos) { + return dateTime.substr(0, spacePos); // شַʼո֮ǰӴ + } + return dateTime; // ûҵո񣬷ԭַȻв̫ܷ +} + +int CDeal::getCurrentGroup(const std::time_t& currentTime,int min) { + // time_tתΪtmṹ + std::tm* localTime = std::localtime(¤tTime); + + // ҹʼǰʱܷ + int totalMinutes = localTime->tm_hour * 60 + localTime->tm_min; + + // ÿķ + const int groupSize = min; + + // + // ʹܷСȻȡõ + // ټΪʱһ飨˵һĿʼм䣩 + int groupNumber = totalMinutes / groupSize; + if (totalMinutes % groupSize != 0) { + groupNumber++; // һ + } + groupNumber++;//ݴ0ʼ ±1ʼ ±ֵ1 + return groupNumber; +} + +std::time_t CDeal::stringToTimeT(const std::string& dateTime) { + std::tm tm{}; + + // strptime is not standard C++ but is available on many systems (POSIX) + strptime(dateTime.c_str(), "%Y-%m-%d %H:%M:%S", &tm); + + // Convert tm to time_t + std::time_t currentTime = std::mktime(&tm); + if (currentTime == -1) { + std::cerr << "Error converting string to time_t." << std::endl; + // Handle the error as needed + } + + return currentTime; +} + +void CDeal::clear() +{ + // AvgDataͬʱͷlistеڴ棨еĻͨlistҪֶͷţ + AvgData.clear(); + // MaxData + MaxData.clear(); + // MinData + MinData.clear(); + // CP95Data + CP95Data.clear(); + // ValData + ValData.clear(); + // TimeData + TimeData.clear(); + // DateDatavaluestd::stringҪֶͷڴ棩 + DateData.clear(); + // aggCydeMinList + aggCydeMinList.clear(); + + // DataTableListͷÿCTableڴ + for (std::list::iterator it = DataTableList.begin(); it != DataTableList.end(); ++it) { + delete* it; // ͷڴ + } + DataTableList.clear(); // беָ +} + +bool CPQDIF::ObservationGetChannelInfoEx(long pRecordObserv, long idxChannel, PqdifChannelInfoEx* out) +{ + if (out == nullptr) + return false; + + bool status = false; + CPQDIF_R_Observation* pobs = nullptr; + + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + if (idxChannel >= 0 && idxChannel < pobs->GetCountChannels()) + { + std::string nameLocal; + UINT4 idPhaseLocal = 0; + GUID idQuantityTypeLocal{}; + UINT4 idQuantityMeasuredLocal = 0; + + out->countSeries = pobs->GetCountSeries(idxChannel); + + status = pobs->GetChannelInfo( + idxChannel, + nameLocal, + idPhaseLocal, + idQuantityTypeLocal, + idQuantityMeasuredLocal + ); + + if (status) + { + out->name = nameLocal; + out->phaseId = static_cast(idPhaseLocal); + out->quantityTypeId = idQuantityTypeLocal; + out->quantityMeasuredId = static_cast(idQuantityMeasuredLocal); + } + } + } + } + catch (...) + { + status = false; + } + + return status; +} + +bool CPQDIF::ObservationGetSeriesInfoEx(long pRecordObserv, long idxChannel, long idxSeries, PqdifSeriesInfoEx* out) +{ + if (out == nullptr) + return false; + + bool status = false; + CPQDIF_R_Observation* pobs = nullptr; + + try + { + pobs = ValidateObservation(pRecordObserv); + if (pobs) + { + UINT4 idQuantityUnitsLocal = 0; + GUID idQuantityCharacteristicLocal{}; + GUID idValueTypeLocal{}; + + status = pobs->GetSeriesInfo( + idxChannel, + idxSeries, + idQuantityUnitsLocal, + idQuantityCharacteristicLocal, + idValueTypeLocal + ); + + if (status) + { + out->quantityUnitsId = static_cast(idQuantityUnitsLocal); + out->quantityCharacteristicId = idQuantityCharacteristicLocal; + out->valueTypeId = idValueTypeLocal; + + long baseType = -1; + if (pobs->GetSeriesBaseType(idxChannel, idxSeries, baseType)) + { + out->seriesBaseType = baseType; + } + + double scale = 1.0; + double offset = 0.0; + if (pobs->GetSeriesScale(idxChannel, idxSeries, scale, offset)) + { + out->scale = scale; + out->offset = offset; + } + } + } + } + catch (...) + { + status = false; + } + + return status; +} \ No newline at end of file diff --git a/LFtid1056/pqdif/PQDIF.h b/LFtid1056/pqdif/PQDIF.h new file mode 100644 index 0000000..c0a0356 --- /dev/null +++ b/LFtid1056/pqdif/PQDIF.h @@ -0,0 +1,193 @@ +#pragma once + +#include +#include +#include +#include +#include +#include + +#include "cjson.h" +#include "PQDIF_classes.h" +#include "pqdif_ph.h" + +typedef double DATE; + +class CPQDIF_Element; +class CPQDIF_E_Collection; +class CPQDIF_E_Scalar; +class CPQDIF_E_Vector; +class CPQDIF_R_Observation; +class CPQDIF_R_DataSource; +class CPQDIF_R_Container; +class CPQDIF_R_Settings; +class CPQDIF_PC_FlatFile; + +// ============================ +// PQDIF ͨչϢ +// ãѱ׼ͨǩ¶ϲ +// ============================ +struct PqdifChannelInfoEx +{ + std::string name; // ԭʼ tagChannelName + long countSeries = 0; // ͨµ series + long phaseId = -1; // tagPhaseID + GUID quantityTypeId{}; // tagQuantityTypeID + long quantityMeasuredId = -1; // tagQuantityMeasuredID +}; + +// ============================ +// PQDIF ϵչϢ +// ãѱ׼ϵмǩ¶ϲ +// ============================ +struct PqdifSeriesInfoEx +{ + long quantityUnitsId = -1; // tagQuantityUnitsID + GUID quantityCharacteristicId{}; // tagQuantityCharacteristicID + GUID valueTypeId{}; // tagValueTypeID + + long seriesBaseType = -1; // series ײͣϢ + double scale = 1.0; // ϵ + double offset = 0.0; // ƫ +}; + +class CPQDIF +{ +public: + CPQDIF(); + ~CPQDIF(); +public: + void GetTime(DATE dt, time_t* tm); + void put_FlatFileName(string strFileName); + bool Read(); + bool Close(); + bool New(); + long RecordGetCount(); + bool RecordGetInfo + ( + long index, + GUID * tagRecordType, + string & nameRecordType + ); + bool RecordRequestObservation(long index, long * pRecordObserv); + bool ObservationGetInfo(long pRecordObserv, DATE& timeStart, string& name, long& countChannels); + bool ObservationGetTriggerInfo(long pRecordObserv, long * idTriggerMethod, DATE * timeTriggered); + bool ObservationGetChannelInfo(long pRecordObserv, long idxChannel, string &name, long * countSeries); + bool ObservationGetSeriesInfo3(long pRecordObserv, long idxChannel, long idxSeries, long * idQuantityUnits, GUID * idQuantityCharacteristic, GUID * idValueType); + bool ObservationGetSeriesData(long pRecordObserv, long idxChannel, long idxSeries, double ** values, long* varCount); + bool ObservationGetChannelFreq(long pRecObs, long idxChannel, double * freq); + bool ObservationGetChannelGroupID(long pRecObs, long idxChannel, int *GroupID); + bool ObservationGetSeriesPhasicType(long pRecordObserv, long idxChannel, long idxSeries, long *valuetypes); + bool ObservationGetSeriesScale(long pRecObs, long idxChannel, long idxSeries, double * scale, double * offset); + bool RecordReleaseObservation(long pRecordObserv); + + // ȡ Observation ijͨչǩϢ + bool ObservationGetChannelInfoEx(long pRecordObserv, long idxChannel, PqdifChannelInfoEx* out); + + // ȡ Observation ij series չǩϢ + bool ObservationGetSeriesInfoEx(long pRecordObserv, long idxChannel, long idxSeries, PqdifSeriesInfoEx* out); + // Internal +protected: + CPQDIF_Element * ValidateElement(long pElement); + CPQDIF_E_Collection * ValidateCollection(long pElement); + CPQDIF_E_Scalar * ValidateScalar(long pElement); + CPQDIF_E_Vector * ValidateVector(long pElement); + CPQDIF_R_Observation * ValidateObservation(long pRecObserv); + CPQDIF_R_DataSource * ValidateDataSource(long pRecDS); + CPQDIF_R_Settings * ValidateSettings(long pRecSettings); + CPQDIF_R_Container* ValidateContainer(long pRecCon); + bool SetDateFromTimeStamp(DATE& date, const TIMESTAMPPQDIF& ts); + // Member data +private: + CPQDIF_PC_FlatFile * m_percont; // Persistence controller + +}; + +class CItem //¸Խṹ +{ +public: + string KeyName;// + string DateName;//ָ + string Type;// MAX MIN AVG CP95 NULL + + CItem(const string& kn, const string& dn, const string& tp) + : KeyName(kn), DateName(dn), Type(tp) {} +}; + +class CSeq //¸ṹ +{ +public: + string seq;// + string telemetryType;//־ + string jsonname;//josn key + list DateItemList;//б + + CSeq(const string& s, const string& tt, const string& tp) + : seq(s), telemetryType(tt), jsonname(tp) {} + // + ~CSeq() { + // ͷDateItemListеCItem + for (std::list::iterator it = DateItemList.begin(); it != DateItemList.end(); ++it) { + delete* it; // ͷڴ + } + DateItemList.clear(); // беָ + } +}; + +class CTable //Ŀṹ +{ +public: + string TableName;// + list DateSeqList;//б + + CTable(const string& tn) + : TableName(tn) {} + // + ~CTable() { + // ͷDateSeqListеCSeq + for (std::list::iterator it = DateSeqList.begin(); it != DateSeqList.end(); ++it) { + delete* it; // ͷڴ + } + DateSeqList.clear(); // беָ + } +}; + +class CDeal //ݴ +{ +public: + void clear(); + void CheckDataTableList();//DataTableList + void ResJsonCfg(char* json);//jsonṹϢ + char* AssJson(char* Id);//װjsonַ + cJSON* cJSON_GetObjectItemCaseSensitive(cJSON* object, const char* string);//jsonṹ ȡֵ + bool ExtractNumbersBetweenPercent(const std::string& str, int& start, int& end); + std::string convertToDateOnly(const std::string& dateTime); + int getCurrentGroup(const std::time_t& currentTime,int min); + std::time_t stringToTimeT(const std::string& dateTime); + + std::list DataTableList;//Ϣ + std::string MonitorId;//ID + std::string dataDate;//ʱ + std::string dataDatePT;//ʱ + + int ShortFlag = 0;//ָ + int LongFlag = 0;//ָ + int FluFlag = 0;//ָ + int aggCydeMin = 3;// ĬΪ3 + int fluCydeMin = 10;// ĬΪ10 + int aggCycleMinShort = 10;// ĬΪ10 + int aggCycleMinLong = 120;// ĬΪ120 + std::map< std::string, std::list > AvgData;//ļݴ洢 avg + std::map< std::string, std::list > MaxData;//ļݴ洢 Max + std::map< std::string, std::list > MinData;//ļݴ洢 Min + std::map< std::string, std::list > CP95Data;//ļݴ洢 CP95 + std::map< std::string, std::list > ValData;//ļݴ洢 value + std::map< std::string, std::list > TimeData;//ļ ʱ + std::map< std::string, std::string > DateData;//ļ ʼʱ + std::map< std::string, int > aggCydeMinList; +}; + +void testjson(); + + + diff --git a/LFtid1056/pqdif/include/PQDIFLib.vcxproj b/LFtid1056/pqdif/include/PQDIFLib.vcxproj new file mode 100644 index 0000000..e6ac3b6 --- /dev/null +++ b/LFtid1056/pqdif/include/PQDIFLib.vcxproj @@ -0,0 +1,208 @@ + + + + + Debug + Win32 + + + Release + Win32 + + + Debug + x64 + + + Release + x64 + + + + 15.0 + {0BB14D2D-2917-46AD-8E82-F0F7F5143CA4} + PQDIFLib + 10.0.17763.0 + + + + Application + true + v141 + MultiByte + + + Application + false + v141 + true + MultiByte + + + StaticLibrary + true + v141 + MultiByte + Static + + + StaticLibrary + false + v141 + true + MultiByte + Static + + + + + + + + + + + + + + + + + + + + + + + Level3 + Disabled + true + true + + + Console + + + + + Level3 + Disabled + true + true + _MBCS;WIN32;%(PreprocessorDefinitions) + + + Console + + + E:\同步盘\源码\电压暂降高级算法\Linux\PQDIFDLL(qt编译张文)\PQDIFDLL\PQDIFDLL\lib\PQDIFLibd.lib + + + + + Level3 + MaxSpeed + true + true + true + true + + + Console + true + true + + + + + Level3 + MaxSpeed + true + true + true + true + WIN32;%(PreprocessorDefinitions) + + + Console + true + true + E:\同步盘\源码\电压暂降高级算法\Linux\PQDIFDLL(qt编译张文)\PQDIFDLL\PQDIFDLL\lib\PQDIFLib.lib + + + %(AdditionalDependencies) + E:\同步盘\源码\电压暂降高级算法\Linux\PQDIFDLL(qt编译张文)\PQDIFDLL\PQDIFDLL\lib\PQDIFLib.lib + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/LFtid1056/pqdif/include/PQDIFLib.vcxproj.filters b/LFtid1056/pqdif/include/PQDIFLib.vcxproj.filters new file mode 100644 index 0000000..e5eee65 --- /dev/null +++ b/LFtid1056/pqdif/include/PQDIFLib.vcxproj.filters @@ -0,0 +1,205 @@ + + + + + {4FC737F1-C7A5-4376-A066-2A32D752A2FF} + cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx + + + {93995380-89BD-4b04-88EB-625FBE52EBFB} + h;hh;hpp;hxx;hm;inl;inc;ipp;xsd + + + {67DA6AB6-F800-4c08-8B7A-83BB121AAD01} + rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms + + + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + 源文件 + + + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + 头文件 + + + + + + + \ No newline at end of file diff --git a/LFtid1056/pqdif/include/PQDIF_classes.h b/LFtid1056/pqdif/include/PQDIF_classes.h new file mode 100644 index 0000000..bf17d31 --- /dev/null +++ b/LFtid1056/pqdif/include/PQDIF_classes.h @@ -0,0 +1,79 @@ +// Main include file for core WPT PQDIF classes. +// --------------------------------------------- +// +// File name: $Workfile: PQDIF_classes.h $ +// Last modified: $Modtime: 10/11/01 11:24a $ +// Last modified by: $Author: Tomm $ +// +// VCS archive path: $Archive: /ElectrotekLibs/Borland/PQDIFlib/PQDIF_classes.h $ +// VCS revision: $Revision: 17 $ + +// Windows stuff... +//#include WW 2024-05-19 + +// Array template from Standard Template Library (STL) +#include +#include +#include +#include +#include +#include + +using namespace std; + +// Math library support +#include + + +//#include "pqdif_custom_1.h" // include implementation specific items WW 2024-05-19 + +// PQDIF headers +#include "pqdif_ph.h" // Physical definitions +#include "pqdif_lg.h" // Logical definitions +#include "pqdif_id.h" // Extensible ID definitions + +// General purpose classes +#include "pqbytearray.h" // Byte array class - mostly compatible with MFC version +#include "pqptrarray.h" // Pointer array class - mostly compatible with MFC version + +// Persistence controllers - Concrete uses an enum defined in pqdfacty.h +#include "pcn_base.h" // Interface (virtual base class) + +// Stream classes +#include "str_base.h" // Interface (virtual base class) +#include "str_flat.h" // Flat file (for reading/writing temporary files) +#include "str_chnk.h" // Chunked streams + +// Stream processor classes +#include "proc_bas.h" // Interface (virtual base class) +#include "proc_not.h" // Concrete: Nothing +#include "proc_zlib.h" // Concrete: ZLIB + +// Record classes +#include "rec_base.h" // Record base class +#include "rec_general.h" // General record class (or "generic") +#include "rec_container.h" // Container record class - cast from general +#include "rec_datasource.h" // Data source record class - cast from general +#include "rec_observ.h" // Observation record class - cast from general +#include "rec_settings.h" // Settings record class - wrapper around general + +// Element classes +#include "el_base.h" // Interface (virtual base class) +#include "el_coll.h" // Concrete: Collection +#include "el_scal.h" // Concrete: Scalar +#include "el_vect.h" // Concrete: Vector + +// Serialization controller, iterator and allocator +#include "ser_cont_el.h" +#include "ser_iter_el.h" +#include "ser_alloc.h" + +// Singleton objects +#include "pqdfacty.h" // Factory object for creating other PQDIF objects +#include "pqdinfo.h" // PQDIF information object (Singleton) + +// Persistence controller - uses an enum defined in pqdfacty.h +#include "pcn_flat.h" // Concrete: Flat file controller + +#include "pqdif_custom_2.h" // include implementation specific items + diff --git a/LFtid1056/pqdif/include/cjson.c b/LFtid1056/pqdif/include/cjson.c new file mode 100644 index 0000000..fe52dfe --- /dev/null +++ b/LFtid1056/pqdif/include/cjson.c @@ -0,0 +1,754 @@ +/* + Copyright (c) 2009 Dave Gamble + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +/* cJSON */ +/* JSON parser in C. */ + +#include +#include +#include +#include +#include +#include +#include +#include "cjson.h" + +static const char *global_ep; + +const char *cJSON_GetErrorPtr(void) {return global_ep;} + +static int cJSON_strcasecmp(const char *s1,const char *s2) +{ + if (!s1) return (s1==s2)?0:1;if (!s2) return 1; + for(; tolower(*s1) == tolower(*s2); ++s1, ++s2) if(*s1 == 0) return 0; + return tolower(*(const unsigned char *)s1) - tolower(*(const unsigned char *)s2); +} + +static void *(*cJSON_malloc)(size_t sz) = malloc; +static void (*cJSON_free)(void *ptr) = free; + +static char* cJSON_strdup(const char* str) +{ + size_t len; + char* copy; + + len = strlen(str) + 1; + if (!(copy = (char*)cJSON_malloc(len))) return 0; + memcpy(copy,str,len); + return copy; +} + +void cJSON_InitHooks(cJSON_Hooks* hooks) +{ + if (!hooks) { /* Reset hooks */ + cJSON_malloc = malloc; + cJSON_free = free; + return; + } + + cJSON_malloc = (hooks->malloc_fn)?hooks->malloc_fn:malloc; + cJSON_free = (hooks->free_fn)?hooks->free_fn:free; +} + +/* Internal constructor. */ +static cJSON *cJSON_New_Item(void) +{ + cJSON* node = (cJSON*)cJSON_malloc(sizeof(cJSON)); + if (node) memset(node,0,sizeof(cJSON)); + return node; +} + +/* Delete a cJSON structure. */ +void cJSON_Delete(cJSON *c) +{ + cJSON *next; + while (c) + { + next=c->next; + if (!(c->type&cJSON_IsReference) && c->child) cJSON_Delete(c->child); + if (!(c->type&cJSON_IsReference) && c->valuestring) cJSON_free(c->valuestring); + if (!(c->type&cJSON_StringIsConst) && c->string) cJSON_free(c->string); + cJSON_free(c); + c=next; + } +} + +/* Parse the input text to generate a number, and populate the result into item. */ +static const char *parse_number(cJSON *item,const char *num) +{ + double n=0,sign=1,scale=0;int subscale=0,signsubscale=1; + + if (*num=='-') sign=-1,num++; /* Has sign? */ + if (*num=='0') num++; /* is zero */ + if (*num>='1' && *num<='9') do n=(n*10.0)+(*num++ -'0'); while (*num>='0' && *num<='9'); /* Number? */ + if (*num=='.' && num[1]>='0' && num[1]<='9') {num++; do n=(n*10.0)+(*num++ -'0'),scale--; while (*num>='0' && *num<='9');} /* Fractional part? */ + if (*num=='e' || *num=='E') /* Exponent? */ + { num++;if (*num=='+') num++; else if (*num=='-') signsubscale=-1,num++; /* With sign? */ + while (*num>='0' && *num<='9') subscale=(subscale*10)+(*num++ - '0'); /* Number? */ + } + + n=sign*n*pow(10.0,(scale+subscale*signsubscale)); /* number = +/- number.fraction * 10^+/- exponent */ + + item->valuedouble=n; + item->valueint=(int)n; + item->type=cJSON_Number; + return num; +} + +static int pow2gt (int x) { --x; x|=x>>1; x|=x>>2; x|=x>>4; x|=x>>8; x|=x>>16; return x+1; } + +typedef struct {char *buffer; int length; int offset; } printbuffer; + +static char* ensure(printbuffer *p,int needed) +{ + char *newbuffer;int newsize; + if (!p || !p->buffer) return 0; + needed+=p->offset; + if (needed<=p->length) return p->buffer+p->offset; + + newsize=pow2gt(needed); + newbuffer=(char*)cJSON_malloc(newsize); + if (!newbuffer) {cJSON_free(p->buffer);p->length=0,p->buffer=0;return 0;} + if (newbuffer) memcpy(newbuffer,p->buffer,p->length); + cJSON_free(p->buffer); + p->length=newsize; + p->buffer=newbuffer; + return newbuffer+p->offset; +} + +static int update(printbuffer *p) +{ + char *str; + if (!p || !p->buffer) return 0; + str=p->buffer+p->offset; + return p->offset+strlen(str); +} + +/* Render the number nicely from the given item into a string. */ +static char *print_number(cJSON *item,printbuffer *p) +{ + char *str=0; + double d=item->valuedouble; + if (d==0) + { + if (p) str=ensure(p,2); + else str=(char*)cJSON_malloc(2); /* special case for 0. */ + if (str) strcpy(str,"0"); + } + else if (fabs(((double)item->valueint)-d)<=DBL_EPSILON && d<=INT_MAX && d>=INT_MIN) + { + if (p) str=ensure(p,21); + else str=(char*)cJSON_malloc(21); /* 2^64+1 can be represented in 21 chars. */ + if (str) sprintf(str,"%d",item->valueint); + } + else + { + if (p) str=ensure(p,64); + else str=(char*)cJSON_malloc(64); /* This is a nice tradeoff. */ + if (str) + { + if (d*0!=0) sprintf(str,"null"); /* This checks for NaN and Infinity */ + else if (fabs(floor(d)-d)<=DBL_EPSILON && fabs(d)<1.0e60) sprintf(str,"%.0f",d); + else if (fabs(d)<1.0e-6 || fabs(d)>1.0e9) sprintf(str,"%e",d); + else sprintf(str,"%f",d); + } + } + return str; +} + +static unsigned parse_hex4(const char *str) +{ + unsigned h=0; + if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0; + h=h<<4;str++; + if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0; + h=h<<4;str++; + if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0; + h=h<<4;str++; + if (*str>='0' && *str<='9') h+=(*str)-'0'; else if (*str>='A' && *str<='F') h+=10+(*str)-'A'; else if (*str>='a' && *str<='f') h+=10+(*str)-'a'; else return 0; + return h; +} + +/* Parse the input text into an unescaped cstring, and populate item. */ +static const unsigned char firstByteMark[7] = { 0x00, 0x00, 0xC0, 0xE0, 0xF0, 0xF8, 0xFC }; +static const char *parse_string(cJSON *item,const char *str,const char **ep) +{ + const char *ptr=str+1,*end_ptr=str+1;char *ptr2;char *out;int len=0;unsigned uc,uc2; + if (*str!='\"') {*ep=str;return 0;} /* not a string! */ + + while (*end_ptr!='\"' && *end_ptr && ++len) if (*end_ptr++ == '\\') end_ptr++; /* Skip escaped quotes. */ + + out=(char*)cJSON_malloc(len+1); /* This is how long we need for the string, roughly. */ + if (!out) return 0; + item->valuestring=out; /* assign here so out will be deleted during cJSON_Delete() later */ + item->type=cJSON_String; + + ptr=str+1;ptr2=out; + while (ptr < end_ptr) + { + if (*ptr!='\\') *ptr2++=*ptr++; + else + { + ptr++; + switch (*ptr) + { + case 'b': *ptr2++='\b'; break; + case 'f': *ptr2++='\f'; break; + case 'n': *ptr2++='\n'; break; + case 'r': *ptr2++='\r'; break; + case 't': *ptr2++='\t'; break; + case 'u': /* transcode utf16 to utf8. */ + uc=parse_hex4(ptr+1);ptr+=4; /* get the unicode char. */ + if (ptr >= end_ptr) {*ep=str;return 0;} /* invalid */ + + if ((uc>=0xDC00 && uc<=0xDFFF) || uc==0) {*ep=str;return 0;} /* check for invalid. */ + + if (uc>=0xD800 && uc<=0xDBFF) /* UTF16 surrogate pairs. */ + { + if (ptr+6 > end_ptr) {*ep=str;return 0;} /* invalid */ + if (ptr[1]!='\\' || ptr[2]!='u') {*ep=str;return 0;} /* missing second-half of surrogate. */ + uc2=parse_hex4(ptr+3);ptr+=6; + if (uc2<0xDC00 || uc2>0xDFFF) {*ep=str;return 0;} /* invalid second-half of surrogate. */ + uc=0x10000 + (((uc&0x3FF)<<10) | (uc2&0x3FF)); + } + + len=4;if (uc<0x80) len=1;else if (uc<0x800) len=2;else if (uc<0x10000) len=3; ptr2+=len; + + switch (len) { + case 4: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; + case 3: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; + case 2: *--ptr2 =((uc | 0x80) & 0xBF); uc >>= 6; + case 1: *--ptr2 =(uc | firstByteMark[len]); + } + ptr2+=len; + break; + default: *ptr2++=*ptr; break; + } + ptr++; + } + } + *ptr2=0; + if (*ptr=='\"') ptr++; + return ptr; +} + +/* Render the cstring provided to an escaped version that can be printed. */ +static char *print_string_ptr(const char *str,printbuffer *p) +{ + const char *ptr;char *ptr2,*out;int len=0,flag=0;unsigned char token; + + if (!str) + { + if (p) out=ensure(p,3); + else out=(char*)cJSON_malloc(3); + if (!out) return 0; + strcpy(out,"\"\""); + return out; + } + + for (ptr=str;*ptr;ptr++) flag|=((*ptr>0 && *ptr<32)||(*ptr=='\"')||(*ptr=='\\'))?1:0; + if (!flag) + { + len=ptr-str; + if (p) out=ensure(p,len+3); + else out=(char*)cJSON_malloc(len+3); + if (!out) return 0; + ptr2=out;*ptr2++='\"'; + strcpy(ptr2,str); + ptr2[len]='\"'; + ptr2[len+1]=0; + return out; + } + + ptr=str;while ((token=*ptr) && ++len) {if (strchr("\"\\\b\f\n\r\t",token)) len++; else if (token<32) len+=5;ptr++;} + + if (p) out=ensure(p,len+3); + else out=(char*)cJSON_malloc(len+3); + if (!out) return 0; + + ptr2=out;ptr=str; + *ptr2++='\"'; + while (*ptr) + { + if ((unsigned char)*ptr>31 && *ptr!='\"' && *ptr!='\\') *ptr2++=*ptr++; + else + { + *ptr2++='\\'; + switch (token=*ptr++) + { + case '\\': *ptr2++='\\'; break; + case '\"': *ptr2++='\"'; break; + case '\b': *ptr2++='b'; break; + case '\f': *ptr2++='f'; break; + case '\n': *ptr2++='n'; break; + case '\r': *ptr2++='r'; break; + case '\t': *ptr2++='t'; break; + default: sprintf(ptr2,"u%04x",token);ptr2+=5; break; /* escape and print */ + } + } + } + *ptr2++='\"';*ptr2++=0; + return out; +} +/* Invote print_string_ptr (which is useful) on an item. */ +static char *print_string(cJSON *item,printbuffer *p) {return print_string_ptr(item->valuestring,p);} + +/* Predeclare these prototypes. */ +static const char *parse_value(cJSON *item,const char *value,const char **ep); +static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p); +static const char *parse_array(cJSON *item,const char *value,const char **ep); +static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p); +static const char *parse_object(cJSON *item,const char *value,const char **ep); +static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p); + +/* Utility to jump whitespace and cr/lf */ +static const char *skip(const char *in) {while (in && *in && (unsigned char)*in<=32) in++; return in;} + +/* Parse an object - create a new root, and populate. */ +cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated) +{ + const char *end=0,**ep=return_parse_end?return_parse_end:&global_ep; + cJSON *c=cJSON_New_Item(); + *ep=0; + if (!c) return 0; /* memory fail */ + + end=parse_value(c,skip(value),ep); + if (!end) {cJSON_Delete(c);return 0;} /* parse failure. ep is set. */ + + /* if we require null-terminated JSON without appended garbage, skip and then check for a null terminator */ + if (require_null_terminated) {end=skip(end);if (*end) {cJSON_Delete(c);*ep=end;return 0;}} + if (return_parse_end) *return_parse_end=end; + return c; +} +/* Default options for cJSON_Parse */ +cJSON *cJSON_Parse(const char *value) {return cJSON_ParseWithOpts(value,0,0);} + +/* Render a cJSON item/entity/structure to text. */ +char *cJSON_Print(cJSON *item) {return print_value(item,0,1,0);} +char *cJSON_PrintUnformatted(cJSON *item) {return print_value(item,0,0,0);} + +char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt) +{ + printbuffer p; + p.buffer=(char*)cJSON_malloc(prebuffer); + p.length=prebuffer; + p.offset=0; + return print_value(item,0,fmt,&p); +} + + +/* Parser core - when encountering text, process appropriately. */ +static const char *parse_value(cJSON *item,const char *value,const char **ep) +{ + if (!value) return 0; /* Fail on null. */ + if (!strncmp(value,"null",4)) { item->type=cJSON_NULL; return value+4; } + if (!strncmp(value,"false",5)) { item->type=cJSON_False; return value+5; } + if (!strncmp(value,"true",4)) { item->type=cJSON_True; item->valueint=1; return value+4; } + if (*value=='\"') { return parse_string(item,value,ep); } + if (*value=='-' || (*value>='0' && *value<='9')) { return parse_number(item,value); } + if (*value=='[') { return parse_array(item,value,ep); } + if (*value=='{') { return parse_object(item,value,ep); } + + *ep=value;return 0; /* failure. */ +} + +/* Render a value to text. */ +static char *print_value(cJSON *item,int depth,int fmt,printbuffer *p) +{ + char *out=0; + if (!item) return 0; + if (p) + { + switch ((item->type)&255) + { + case cJSON_NULL: {out=ensure(p,5); if (out) strcpy(out,"null"); break;} + case cJSON_False: {out=ensure(p,6); if (out) strcpy(out,"false"); break;} + case cJSON_True: {out=ensure(p,5); if (out) strcpy(out,"true"); break;} + case cJSON_Number: out=print_number(item,p);break; + case cJSON_String: out=print_string(item,p);break; + case cJSON_Array: out=print_array(item,depth,fmt,p);break; + case cJSON_Object: out=print_object(item,depth,fmt,p);break; + } + } + else + { + switch ((item->type)&255) + { + case cJSON_NULL: out=cJSON_strdup("null"); break; + case cJSON_False: out=cJSON_strdup("false");break; + case cJSON_True: out=cJSON_strdup("true"); break; + case cJSON_Number: out=print_number(item,0);break; + case cJSON_String: out=print_string(item,0);break; + case cJSON_Array: out=print_array(item,depth,fmt,0);break; + case cJSON_Object: out=print_object(item,depth,fmt,0);break; + } + } + return out; +} + +/* Build an array from input text. */ +static const char *parse_array(cJSON *item,const char *value,const char **ep) +{ + cJSON *child; + if (*value!='[') {*ep=value;return 0;} /* not an array! */ + + item->type=cJSON_Array; + value=skip(value+1); + if (*value==']') return value+1; /* empty array. */ + + item->child=child=cJSON_New_Item(); + if (!item->child) return 0; /* memory fail */ + value=skip(parse_value(child,skip(value),ep)); /* skip any spacing, get the value. */ + if (!value) return 0; + + while (*value==',') + { + cJSON *new_item; + if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */ + child->next=new_item;new_item->prev=child;child=new_item; + value=skip(parse_value(child,skip(value+1),ep)); + if (!value) return 0; /* memory fail */ + } + + if (*value==']') return value+1; /* end of array */ + *ep=value;return 0; /* malformed. */ +} + +/* Render an array to text */ +static char *print_array(cJSON *item,int depth,int fmt,printbuffer *p) +{ + char **entries; + char *out=0,*ptr,*ret;int len=5; + cJSON *child=item->child; + int numentries=0,i=0,fail=0; + size_t tmplen=0; + + /* How many entries in the array? */ + while (child) numentries++,child=child->next; + /* Explicitly handle numentries==0 */ + if (!numentries) + { + if (p) out=ensure(p,3); + else out=(char*)cJSON_malloc(3); + if (out) strcpy(out,"[]"); + return out; + } + + if (p) + { + /* Compose the output array. */ + i=p->offset; + ptr=ensure(p,1);if (!ptr) return 0; *ptr='['; p->offset++; + child=item->child; + while (child && !fail) + { + print_value(child,depth+1,fmt,p); + p->offset=update(p); + if (child->next) {len=fmt?2:1;ptr=ensure(p,len+1);if (!ptr) return 0;*ptr++=',';if(fmt)*ptr++=' ';*ptr=0;p->offset+=len;} + child=child->next; + } + ptr=ensure(p,2);if (!ptr) return 0; *ptr++=']';*ptr=0; + out=(p->buffer)+i; + } + else + { + /* Allocate an array to hold the values for each */ + entries=(char**)cJSON_malloc(numentries*sizeof(char*)); + if (!entries) return 0; + memset(entries,0,numentries*sizeof(char*)); + /* Retrieve all the results: */ + child=item->child; + while (child && !fail) + { + ret=print_value(child,depth+1,fmt,0); + entries[i++]=ret; + if (ret) len+=strlen(ret)+2+(fmt?1:0); else fail=1; + child=child->next; + } + + /* If we didn't fail, try to malloc the output string */ + if (!fail) out=(char*)cJSON_malloc(len); + /* If that fails, we fail. */ + if (!out) fail=1; + + /* Handle failure. */ + if (fail) + { + for (i=0;itype=cJSON_Object; + value=skip(value+1); + if (*value=='}') return value+1; /* empty array. */ + + item->child=child=cJSON_New_Item(); + if (!item->child) return 0; + value=skip(parse_string(child,skip(value),ep)); + if (!value) return 0; + child->string=child->valuestring;child->valuestring=0; + if (*value!=':') {*ep=value;return 0;} /* fail! */ + value=skip(parse_value(child,skip(value+1),ep)); /* skip any spacing, get the value. */ + if (!value) return 0; + + while (*value==',') + { + cJSON *new_item; + if (!(new_item=cJSON_New_Item())) return 0; /* memory fail */ + child->next=new_item;new_item->prev=child;child=new_item; + value=skip(parse_string(child,skip(value+1),ep)); + if (!value) return 0; + child->string=child->valuestring;child->valuestring=0; + if (*value!=':') {*ep=value;return 0;} /* fail! */ + value=skip(parse_value(child,skip(value+1),ep)); /* skip any spacing, get the value. */ + if (!value) return 0; + } + + if (*value=='}') return value+1; /* end of array */ + *ep=value;return 0; /* malformed. */ +} + +/* Render an object to text. */ +static char *print_object(cJSON *item,int depth,int fmt,printbuffer *p) +{ + char **entries=0,**names=0; + char *out=0,*ptr,*ret,*str;int len=7,i=0,j; + cJSON *child=item->child; + int numentries=0,fail=0; + size_t tmplen=0; + /* Count the number of entries. */ + while (child) numentries++,child=child->next; + /* Explicitly handle empty object case */ + if (!numentries) + { + if (p) out=ensure(p,fmt?depth+4:3); + else out=(char*)cJSON_malloc(fmt?depth+4:3); + if (!out) return 0; + ptr=out;*ptr++='{'; + if (fmt) {*ptr++='\n';for (i=0;ioffset; + len=fmt?2:1; ptr=ensure(p,len+1); if (!ptr) return 0; + *ptr++='{'; if (fmt) *ptr++='\n'; *ptr=0; p->offset+=len; + child=item->child;depth++; + while (child) + { + if (fmt) + { + ptr=ensure(p,depth); if (!ptr) return 0; + for (j=0;joffset+=depth; + } + print_string_ptr(child->string,p); + p->offset=update(p); + + len=fmt?2:1; + ptr=ensure(p,len); if (!ptr) return 0; + *ptr++=':';if (fmt) *ptr++='\t'; + p->offset+=len; + + print_value(child,depth,fmt,p); + p->offset=update(p); + + len=(fmt?1:0)+(child->next?1:0); + ptr=ensure(p,len+1); if (!ptr) return 0; + if (child->next) *ptr++=','; + if (fmt) *ptr++='\n';*ptr=0; + p->offset+=len; + child=child->next; + } + ptr=ensure(p,fmt?(depth+1):2); if (!ptr) return 0; + if (fmt) for (i=0;ibuffer)+i; + } + else + { + /* Allocate space for the names and the objects */ + entries=(char**)cJSON_malloc(numentries*sizeof(char*)); + if (!entries) return 0; + names=(char**)cJSON_malloc(numentries*sizeof(char*)); + if (!names) {cJSON_free(entries);return 0;} + memset(entries,0,sizeof(char*)*numentries); + memset(names,0,sizeof(char*)*numentries); + + /* Collect all the results into our arrays: */ + child=item->child;depth++;if (fmt) len+=depth; + while (child && !fail) + { + names[i]=str=print_string_ptr(child->string,0); + entries[i++]=ret=print_value(child,depth,fmt,0); + if (str && ret) len+=strlen(ret)+strlen(str)+2+(fmt?2+depth:0); else fail=1; + child=child->next; + } + + /* Try to allocate the output string */ + if (!fail) out=(char*)cJSON_malloc(len); + if (!out) fail=1; + + /* Handle failure */ + if (fail) + { + for (i=0;ichild;int i=0;while(c)i++,c=c->next;return i;} +cJSON *cJSON_GetArrayItem(cJSON *array,int item) {cJSON *c=array?array->child:0;while (c && item>0) item--,c=c->next; return c;} +cJSON *cJSON_GetObjectItem(cJSON *object,const char *string) {cJSON *c=object?object->child:0;while (c && cJSON_strcasecmp(c->string,string)) c=c->next; return c;} +int cJSON_HasObjectItem(cJSON *object,const char *string) {return cJSON_GetObjectItem(object,string)?1:0;} + +/* Utility for array list handling. */ +static void suffix_object(cJSON *prev,cJSON *item) {prev->next=item;item->prev=prev;} +/* Utility for handling references. */ +static cJSON *create_reference(cJSON *item) {cJSON *ref=cJSON_New_Item();if (!ref) return 0;memcpy(ref,item,sizeof(cJSON));ref->string=0;ref->type|=cJSON_IsReference;ref->next=ref->prev=0;return ref;} + +/* Add item to array/object. */ +void cJSON_AddItemToArray(cJSON *array, cJSON *item) {cJSON *c=array->child;if (!item) return; if (!c) {array->child=item;} else {while (c && c->next) c=c->next; suffix_object(c,item);}} +void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (item->string) cJSON_free(item->string);item->string=cJSON_strdup(string);cJSON_AddItemToArray(object,item);} +void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item) {if (!item) return; if (!(item->type&cJSON_StringIsConst) && item->string) cJSON_free(item->string);item->string=(char*)string;item->type|=cJSON_StringIsConst;cJSON_AddItemToArray(object,item);} +void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item) {cJSON_AddItemToArray(array,create_reference(item));} +void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item) {cJSON_AddItemToObject(object,string,create_reference(item));} + +cJSON *cJSON_DetachItemFromArray(cJSON *array,int which) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return 0; + if (c->prev) c->prev->next=c->next;if (c->next) c->next->prev=c->prev;if (c==array->child) array->child=c->next;c->prev=c->next=0;return c;} +void cJSON_DeleteItemFromArray(cJSON *array,int which) {cJSON_Delete(cJSON_DetachItemFromArray(array,which));} +cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string) {int i=0;cJSON *c=object->child;while (c && cJSON_strcasecmp(c->string,string)) i++,c=c->next;if (c) return cJSON_DetachItemFromArray(object,i);return 0;} +void cJSON_DeleteItemFromObject(cJSON *object,const char *string) {cJSON_Delete(cJSON_DetachItemFromObject(object,string));} + +/* Replace array/object items with new ones. */ +void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) {cJSON_AddItemToArray(array,newitem);return;} + newitem->next=c;newitem->prev=c->prev;c->prev=newitem;if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;} +void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem) {cJSON *c=array->child;while (c && which>0) c=c->next,which--;if (!c) return; + newitem->next=c->next;newitem->prev=c->prev;if (newitem->next) newitem->next->prev=newitem; + if (c==array->child) array->child=newitem; else newitem->prev->next=newitem;c->next=c->prev=0;cJSON_Delete(c);} +void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem){int i=0;cJSON *c=object->child;while(c && cJSON_strcasecmp(c->string,string))i++,c=c->next;if(c){newitem->string=cJSON_strdup(string);cJSON_ReplaceItemInArray(object,i,newitem);}} + +/* Create basic types: */ +cJSON *cJSON_CreateNull(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_NULL;return item;} +cJSON *cJSON_CreateTrue(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_True;return item;} +cJSON *cJSON_CreateFalse(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_False;return item;} +cJSON *cJSON_CreateBool(int b) {cJSON *item=cJSON_New_Item();if(item)item->type=b?cJSON_True:cJSON_False;return item;} +cJSON *cJSON_CreateNumber(double num) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_Number;item->valuedouble=num;item->valueint=(int)num;}return item;} +cJSON *cJSON_CreateString(const char *string) {cJSON *item=cJSON_New_Item();if(item){item->type=cJSON_String;item->valuestring=cJSON_strdup(string);if(!item->valuestring){cJSON_Delete(item);return 0;}}return item;} +cJSON *cJSON_CreateArray(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Array;return item;} +cJSON *cJSON_CreateObject(void) {cJSON *item=cJSON_New_Item();if(item)item->type=cJSON_Object;return item;} + +/* Create Arrays: */ +cJSON *cJSON_CreateIntArray(const int *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;} +cJSON *cJSON_CreateFloatArray(const float *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;} +cJSON *cJSON_CreateDoubleArray(const double *numbers,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;} +cJSON *cJSON_CreateStringArray(const char **strings,int count) {int i;cJSON *n=0,*p=0,*a=cJSON_CreateArray();for(i=0;a && ichild=n;else suffix_object(p,n);p=n;}return a;} + +/* Duplication */ +cJSON *cJSON_Duplicate(cJSON *item,int recurse) +{ + cJSON *newitem,*cptr,*nptr=0,*newchild; + /* Bail on bad ptr */ + if (!item) return 0; + /* Create new item */ + newitem=cJSON_New_Item(); + if (!newitem) return 0; + /* Copy over all vars */ + newitem->type=item->type&(~cJSON_IsReference),newitem->valueint=item->valueint,newitem->valuedouble=item->valuedouble; + if (item->valuestring) {newitem->valuestring=cJSON_strdup(item->valuestring); if (!newitem->valuestring) {cJSON_Delete(newitem);return 0;}} + if (item->string) {newitem->string=cJSON_strdup(item->string); if (!newitem->string) {cJSON_Delete(newitem);return 0;}} + /* If non-recursive, then we're done! */ + if (!recurse) return newitem; + /* Walk the ->next chain for the child. */ + cptr=item->child; + while (cptr) + { + newchild=cJSON_Duplicate(cptr,1); /* Duplicate (with recurse) each item in the ->next chain */ + if (!newchild) {cJSON_Delete(newitem);return 0;} + if (nptr) {nptr->next=newchild,newchild->prev=nptr;nptr=newchild;} /* If newitem->child already set, then crosswire ->prev and ->next and move on */ + else {newitem->child=newchild;nptr=newchild;} /* Set newitem->child and move to it */ + cptr=cptr->next; + } + return newitem; +} + +void cJSON_Minify(char *json) +{ + char *into=json; + while (*json) + { + if (*json==' ') json++; + else if (*json=='\t') json++; /* Whitespace characters. */ + else if (*json=='\r') json++; + else if (*json=='\n') json++; + else if (*json=='/' && json[1]=='/') while (*json && *json!='\n') json++; /* double-slash comments, to end of line. */ + else if (*json=='/' && json[1]=='*') {while (*json && !(*json=='*' && json[1]=='/')) json++;json+=2;} /* multiline comments. */ + else if (*json=='\"'){*into++=*json++;while (*json && *json!='\"'){if (*json=='\\') *into++=*json++;*into++=*json++;}*into++=*json++;} /* string literals, which are \" sensitive. */ + else *into++=*json++; /* All other characters. */ + } + *into=0; /* and null-terminate. */ +} diff --git a/LFtid1056/pqdif/include/cjson.h b/LFtid1056/pqdif/include/cjson.h new file mode 100644 index 0000000..3a587cb --- /dev/null +++ b/LFtid1056/pqdif/include/cjson.h @@ -0,0 +1,153 @@ +/* + Copyright (c) 2009 Dave Gamble + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. +*/ + +#ifndef cJSON__h +#define cJSON__h + +#ifdef __cplusplus +extern "C" +{ +#endif + +/* cJSON Types: */ +#define cJSON_False (1 << 0) +#define cJSON_True (1 << 1) +#define cJSON_NULL (1 << 2) +#define cJSON_Number (1 << 3) +#define cJSON_String (1 << 4) +#define cJSON_Array (1 << 5) +#define cJSON_Object (1 << 6) + +#define cJSON_IsReference 256 +#define cJSON_StringIsConst 512 + +/* The cJSON structure: */ +typedef struct cJSON { + struct cJSON *next,*prev; /* next/prev allow you to walk array/object chains. Alternatively, use GetArraySize/GetArrayItem/GetObjectItem */ + struct cJSON *child; /* An array or object item will have a child pointer pointing to a chain of the items in the array/object. */ + + int type; /* The type of the item, as above. */ + + char *valuestring; /* The item's string, if type==cJSON_String */ + int valueint; /* The item's number, if type==cJSON_Number */ + double valuedouble; /* The item's number, if type==cJSON_Number */ + + char *string; /* The item's name string, if this item is the child of, or is in the list of subitems of an object. */ +} cJSON; + +typedef struct cJSON_Hooks { + void *(*malloc_fn)(size_t sz); + void (*free_fn)(void *ptr); +} cJSON_Hooks; + +/* Supply malloc, realloc and free functions to cJSON */ +extern void cJSON_InitHooks(cJSON_Hooks* hooks); + + +/* Supply a block of JSON, and this returns a cJSON object you can interrogate. Call cJSON_Delete when finished. */ +extern cJSON *cJSON_Parse(const char *value); +/* Render a cJSON entity to text for transfer/storage. Free the char* when finished. */ +extern char *cJSON_Print(cJSON *item); +/* Render a cJSON entity to text for transfer/storage without any formatting. Free the char* when finished. */ +extern char *cJSON_PrintUnformatted(cJSON *item); +/* Render a cJSON entity to text using a buffered strategy. prebuffer is a guess at the final size. guessing well reduces reallocation. fmt=0 gives unformatted, =1 gives formatted */ +extern char *cJSON_PrintBuffered(cJSON *item,int prebuffer,int fmt); +/* Delete a cJSON entity and all subentities. */ +extern void cJSON_Delete(cJSON *c); + +/* Returns the number of items in an array (or object). */ +extern int cJSON_GetArraySize(cJSON *array); +/* Retrieve item number "item" from array "array". Returns NULL if unsuccessful. */ +extern cJSON *cJSON_GetArrayItem(cJSON *array,int item); +/* Get item "string" from object. Case insensitive. */ +extern cJSON *cJSON_GetObjectItem(cJSON *object,const char *string); +extern int cJSON_HasObjectItem(cJSON *object,const char *string); +/* For analysing failed parses. This returns a pointer to the parse error. You'll probably need to look a few chars back to make sense of it. Defined when cJSON_Parse() returns 0. 0 when cJSON_Parse() succeeds. */ +extern const char *cJSON_GetErrorPtr(void); + +/* These calls create a cJSON item of the appropriate type. */ +extern cJSON *cJSON_CreateNull(void); +extern cJSON *cJSON_CreateTrue(void); +extern cJSON *cJSON_CreateFalse(void); +extern cJSON *cJSON_CreateBool(int b); +extern cJSON *cJSON_CreateNumber(double num); +extern cJSON *cJSON_CreateString(const char *string); +extern cJSON *cJSON_CreateArray(void); +extern cJSON *cJSON_CreateObject(void); + +/* These utilities create an Array of count items. */ +extern cJSON *cJSON_CreateIntArray(const int *numbers,int count); +extern cJSON *cJSON_CreateFloatArray(const float *numbers,int count); +extern cJSON *cJSON_CreateDoubleArray(const double *numbers,int count); +extern cJSON *cJSON_CreateStringArray(const char **strings,int count); + +/* Append item to the specified array/object. */ +extern void cJSON_AddItemToArray(cJSON *array, cJSON *item); +extern void cJSON_AddItemToObject(cJSON *object,const char *string,cJSON *item); +extern void cJSON_AddItemToObjectCS(cJSON *object,const char *string,cJSON *item); /* Use this when string is definitely const (i.e. a literal, or as good as), and will definitely survive the cJSON object */ +/* Append reference to item to the specified array/object. Use this when you want to add an existing cJSON to a new cJSON, but don't want to corrupt your existing cJSON. */ +extern void cJSON_AddItemReferenceToArray(cJSON *array, cJSON *item); +extern void cJSON_AddItemReferenceToObject(cJSON *object,const char *string,cJSON *item); + +/* Remove/Detatch items from Arrays/Objects. */ +extern cJSON *cJSON_DetachItemFromArray(cJSON *array,int which); +extern void cJSON_DeleteItemFromArray(cJSON *array,int which); +extern cJSON *cJSON_DetachItemFromObject(cJSON *object,const char *string); +extern void cJSON_DeleteItemFromObject(cJSON *object,const char *string); + +/* Update array items. */ +extern void cJSON_InsertItemInArray(cJSON *array,int which,cJSON *newitem); /* Shifts pre-existing items to the right. */ +extern void cJSON_ReplaceItemInArray(cJSON *array,int which,cJSON *newitem); +extern void cJSON_ReplaceItemInObject(cJSON *object,const char *string,cJSON *newitem); + +/* Duplicate a cJSON item */ +extern cJSON *cJSON_Duplicate(cJSON *item,int recurse); +/* Duplicate will create a new, identical cJSON item to the one you pass, in new memory that will +need to be released. With recurse!=0, it will duplicate any children connected to the item. +The item->next and ->prev pointers are always zero on return from Duplicate. */ + +/* ParseWithOpts allows you to require (and check) that the JSON is null terminated, and to retrieve the pointer to the final byte parsed. */ +/* If you supply a ptr in return_parse_end and parsing fails, then return_parse_end will contain a pointer to the error. If not, then cJSON_GetErrorPtr() does the job. */ +extern cJSON *cJSON_ParseWithOpts(const char *value,const char **return_parse_end,int require_null_terminated); + +extern void cJSON_Minify(char *json); + +/* Macros for creating things quickly. */ +#define cJSON_AddNullToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateNull()) +#define cJSON_AddTrueToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateTrue()) +#define cJSON_AddFalseToObject(object,name) cJSON_AddItemToObject(object, name, cJSON_CreateFalse()) +#define cJSON_AddBoolToObject(object,name,b) cJSON_AddItemToObject(object, name, cJSON_CreateBool(b)) +#define cJSON_AddNumberToObject(object,name,n) cJSON_AddItemToObject(object, name, cJSON_CreateNumber(n)) +#define cJSON_AddStringToObject(object,name,s) cJSON_AddItemToObject(object, name, cJSON_CreateString(s)) + +/* When assigning an integer value, it needs to be propagated to valuedouble too. */ +#define cJSON_SetIntValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) +#define cJSON_SetNumberValue(object,val) ((object)?(object)->valueint=(object)->valuedouble=(val):(val)) + +/* Macro for iterating over an array */ +#define cJSON_ArrayForEach(pos, head) for(pos = (head)->child; pos != NULL; pos = pos->next) + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/LFtid1056/pqdif/include/el_base.cpp b/LFtid1056/pqdif/include/el_base.cpp new file mode 100644 index 0000000..901e74a --- /dev/null +++ b/LFtid1056/pqdif/include/el_base.cpp @@ -0,0 +1,564 @@ +/* +** CPQDIF_Element class. The base class for PQDIF elements. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: el_base.cpp $ +** Last modified: $Modtime: 11/13/00 3:40p $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_base.cpp $ +** VCS revision: $Revision: 13 $ +*/ +#include "PQDIF_classes.h" + +CPQDIF_Element::CPQDIF_Element() +{ + m_pRecord = NULL; + memset( &m_tag, 0, sizeof( m_tag ) ); + m_typePhysical = 0; +} + + +#ifdef PQDIF_USE_COM +bool CPQDIF_Element::convertFromVariant( const VARIANT & value, PQDIFValue& m_value ) const + { + bool status = true; + INT1 val_int1; + INT2 val_int2; + INT4 val_int4; + + // First, verify the variant physical type matches + // (and pull out the integer values) + status = TRUE; + switch( m_typePhysical ) + { + case ID_PHYS_TYPE_BOOLEAN1 : + case ID_PHYS_TYPE_BOOLEAN2 : + case ID_PHYS_TYPE_BOOLEAN4 : + if( value.vt != VT_BOOL ) + status = false; + break; + + case ID_PHYS_TYPE_CHAR1 : + case ID_PHYS_TYPE_INTEGER1 : + case ID_PHYS_TYPE_UNS_INTEGER1 : + switch( value.vt ) + { + case VT_UI1: + val_int1 = (INT1) value.bVal; + break; + + case VT_I1: + val_int1 = (INT1) value.cVal; + break; + + default: + status = false; + } + break; + + case ID_PHYS_TYPE_CHAR2 : + case ID_PHYS_TYPE_INTEGER2 : + case ID_PHYS_TYPE_UNS_INTEGER2 : + switch( value.vt ) + { + case VT_UI2: + val_int2 = (INT2) value.uiVal; + break; + + case VT_I2: + val_int2 = (INT2) value.iVal; + break; + + default: + status = false; + } + break; + + case ID_PHYS_TYPE_INTEGER4 : + case ID_PHYS_TYPE_UNS_INTEGER4 : + switch( value.vt ) + { + case VT_UI4: + val_int4 = (INT4) value.ulVal; + break; + + case VT_I4: + val_int4 = (INT4) value.lVal; + break; + + default: + status = false; + } + break; + + // Real/complex + case ID_PHYS_TYPE_REAL4 : + if( value.vt != VT_R4 ) + status = false; + break; + + case ID_PHYS_TYPE_REAL8 : + if( value.vt != VT_R4 ) + status = false; + break; + + case ID_PHYS_TYPE_COMPLEX8 : + case ID_PHYS_TYPE_COMPLEX16 : + //if( value.vt == VT_ARRAY ) ??? + break; + + case ID_PHYS_TYPE_TIMESTAMPPQDIF : + if( value.vt != VT_DATE ) + status = false; + break; + + case ID_PHYS_TYPE_GUID : + //if( value.vt == VT_ARRAY ) ??? + break; + + default: + status = false; + break; + } + + if( status ) + { + switch( m_typePhysical ) + { + case ID_PHYS_TYPE_BOOLEAN1 : + m_value.bool1 = (BOOL1) value.boolVal; + case ID_PHYS_TYPE_BOOLEAN2 : + m_value.bool2 = (BOOL2) value.boolVal; + case ID_PHYS_TYPE_BOOLEAN4 : + m_value.bool4 = (BOOL4) value.boolVal; + break; + + case ID_PHYS_TYPE_CHAR1 : + m_value.char1 = (CHAR1) val_int1; + break; + case ID_PHYS_TYPE_INTEGER1 : + m_value.int1 = (INT1) val_int1; + break; + case ID_PHYS_TYPE_UNS_INTEGER1 : + m_value.uint1 = (UINT1) val_int1; + break; + + case ID_PHYS_TYPE_CHAR2 : + m_value.char2 = (CHAR2) val_int2; + break; + case ID_PHYS_TYPE_INTEGER2 : + m_value.int2 = (INT2) val_int2; + break; + case ID_PHYS_TYPE_UNS_INTEGER2 : + m_value.uint2 = (UINT2) val_int2; + break; + + case ID_PHYS_TYPE_INTEGER4 : + m_value.int4 = (INT4) val_int4; + break; + case ID_PHYS_TYPE_UNS_INTEGER4 : + m_value.uint4 = (UINT4) val_int4; + break; + + // Real/complex + case ID_PHYS_TYPE_REAL4 : + m_value.real4 = (REAL4) value.fltVal; + break; + case ID_PHYS_TYPE_REAL8 : + m_value.real8 = (REAL8) value.dblVal; + break; + + case ID_PHYS_TYPE_COMPLEX8 : + case ID_PHYS_TYPE_COMPLEX16 : + // need to fix + // SAFEARRAY? + break; + + // Date/time + case ID_PHYS_TYPE_TIMESTAMPPQDIF : + // From the documentation, it appears that the + // whole number portion of the DATE is compatible + // with our .day member. (Although it is possible that + // they will be off by 1 day...) + m_value.ts.day = (UINT4) ( value.date ); + + // Convert the fractional day to fractional seconds. + m_value.ts.sec = (REAL8) ( value.date - (DATE) m_value.ts.day ); + m_value.ts.sec *= (REAL8) SECONDS_PER_DAY; + break; + + // GUID + case ID_PHYS_TYPE_GUID : + // need to fix + // SAFEARRAY? + break; + + default: + status = false; + break; + } + } + + return status; + } + + +bool CPQDIF_Element::convertToVariant( const PQDIFValue& m_value, VARIANT & value ) const + { + bool status = true; + string strRep; + + VariantInit( &value ); + + USES_CONVERSION; + + if( status ) + { + switch( m_typePhysical ) + { + case ID_PHYS_TYPE_BOOLEAN1 : + value.vt = VT_BOOL; + value.boolVal = m_value.bool1; + break; + + case ID_PHYS_TYPE_CHAR1 : + value.vt = VT_I1; + value.cVal = m_value.char1; + break; + + case ID_PHYS_TYPE_INTEGER1 : + value.vt = VT_I1; + value.cVal = m_value.int1; + break; + + case ID_PHYS_TYPE_UNS_INTEGER1 : + // VT_UI1 / value.bVal + value.vt = VT_I1; + value.cVal = m_value.uint1; + break; + + case ID_PHYS_TYPE_BOOLEAN2 : + value.vt = VT_BOOL; + value.boolVal = m_value.bool2; + break; + + case ID_PHYS_TYPE_CHAR2 : + // Single-char Unicode string instead? + value.vt = VT_I2; + value.iVal = m_value.char2; + break; + + case ID_PHYS_TYPE_INTEGER2 : + value.vt = VT_I2; + value.iVal = m_value.int2; + break; + + case ID_PHYS_TYPE_UNS_INTEGER2 : + //VT_UI2 / uiVal + value.vt = VT_I2; + value.iVal = m_value.uint2 ; + break; + + case ID_PHYS_TYPE_BOOLEAN4 : + value.vt = VT_BOOL; + value.boolVal = (VARIANT_BOOL) m_value.bool4; + break; + + case ID_PHYS_TYPE_INTEGER4 : + value.vt = VT_I4; + value.lVal = m_value.int4; + break; + + case ID_PHYS_TYPE_UNS_INTEGER4 : + // VT_UI4 / ulVal + value.vt = VT_I4; + value.lVal = m_value.uint4; + break; + + // Real/complex + case ID_PHYS_TYPE_REAL4 : + value.vt = VT_R4; + value.fltVal = m_value.real4; + break; + + case ID_PHYS_TYPE_REAL8 : + value.vt = VT_R8; + value.dblVal = m_value.real8; + break; + + case ID_PHYS_TYPE_COMPLEX8 : + case ID_PHYS_TYPE_COMPLEX16 : + // need to fix + // SAFEARRAY? + //value.vt = VT_ARRAY; + //value.parray = NULL; + + // In string form ("real imag") +// strRep = _T( "" ); + strRep = ""; + char szBuffer[64]; + + if( m_typePhysical == ID_PHYS_TYPE_COMPLEX8 ) + { + sprintf( szBuffer, "%.8g %.8g", + m_value.complex8.real, + m_value.complex8.image ); + strRep = szBuffer; + } + else + { + sprintf( szBuffer, "%.16g %.16g", + m_value.complex16.real, + m_value.complex16.image ); + strRep = szBuffer; + } + + value.vt = VT_BSTR; +#if _MSC_VER >= 1100 + value.bstrVal = SysAllocString(_bstr_t(strRep.c_str())); +#else + value.bstrVal = SysAllocString(A2W(strRep.c_str())); +#endif + break; + + // Date/time + case ID_PHYS_TYPE_TIMESTAMPPQDIF : + value.vt = VT_DATE; + value.date = (double) m_value.ts.day + + ( (double) m_value.ts.sec / (double) SECONDS_PER_DAY ); + break; + + // GUID + case ID_PHYS_TYPE_GUID : + status = theSupport.NewVariantArrayFromGUID( value, m_value.guid ); + // need to fix + // SAFEARRAY? + //value.vt = VT_ARRAY; + //value.parray = NULL; + //unsigned char ** pstrRPC; + // Generate a GUID string + //UuidToString( &m_value.guid, pstrRPC ); + //RpcStringFree( pstrRPC ); + + // String in this format: + // {89738618-F1C3-11cf-9D89-0080C72E70A3} + //{ + //char * pstr = strRep.GetBuffer( 64 ); + //sprintf( pstr, "{%08.8lx-%04.4x-%04.4x-%02.2x%02.2x%02.2x%02.2x}", + // m_value.guid.Data1, + // m_value.guid.Data2, + // m_value.guid.Data3, + // (short) m_value.guid.Data4[ 0 ], + // (short) m_value.guid.Data4[ 1 ], + // (short) m_value.guid.Data4[ 2 ], + // (short) m_value.guid.Data4[ 3 ] + // ); + //strRep.ReleaseBuffer(); + //} + // Return it back in the variant... + //value.vt = VT_BSTR | VT_BYREF; + //*value.pbstrVal = strRep.AllocSysString(); + //value.vt = VT_BSTR; + //value.bstrVal = strRep.AllocSysString(); + break; + + default: + status = false; + break; + } + } + + return status; + } +#endif + +bool CPQDIF_Element::convertFromDouble( double valueSource, PQDIFValue& valueTarget ) const +{ + bool status = true; + + // First, verify the variant physical type matches + // (and pull out the integer values) + if( status ) + { + switch( m_typePhysical ) + { + case ID_PHYS_TYPE_BOOLEAN1 : + valueTarget.bool1 = (BOOL1) valueSource; + break; + case ID_PHYS_TYPE_BOOLEAN2 : + valueTarget.bool2 = (BOOL2) valueSource; + break; + case ID_PHYS_TYPE_BOOLEAN4 : + valueTarget.bool4 = (BOOL4) valueSource; + break; + + case ID_PHYS_TYPE_CHAR1 : + valueTarget.char1 = (CHAR1) valueSource; + break; + case ID_PHYS_TYPE_INTEGER1 : + valueTarget.int1 = (INT1) valueSource; + break; + case ID_PHYS_TYPE_UNS_INTEGER1 : + valueTarget.uint1 = (UINT1) valueSource; + break; + + case ID_PHYS_TYPE_CHAR2 : + valueTarget.char2 = (CHAR2) valueSource; + break; + case ID_PHYS_TYPE_INTEGER2 : + valueTarget.int2 = (INT2) valueSource; + break; + case ID_PHYS_TYPE_UNS_INTEGER2 : + valueTarget.uint2 = (UINT2) valueSource; + break; + + case ID_PHYS_TYPE_INTEGER4 : + valueTarget.int4 = (INT4) valueSource; + break; + case ID_PHYS_TYPE_UNS_INTEGER4 : + valueTarget.uint4 = (UINT4) valueSource; + break; + + // Real/complex + case ID_PHYS_TYPE_REAL4 : + valueTarget.real4 = (REAL4) valueSource; + break; + case ID_PHYS_TYPE_REAL8 : + valueTarget.real8 = (REAL8) valueSource; + break; + + case ID_PHYS_TYPE_COMPLEX8 : + valueTarget.complex8.real = (REAL4) valueSource; + valueTarget.complex8.image = 0.0; + break; + + case ID_PHYS_TYPE_COMPLEX16 : + valueTarget.complex16.real = (REAL4) valueSource; + valueTarget.complex16.image = 0.0; + break; + + // Date/time + case ID_PHYS_TYPE_TIMESTAMPPQDIF : + // From the documentation, it appears that the + // whole number portion of the DATE is compatible + // with our .day member. (Although it is possible that + // they will be off by 1 day...) + valueTarget.ts.day = (UINT4) ( valueSource ); + + // Convert the fractional day to fractional seconds. + valueTarget.ts.sec = (REAL8) ( valueSource - (double) valueTarget.ts.day ); + valueTarget.ts.sec *= (REAL8) SECONDS_PER_DAY; + break; + + // GUID + case ID_PHYS_TYPE_GUID : + // Cannot convert from double. + break; + + default: + status = false; + break; + } + } + + return status; +} + + +bool CPQDIF_Element::convertToDouble( const PQDIFValue& valueSource, double& valueTarget ) const +{ + bool status = true; + + valueTarget = 0.0; + + if( status ) + { + switch( m_typePhysical ) + { + case ID_PHYS_TYPE_BOOLEAN1 : + valueTarget = (double) valueSource.bool1; + break; + + case ID_PHYS_TYPE_CHAR1 : + valueTarget = (double) valueSource.char1; + break; + + case ID_PHYS_TYPE_INTEGER1 : + valueTarget = (double) valueSource.int1; + break; + + case ID_PHYS_TYPE_UNS_INTEGER1 : + valueTarget = (double) valueSource.uint1; + break; + + case ID_PHYS_TYPE_BOOLEAN2 : + valueTarget = (double) valueSource.bool2; + break; + + case ID_PHYS_TYPE_CHAR2 : + // Single-char Unicode string instead? + valueTarget = (double) valueSource.char2; + break; + + case ID_PHYS_TYPE_INTEGER2 : + valueTarget = (double) valueSource.int2; + break; + + case ID_PHYS_TYPE_UNS_INTEGER2 : + valueTarget = (double) valueSource.uint2 ; + break; + + case ID_PHYS_TYPE_BOOLEAN4 : + valueTarget = (double) valueSource.bool4; + break; + + case ID_PHYS_TYPE_INTEGER4 : + valueTarget = (double) valueSource.int4; + break; + + case ID_PHYS_TYPE_UNS_INTEGER4 : + valueTarget = (double) valueSource.uint4; + break; + + // Real/complex + case ID_PHYS_TYPE_REAL4 : + valueTarget = (double) valueSource.real4; + break; + + case ID_PHYS_TYPE_REAL8 : + valueTarget = (double) valueSource.real8; + break; + + case ID_PHYS_TYPE_COMPLEX8 : + case ID_PHYS_TYPE_COMPLEX16 : + // Cannot convert to double. + break; + + // Date/time + case ID_PHYS_TYPE_TIMESTAMPPQDIF : + //valueTarget.vt = VT_DATE; + valueTarget = (double) valueSource.ts.day + + ( (double) valueSource.ts.sec / (double) SECONDS_PER_DAY ); + break; + + // GUID + case ID_PHYS_TYPE_GUID : + // Cannot convert to double. + break; + + default: + status = false; + break; + } + } + + return status; +} + + +long CPQDIF_Element::getNumBytesOfType( void ) const +{ + return theInfo.GetNumBytesOfType( m_typePhysical ); +} + diff --git a/LFtid1056/pqdif/include/el_base.h b/LFtid1056/pqdif/include/el_base.h new file mode 100644 index 0000000..58dd4d8 --- /dev/null +++ b/LFtid1056/pqdif/include/el_base.h @@ -0,0 +1,102 @@ +/* +** class CPQDIF_Element +** -------------------------------------------------------------------------- +** +** File name: $Workfile: el_base.h $ +** Last modified: $Modtime: 12/01/00 8:34a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_base.h $ +** VCS revision: $Revision: 11 $ +*/ + +union PQDIFValue + { + BOOL1 bool1; + BOOL2 bool2; + BOOL4 bool4; + + CHAR1 char1; // ASCII string character + CHAR2 char2; // Unicode string character + + INT1 int1; + INT2 int2; + INT4 int4; + + UINT1 uint1; + UINT2 uint2; + UINT4 uint4; + + REAL4 real4; + REAL8 real8; + COMPLEX8 complex8; + COMPLEX16 complex16; + + TIMESTAMPPQDIF ts; + + GUID guid; + }; + + +class CPQDIF_Element + { + // Construct/destruct + public: + CPQDIF_Element(); + virtual ~CPQDIF_Element() {} + + // Operator(s) + public: + + // Attributes + public: + virtual long GetElementType( void ) const + {return -1; } + + inline CPQDIFRecord * GetRecord( void ) + { + return m_pRecord; + } + virtual void SetRecord( CPQDIFRecord * pRecord ) + { + m_pRecord = pRecord; + } + + // Operations + public: + inline const GUID& GetTag( void ) const + { return m_tag; } + inline void SetTag( const GUID& tag ) + { + m_tag = tag; + if( m_pRecord ) + m_pRecord->SetChanged( true ); + } + inline long GetPhysicalType( void ) const + { return m_typePhysical; } + virtual void SetPhysicalType( long type ) + { + m_typePhysical = type; + if( m_pRecord ) + m_pRecord->SetChanged( true ); + } + + // Implementation + protected: +#ifdef PQDIF_USE_COM // if COM support, then VARIANT is available + bool convertToVariant( const PQDIFValue& valuePQDIF, VARIANT & valueVariant ) const; + bool convertFromVariant( const VARIANT & valueVariant, PQDIFValue& valuePQDIF ) const; +#endif + bool convertToDouble( const PQDIFValue& m_value, double& value ) const; + bool convertFromDouble( double value, PQDIFValue& m_value ) const; + long getNumBytesOfType( void ) const; + inline BYTE * getPointerToValue( PQDIFValue& value ) const { return (BYTE *)&value; } + inline const BYTE * getPointerToValue( const PQDIFValue& value ) const { return (const BYTE *)&value; } + + // Member data + protected: + GUID m_tag; // Tag for this element. + long m_typePhysical; // Physical type for this element. + CPQDIFRecord * m_pRecord; // The record that this element + // is associated with. + }; diff --git a/LFtid1056/pqdif/include/el_coll.cpp b/LFtid1056/pqdif/include/el_coll.cpp new file mode 100644 index 0000000..e5d46f2 --- /dev/null +++ b/LFtid1056/pqdif/include/el_coll.cpp @@ -0,0 +1,419 @@ +/* +** CPQDIF_E_Collection class. Implements the PQDIF collection element. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: el_coll.cpp $ +** Last modified: $Modtime: 11/21/00 10:59a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_coll.cpp $ +** VCS revision: $Revision: 17 $ +*/ +#include "PQDIF_classes.h" + + + +// Local constants +const char cTerminator = '\0'; + + +// Relational operators for for ordering a collection. +bool operator<( const CPQDIF_Element * pel, const GUID &tag ) +{ + return ( memcmp( &(pel->GetTag()), &tag, sizeof( tag ) ) < 0 ); +} + +bool operator<( const GUID &tag, const CPQDIF_Element * pel ) +{ + return ( memcmp( &tag, &(pel->GetTag()), sizeof( tag ) ) < 0 ); +} + + +// Construction +// ============ + +CPQDIF_E_Collection::CPQDIF_E_Collection() +{ + m_array.reserve( 32 ); +} + + +CPQDIF_E_Collection::~CPQDIF_E_Collection() +{ + + // Destroy all elements in the array + CArrayElements::iterator iter; + for( iter = m_array.begin(); iter != m_array.end(); iter++ ) + { + delete *iter; + *iter = NULL; + } + +} + + +long CPQDIF_E_Collection::GetCount( void ) const +{ + return m_array.size(); +} + + +CPQDIF_Element * CPQDIF_E_Collection::GetElement( long index ) const +{ + CPQDIF_Element * pel = NULL; + + if( index >= 0 && index < GetCount() ) + { + pel = m_array[ index ]; + } + + return pel; +} + + +CPQDIF_Element * CPQDIF_E_Collection::GetElement( const GUID& tag, long elementType ) const +{ + CPQDIF_Element * pelReturn = NULL; + + // See if specified element is in the collection. + CArrayElements::const_iterator iter; + iter = lower_bound( m_array.begin(), m_array.end(), tag ); + while( pelReturn == NULL + && iter != m_array.end() + && *iter != NULL + && PQDIF_IsEqualGUID( (*iter)->GetTag(), tag ) ) + { + // Matching type. + if( elementType == -1 + || elementType == (*iter)->GetElementType() ) + { + pelReturn = *iter; + } + iter++; + } + + return pelReturn; +} + + +void CPQDIF_E_Collection::SetRecord( CPQDIFRecord * pRecord ) +{ + CPQDIF_Element * pel; + + // Call the base class method. + CPQDIF_Element::SetRecord( pRecord ); + + // Do the same thing to the objects we own + CArrayElements::iterator iter; + for( iter = m_array.begin(); iter != m_array.end(); iter++ ) + { + pel = *iter; + //ASSERT_VALID( pel ); + if( pel ) + { + pel->SetRecord( pRecord ); + } + } + + return; +} + + +void CPQDIF_E_Collection::Add( CPQDIF_Element * pel ) +{ + + // Add the element to the collection. + CArrayElements::iterator iter = upper_bound( m_array.begin(), m_array.end(), pel->GetTag() ); + m_array.insert( iter, pel ); + + // Set the element to reference the collections record. + if( pel ) + pel->SetRecord( GetRecord() ); + + // Signal that the record has changed. + if( m_pRecord ) + m_pRecord->SetChanged( true ); +} + + +// Should this delete the element or not? +void CPQDIF_E_Collection::RemoveAt( long index ) +{ + + // If a valid element was specified then .... + //ASSERT( index >= 0 && index < GetCount() ); + if( index >= 0 && index < GetCount() ) + { + + // Dereference the element. + CArrayElements::iterator where = m_array.begin(); + where += index; + CPQDIF_Element * pel = *where; + + // Clear the element's reference to the record. + if( pel ) + pel->SetRecord( NULL ); + + // Remove it from the list. + m_array.erase( where ); + + // Mark the collection as dirty. + if( m_pRecord ) + m_pRecord->SetChanged( true ); + + } +} + + +void CPQDIF_E_Collection::AddOrReplace( CPQDIF_Element * pel ) +{ + + bool bFound = false; + CPQDIF_Element * pelToCompare = NULL; + const GUID & tagToAdd = pel->GetTag(); + + // See if this tag already exists + CArrayElements::iterator iter; + iter = lower_bound( m_array.begin(), m_array.end(), tagToAdd ); + if( iter != m_array.end() ) + { + pelToCompare = *iter; + if( pelToCompare ) + { + + // Matching tags? + if( PQDIF_IsEqualGUID( pelToCompare->GetTag(), tagToAdd ) ) + { + + // Delete the old element. + delete pelToCompare; + + // Add the new element to the collection. + *iter = pel; + + // Signal that the element is found. + bFound = true; + + } + } + } + + // If an existing element was not found then add the element. + if( !bFound ) + { + m_array.insert( iter, pel ); + } + + // Set the element to reference the collections record. + if( pel ) + pel->SetRecord( GetRecord() ); + + // Signal that the record has changed. + if( m_pRecord ) + m_pRecord->SetChanged( true ); + +} + + +void CPQDIF_E_Collection::SetVectorString + ( + const GUID& tagElement, + const char * text, + bool allowReplace + ) +{ + CPQDIF_E_Vector * pvectString; + + if( text ) + { + // Create the new vector to hold the string + pvectString = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); + if( pvectString ) + { + // Set it up ... + pvectString->SetTag( tagElement ); + pvectString->SetPhysicalType( ID_PHYS_TYPE_CHAR1 ); + pvectString->SetValues( text ); + + // Add it + if( allowReplace ) + AddOrReplace( pvectString ); + else + Add( pvectString ); + } + } +} + + +// Parameterized SetVector...() functions +// ====================================== +#define SETVECTOR( nametype, type, idtype ) \ +void CPQDIF_E_Collection::SetVector##nametype \ + ( const GUID& tagElement, \ + const type * values, \ + long count, \ + bool allowReplace ) \ +{ \ + CPQDIF_E_Vector * pvect; \ + if( values ) \ + { \ + /* Create the new vector to hold the string */ \ + pvect = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); \ + if( pvect ) \ + { \ + /* Set it up ... */ \ + pvect->SetTag( tagElement ); \ + pvect->SetPhysicalType( idtype ); \ + pvect->SetValues##nametype( values, count ); \ + /* Add it */ \ + if( allowReplace ) \ + AddOrReplace( pvect ); \ + else \ + Add( pvect ); \ + } \ + } \ +} + + +SETVECTOR( INT1, INT1, ID_PHYS_TYPE_INTEGER1 ); +SETVECTOR( INT2, INT2, ID_PHYS_TYPE_INTEGER2 ); +SETVECTOR( INT4, INT4, ID_PHYS_TYPE_INTEGER4 ); +SETVECTOR( UINT4, UINT4, ID_PHYS_TYPE_UNS_INTEGER4 ); +SETVECTOR( REAL4, REAL4, ID_PHYS_TYPE_REAL4 ); +SETVECTOR( REAL8, REAL8, ID_PHYS_TYPE_REAL8 ); +SETVECTOR( TimeStamp, TIMESTAMPPQDIF, ID_PHYS_TYPE_TIMESTAMPPQDIF ); + + +bool CPQDIF_E_Collection::GetVectorString + ( + const GUID& tagElement, + char * text, + long max + ) const +{ + bool status = false; + const CPQDIF_Element * pel; + string values; + + pel = GetElement( tagElement ); + if( pel && pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR ) + { + const CPQDIF_E_Vector * pvect = (const CPQDIF_E_Vector *) pel; + status = pvect->GetValues( values ); + if( status ) + { +#ifdef WIN32 + strncpy_s(text, strlen(text),values.c_str(), max); +#else + strncpy(text, values.c_str(), max); + +#endif // WIN32 + + text[ max - 1 ] = cTerminator; + } + } + + return status; +} + + +// Parameterized GetVector...() functions +// ====================================== +#define GETVECTOR( nametype, type ) \ +long CPQDIF_E_Collection::GetVector##nametype \ + ( \ + const GUID& tagElement, \ + type * values, \ + long max \ + ) const \ +{ \ + long sizeActual = 0; \ + const CPQDIF_Element * pel; \ + pel = GetElement( tagElement ); \ + if( pel && pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR ) \ + { \ + const CPQDIF_E_Vector * pvect = (const CPQDIF_E_Vector *) pel; \ + sizeActual = pvect->GetValues##nametype( values, max ); \ + } \ + return sizeActual; \ +} + + +GETVECTOR( INT1, INT1 ); +GETVECTOR( INT2, INT2 ); +GETVECTOR( INT4, INT4 ); +GETVECTOR( UINT4, UINT4 ); +GETVECTOR( REAL4, REAL4 ); +GETVECTOR( REAL8, REAL8 ); +GETVECTOR( TimeStamp, TIMESTAMPPQDIF ); + + +// Parameterized SetScalar...() functions +// ====================================== +#define SETSCALAR( nametype, type ) \ +void CPQDIF_E_Collection::SetScalar##nametype \ + ( \ + const GUID& tagElement, \ + type value, \ + bool allowReplace \ + ) \ +{ \ + CPQDIF_E_Scalar * psc; \ + psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); \ + if( psc ) \ + { \ + psc->SetTag( tagElement ); \ + psc->SetValue##nametype( value ); \ + if( allowReplace ) \ + AddOrReplace( psc ); \ + else \ + Add( psc ); \ + } \ +} + + +SETSCALAR( BOOL4, bool ) +SETSCALAR( INT2, INT2 ) +SETSCALAR( UINT2, UINT2 ) +SETSCALAR( INT4, INT4 ) +SETSCALAR( UINT4, UINT4 ) +SETSCALAR( REAL4, REAL4 ) +SETSCALAR( REAL8, REAL8 ) +SETSCALAR( COMPLEX8, COMPLEX8 ) +SETSCALAR( COMPLEX16, COMPLEX16 ) +SETSCALAR( GUID, GUID ) +SETSCALAR( TimeStamp, TIMESTAMPPQDIF ) + + +// Parameterized GetScalar...() functions +// ====================================== +#define GETSCALAR( nametype, type ) \ +bool CPQDIF_E_Collection::GetScalar##nametype \ + ( \ + const GUID& tagElement, \ + type& value \ + ) const \ +{ \ + bool status = false; \ + const CPQDIF_Element * pel; \ + pel = GetElement( tagElement ); \ + if( pel && pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) \ + { \ + const CPQDIF_E_Scalar * psc = (const CPQDIF_E_Scalar *) pel; \ + status = psc->GetValue##nametype( value ); \ + } \ + return status; \ +} + + +GETSCALAR( BOOL4, bool ) +GETSCALAR( INT2, INT2 ) +GETSCALAR( UINT2, UINT2 ) +GETSCALAR( INT4, INT4 ) +GETSCALAR( UINT4, UINT4 ) +GETSCALAR( REAL4, REAL4 ) +GETSCALAR( REAL8, REAL8 ) +GETSCALAR( COMPLEX8, COMPLEX8 ) +GETSCALAR( COMPLEX16, COMPLEX16 ) +GETSCALAR( GUID, GUID ) +GETSCALAR( TimeStamp, TIMESTAMPPQDIF ) diff --git a/LFtid1056/pqdif/include/el_coll.h b/LFtid1056/pqdif/include/el_coll.h new file mode 100644 index 0000000..b41e1ff --- /dev/null +++ b/LFtid1056/pqdif/include/el_coll.h @@ -0,0 +1,279 @@ +// File name: $Workfile: el_coll.h $ +// Last modified: $Modtime: 11/20/00 2:27p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_coll.h $ +// VCS revision: $Revision: 13 $ + +//typedef list CClassInfoList; +typedef CPQDIF_Element * PElement; +typedef vector CArrayElements; + + +class CPQDIF_E_Collection : public CPQDIF_Element + { + public: + CPQDIF_E_Collection(); + virtual ~CPQDIF_E_Collection(); + + // Operator(s) + public: + + // Attributes + public: + virtual long GetElementType( void ) const + { return ID_ELEMENT_TYPE_COLLECTION; } + + virtual void SetRecord( CPQDIFRecord * pRecord ); + + // Operations + public: + // Read + long GetCount( void ) const; + CPQDIF_Element * GetElement( long index ) const; + CPQDIF_Element * GetElement( const GUID& tag, long elementType = -1 ) const; + + // Modify + void Add( CPQDIF_Element * pel ); + void RemoveAt( long index ); + void AddOrReplace( CPQDIF_Element * pel ); + + // Set vectors + void SetVectorString + ( + const GUID& tagElement, + const char * text, + bool allowReplace = true + ); + void SetVectorINT1 + ( + const GUID& tagElement, + const INT1 * values, + long count, + bool allowReplace = true + ); + void SetVectorINT2 + ( + const GUID& tagElement, + const INT2 * values, + long count, + bool allowReplace = true + ); + void SetVectorINT4 + ( + const GUID& tagElement, + const INT4 * values, + long count, + bool allowReplace = true + ); + void SetVectorUINT4 + ( + const GUID& tagElement, + const UINT4 * values, + long count, + bool allowReplace = true + ); + void SetVectorREAL4 + ( + const GUID& tagElement, + const REAL4 * values, + long count, + bool allowReplace = true + ); + void SetVectorREAL8 + ( + const GUID& tagElement, + const REAL8 * values, + long count, + bool allowReplace = true + ); + void SetVectorTimeStamp + ( + const GUID& tagElement, + const TIMESTAMPPQDIF * values, + long count, + bool allowReplace = true + ); + + // Get vectors + bool GetVectorString + ( + const GUID& tagElement, + char * text, + long max + ) const; + long GetVectorINT1 + ( + const GUID& tagElement, + INT1 * values, + long max + ) const; + long GetVectorINT2 + ( + const GUID& tagElement, + INT2 * values, + long max + ) const; + long GetVectorINT4 + ( + const GUID& tagElement, + INT4 * values, + long max + ) const; + long GetVectorUINT4 + ( + const GUID& tagElement, + UINT4 * values, + long max + ) const; + long GetVectorREAL4 + ( + const GUID& tagElement, + REAL4 * values, + long max + ) const; + long GetVectorREAL8 + ( + const GUID& tagElement, + REAL8 * values, + long max + ) const; + long GetVectorTimeStamp + ( + const GUID& tagElement, + TIMESTAMPPQDIF * values, + long max + ) const; + + // Set scalars + void SetScalarGUID + ( + const GUID& tagElement, + GUID value, + bool allowReplace = true + ); + void SetScalarTimeStamp + ( + const GUID& tagElement, + TIMESTAMPPQDIF value, + bool allowReplace = true + ); + void SetScalarUINT2 + ( + const GUID& tagElement, + UINT2 value, + bool allowReplace = true + ); + void SetScalarINT2 + ( + const GUID& tagElement, + INT2 value, + bool allowReplace = true + ); + void SetScalarUINT4 + ( + const GUID& tagElement, + UINT4 value, + bool allowReplace = true + ); + void SetScalarINT4 + ( + const GUID& tagElement, + INT4 value, + bool allowReplace = true + ); + void SetScalarBOOL4 + ( + const GUID& tagElement, + bool value, + bool allowReplace = true + ); + void SetScalarREAL4 + ( + const GUID& tagElement, + REAL4 value, + bool allowReplace = true + ); + void SetScalarREAL8 + ( + const GUID& tagElement, + REAL8 value, + bool allowReplace = true + ); + void SetScalarCOMPLEX8 + ( + const GUID& tagElement, + COMPLEX8 value, + bool allowReplace = true + ); + void SetScalarCOMPLEX16 + ( + const GUID& tagElement, + COMPLEX16 value, + bool allowReplace = true + ); + + // Get scalars + bool GetScalarGUID + ( + const GUID& tagElement, + GUID& value + ) const; + bool GetScalarTimeStamp + ( + const GUID& tagElement, + TIMESTAMPPQDIF& value + ) const; + bool GetScalarUINT2 + ( + const GUID& tagElement, + UINT2& value + ) const; + bool GetScalarINT2 + ( + const GUID& tagElement, + INT2& value + ) const; + bool GetScalarUINT4 + ( + const GUID& tagElement, + UINT4& value + ) const; + bool GetScalarINT4 + ( + const GUID& tagElement, + INT4& value + ) const; + bool GetScalarBOOL4 + ( + const GUID& tagElement, + bool& value + ) const; + bool GetScalarREAL4 + ( + const GUID& tagElement, + REAL4& value + ) const; + bool GetScalarREAL8 + ( + const GUID& tagElement, + REAL8& value + ) const; + bool GetScalarCOMPLEX8 + ( + const GUID& tagElement, + COMPLEX8& value + ) const; + bool GetScalarCOMPLEX16 + ( + const GUID& tagElement, + COMPLEX16& value + ) const; + + // Implementation + private: + + // Member data + private: + CArrayElements m_array; + }; diff --git a/LFtid1056/pqdif/include/el_scal.cpp b/LFtid1056/pqdif/include/el_scal.cpp new file mode 100644 index 0000000..bb41f55 --- /dev/null +++ b/LFtid1056/pqdif/include/el_scal.cpp @@ -0,0 +1,367 @@ +/* +** CPQDIF_E_Scalar class. Implements the PQDIF scalar element. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: el_scal.cpp $ +** Last modified: $Modtime: 12/22/00 10:30a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/el_scal.cpp $ +** VCS revision: $Revision: 12 $ +*/ +#include "PQDIF_classes.h" + + +// Construction +// ============ + +CPQDIF_E_Scalar::CPQDIF_E_Scalar() + { + memset( &m_value, 0, sizeof( m_value ) ); + } + +CPQDIF_E_Scalar::~CPQDIF_E_Scalar() + { + } + +#ifdef PQDIF_USE_COM +bool CPQDIF_E_Scalar::SetValue( long typePhysical, VARIANT & value ) + { + bool status = false; + + m_typePhysical = typePhysical; + if( m_pRecord ) + m_pRecord->SetChanged( true ); + + status = convertFromVariant( value, m_value ); + + return status; + } + +bool CPQDIF_E_Scalar::GetValue( VARIANT& value ) + { + bool status = true; + + status = convertToVariant( m_value, value ); + + return status; + } +#endif + +bool CPQDIF_E_Scalar::SetValue( long typePhysical, PQDIFValue& value ) + { + bool status = false; + + int iSize = theInfo.GetNumBytesOfType( typePhysical ); + if( iSize > 0 ) + { + m_typePhysical = typePhysical; + memcpy( (void *)&m_value, (void *)&value, iSize ); + status = true; + + if( m_pRecord ) + m_pRecord->SetChanged( true ); + } + + return status; + } + +bool CPQDIF_E_Scalar::GetValue( long& typePhysical, PQDIFValue& value ) const + { + bool status = false; + + if( m_typePhysical != 0 ) + { + typePhysical = m_typePhysical; + value = m_value; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueUINT2( UINT2 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_UNS_INTEGER2; + m_value.uint2 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueUINT2( UINT2& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_UNS_INTEGER2 ) + { + value = m_value.uint2; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueINT2( INT2 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_INTEGER2; + m_value.int2 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueINT2( INT2& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_INTEGER2 ) + { + value = m_value.int2; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueUINT4( UINT4 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_UNS_INTEGER4; + m_value.uint4 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueUINT4( UINT4& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_UNS_INTEGER4 ) + { + value = m_value.uint4; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueINT4( INT4 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_INTEGER4; + m_value.int4 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueINT4( INT4& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_INTEGER4 ) + { + value = m_value.int4; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueBOOL4( bool value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_BOOLEAN4; + m_value.bool4 = value ? (BOOL4) 1 : (BOOL4) 0; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueBOOL4( bool& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_BOOLEAN4 ) + { + value = ( m_value.bool4 != 0 ) ? true : false; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueREAL4( REAL4 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_REAL4; + m_value.real4 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueREAL4( REAL4& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_REAL4 ) + { + value = m_value.real4; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueREAL8( REAL8 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_REAL8; + m_value.real8 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueREAL8( REAL8& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_REAL8 ) + { + value = m_value.real8; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueCOMPLEX8( COMPLEX8 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_COMPLEX8; + m_value.complex8 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueCOMPLEX8( COMPLEX8& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_COMPLEX8 ) + { + value = m_value.complex8; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueCOMPLEX16( COMPLEX16 value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_COMPLEX16; + m_value.complex16 = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueCOMPLEX16( COMPLEX16& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_COMPLEX16 ) + { + value = m_value.complex16; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueGUID( GUID value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_GUID; + m_value.guid = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueGUID( GUID& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_GUID ) + { + value = m_value.guid; + status = true; + } + + return status; + } + + +bool CPQDIF_E_Scalar::SetValueTimeStamp( TIMESTAMPPQDIF value ) + { + bool status = false; + + m_typePhysical = ID_PHYS_TYPE_TIMESTAMPPQDIF; + m_value.ts = value; + status = true; + + return status; + } + + +bool CPQDIF_E_Scalar::GetValueTimeStamp( TIMESTAMPPQDIF& value ) const + { + bool status = false; + + if( m_typePhysical == ID_PHYS_TYPE_TIMESTAMPPQDIF ) + { + value = m_value.ts; + status = true; + } + + return status; + } diff --git a/LFtid1056/pqdif/include/el_scal.h b/LFtid1056/pqdif/include/el_scal.h new file mode 100644 index 0000000..c91baf1 --- /dev/null +++ b/LFtid1056/pqdif/include/el_scal.h @@ -0,0 +1,61 @@ +// File name: $Workfile: el_scal.h $ +// Last modified: $Modtime: 11/13/00 2:41p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_scal.h $ +// VCS revision: $Revision: 8 $ + +class CPQDIF_E_Scalar : public CPQDIF_Element + { + public: + CPQDIF_E_Scalar(); + virtual ~CPQDIF_E_Scalar(); + + // Operator(s) + public: + + // Attributes + public: + virtual long GetElementType( void ) const + { return ID_ELEMENT_TYPE_SCALAR; } + + // Operations + public: +#ifdef PQDIF_USE_COM + bool SetValue( long typePhysical, VARIANT & value ); + bool GetValue( VARIANT& value ); +#endif + bool SetValue( long typePhysical, PQDIFValue& value ); + bool GetValue( long& typePhysical, PQDIFValue& value ) const; + + // Specific physical types + bool SetValueUINT2( UINT2 value ); + bool GetValueUINT2( UINT2& value ) const; + bool SetValueINT2( INT2 value ); + bool GetValueINT2( INT2& value ) const; + bool SetValueUINT4( UINT4 value ); + bool GetValueUINT4( UINT4& value ) const; + bool SetValueINT4( INT4 value ); + bool GetValueINT4( INT4& value ) const; + bool SetValueBOOL4( bool value ); + bool GetValueBOOL4( bool& value ) const; + bool SetValueREAL4( REAL4 value ); + bool GetValueREAL4( REAL4& value ) const; + bool SetValueREAL8( REAL8 value ); + bool GetValueREAL8( REAL8& value ) const; + bool SetValueCOMPLEX8( COMPLEX8 value ); + bool GetValueCOMPLEX8( COMPLEX8& value ) const; + bool SetValueCOMPLEX16( COMPLEX16 value ); + bool GetValueCOMPLEX16( COMPLEX16& value ) const; + bool SetValueGUID( GUID value ); + bool GetValueGUID( GUID& value ) const; + bool SetValueTimeStamp( TIMESTAMPPQDIF value ); + bool GetValueTimeStamp( TIMESTAMPPQDIF& value ) const; + + // Implementation + private: + + // Member data + private: + PQDIFValue m_value; + }; diff --git a/LFtid1056/pqdif/include/el_vect.cpp b/LFtid1056/pqdif/include/el_vect.cpp new file mode 100644 index 0000000..1049562 --- /dev/null +++ b/LFtid1056/pqdif/include/el_vect.cpp @@ -0,0 +1,431 @@ +/* +** CPQDIF_E_Vector class. Implements the PQDIF vector element. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: el_vect.cpp $ +** Last modified: $Modtime: 11/13/00 3:56p $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_vect.cpp $ +** VCS revision: $Revision: 14 $ +*/ +#include "PQDIF_classes.h" + + +const int defaultGrowBy = 4; + +// Construction +// ============ + +CPQDIF_E_Vector::CPQDIF_E_Vector() +{ + m_array.SetSize( 0, defaultGrowBy ); +} + + +CPQDIF_E_Vector::~CPQDIF_E_Vector() +{ +} + + +void CPQDIF_E_Vector::SetPhysicalType( long type ) +{ + long count = m_array.GetSize() / getNumBytesOfType(); + + if( m_typePhysical != type ) + { + // Yup, it's changed! + m_typePhysical = type; + + // ... and realloc space for the new type. + SetCount( count ); + + // Signal that the record changed. + if( m_pRecord ) + m_pRecord->SetChanged( true ); + } +} + + +#ifdef PQDIF_USE_COM +bool CPQDIF_E_Vector::SetValue( long index, VARIANT & value ) + { + bool status = false; + PQDIFValue valPQ; + + // Copy over the information + status = convertFromVariant( value, valPQ ); + if( status ) + { + SetValue( index, valPQ ); + } + + return status; + } + +bool CPQDIF_E_Vector::GetValue( long index, VARIANT & value ) const + { + bool status = false; + PQDIFValue valPQ; + long nItem; + GetCount(nItem); + + if( index >= 0 && index < nItem ) + { + status = GetValue( index, valPQ ); + if( status ) + { + status = convertToVariant( valPQ, value ); + } + } + + return status; + } +#endif + +bool CPQDIF_E_Vector::SetValue( long index, const PQDIFValue& value ) +{ + bool status = false; + BYTE * pvalSource = (BYTE *) getPointerToValue( value ); + BYTE * pvalTarget = (BYTE *) getPointer( index ); + + if( pvalSource && pvalTarget ) + { + memcpy( pvalTarget, pvalSource, getNumBytesOfType() ); + status = true; + } + + return status; +} + + +bool CPQDIF_E_Vector::GetValue( long index, PQDIFValue& value ) const +{ + bool status = false; + BYTE * pvalTarget = (BYTE *) getPointerToValue( value ); + BYTE * pvalSource = (BYTE *) getPointer( index ); + + if( pvalSource && pvalTarget ) + { + memcpy( pvalTarget, pvalSource, getNumBytesOfType() ); + status = true; + } + + return status; +} + + +bool CPQDIF_E_Vector::SetValue( long index, double value ) +{ + bool status; + PQDIFValue valuePQ; + + status = convertFromDouble( value, valuePQ ); + if( status ) + { + status = SetValue( index, valuePQ ); + } + + return status; +} + + +bool CPQDIF_E_Vector::GetValue( long index, double& value ) const +{ + bool status; + PQDIFValue valuePQ; + + status = GetValue( index, valuePQ ); + if( status ) + { + status = convertToDouble( valuePQ, value ); + } + + return status; +} + + + +bool CPQDIF_E_Vector::SetValues( const char * text ) +{ + bool status = false; + long idxItem; + long countItems; + BYTE * data = NULL; + + // Init + countItems = strlen( text ) + 1; + + switch( GetPhysicalType() ) + { + case ID_PHYS_TYPE_CHAR1: + SetCount( countItems ); + data = GetRawData(); + if( data ) + { + // Copy the string across directly + memcpy( data, text, countItems - 1 ); + + // Make sure it's null-terminated + data[ countItems - 1 ] = (BYTE) 0; + status = true; + } + break; + + case ID_PHYS_TYPE_CHAR2: + SetCount( countItems ); + data = GetRawData(); + if( data ) + { + CHAR2 * temp = (CHAR2 *) data; + + // Copy the data across by physical item size + // Don't copy the last character -- should be a NULL + for( idxItem = 0; idxItem < ( countItems - 1); idxItem++ ) + { + // Copy each value + *temp = (CHAR2) text[ (int) idxItem ]; + temp++; + } + + // NULL-terminate it + *temp = (CHAR2) 0; + status = true; + } + break; + + default: + status = false; + break; + } + + return status; +} + + +bool CPQDIF_E_Vector::GetValues( string& strOutput ) const +{ + bool status = false; + long idxItem; + long countItems; + const BYTE * data = NULL; + + // Init + GetCount( countItems ); + data = GetRawData(); + + switch( GetPhysicalType() ) + { + case ID_PHYS_TYPE_CHAR1: + if( data ) + { + // Copy the data across by physical item size + // Don't copy the last character -- should be a NULL + strOutput = (const char *) data; + status = TRUE; + } + break; + + case ID_PHYS_TYPE_CHAR2: + if( data ) + { + CHAR2 * temp = (CHAR2 *) data; + + // Copy the data across by physical item size + // Don't copy the last character -- should be a NULL + for( idxItem = 0; idxItem < ( countItems - 1); idxItem++ ) + { + // Copy across a single value + strOutput += (TCHAR) ( *temp ); + + // Next! + temp++; + } + + status = TRUE; + } + break; + + default: + status = false; + break; + } + + return status; +} + + +BYTE * CPQDIF_E_Vector::GetRawData( void ) +{ + return m_array.GetData(); +} + + +const BYTE * CPQDIF_E_Vector::GetRawData( void ) const +{ + return m_array.GetData(); +} + + +bool CPQDIF_E_Vector::GetCount( long& count ) const +{ + bool status = false; + + count = m_array.GetSize() / getNumBytesOfType(); + status = true; + + return status; +} + + +bool CPQDIF_E_Vector::SetCount( long count ) +{ + bool status = false; + + // Resize the array. + int size = count * getNumBytesOfType(); + m_array.SetSize( size, defaultGrowBy ); + status = m_array.GetSize() == size; + + return status; +} + + +long CPQDIF_E_Vector::GetSizeBytes( void ) +{ + return m_array.GetSize(); +} + + +BYTE * CPQDIF_E_Vector::getPointer( int idx ) +{ + BYTE * ptr = NULL; + long count = m_array.GetSize() / getNumBytesOfType(); + + ptr = m_array.GetData(); + if( ptr && idx >= 0 && idx < count ) + { + ptr += ( idx * getNumBytesOfType() ); + } + + return ptr; +} + + +const BYTE * CPQDIF_E_Vector::getPointer( int idx ) const +{ + const BYTE * ptr = NULL; + long count = m_array.GetSize() / getNumBytesOfType(); + + ptr = m_array.GetData(); + if( ptr && idx >= 0 && idx < count ) + { + ptr += ( idx * getNumBytesOfType() ); + } + + return ptr; +} + + +// Type-specific member functions +// ------------------------------ + +#define ELVECT_SETVALUE( nametype, type, idtype ) \ +void CPQDIF_E_Vector::SetValue##nametype( long index, type value ) \ +{ \ + bool status = false; \ + type * pval = NULL; \ + SetPhysicalType( idtype ); \ + pval = (type *) getPointer( index ); \ + if( pval ) \ + { \ + *pval = value; \ + status = true; \ + } \ +} + + +#define ELVECT_GETVALUE( nametype, type, idtype ) \ +bool CPQDIF_E_Vector::GetValue##nametype( long index, type& value ) const \ +{ bool status = false; \ + type * pval = NULL; \ + if( GetPhysicalType() == idtype ) \ + { \ + pval = (type *) getPointer( index ); \ + if( pval ) \ + { \ + value = *pval; \ + status = true; \ + } \ + } \ + return status; } + + +#define ELVECT_SETVALUES_ARRAY( nametype, type, idtype ) \ +void CPQDIF_E_Vector::SetValues##nametype( const type * values, long count ) \ +{ bool status = false; \ + type * pval = NULL; \ + SetPhysicalType( idtype ); \ + SetCount( count ); \ + pval = (type *) getPointer( 0 ); \ + if( pval ) \ + { \ + memcpy( pval, values, count * sizeof( type ) ); \ + status = true; \ + } \ +} + + +#define ELVECT_GETVALUES_ARRAY( nametype, type, idtype ) \ +long CPQDIF_E_Vector::GetValues##nametype( type * values, long max ) const \ +{ long countActual = 0; \ + type * pval = NULL; \ + long sizeType = getNumBytesOfType(); \ + long count = m_array.GetSize() / sizeType; \ + if( GetPhysicalType() == idtype ) \ + { \ + pval = (type *) getPointer( 0 ); \ + if( pval ) \ + { \ + countActual = min( max, count ); \ + memcpy( values, pval, countActual * sizeType ); \ + } \ + } \ + return countActual; } + + +ELVECT_SETVALUE ( INT1, INT1, ID_PHYS_TYPE_INTEGER1 ) +ELVECT_SETVALUES_ARRAY( INT1, INT1, ID_PHYS_TYPE_INTEGER1 ) +ELVECT_GETVALUE ( INT1, INT1, ID_PHYS_TYPE_INTEGER1 ) +ELVECT_GETVALUES_ARRAY( INT1, INT1, ID_PHYS_TYPE_INTEGER1 ) + +ELVECT_SETVALUE ( INT2, INT2, ID_PHYS_TYPE_INTEGER2 ) +ELVECT_SETVALUES_ARRAY( INT2, INT2, ID_PHYS_TYPE_INTEGER2 ) +ELVECT_GETVALUE ( INT2, INT2, ID_PHYS_TYPE_INTEGER2 ) +ELVECT_GETVALUES_ARRAY( INT2, INT2, ID_PHYS_TYPE_INTEGER2 ) + +ELVECT_SETVALUE ( INT4, INT4, ID_PHYS_TYPE_INTEGER4 ) +ELVECT_SETVALUES_ARRAY( INT4, INT4, ID_PHYS_TYPE_INTEGER4 ) +ELVECT_GETVALUE ( INT4, INT4, ID_PHYS_TYPE_INTEGER4 ) +ELVECT_GETVALUES_ARRAY( INT4, INT4, ID_PHYS_TYPE_INTEGER4 ) + +ELVECT_SETVALUE ( UINT4, UINT4, ID_PHYS_TYPE_UNS_INTEGER4 ) +ELVECT_SETVALUES_ARRAY( UINT4, UINT4, ID_PHYS_TYPE_UNS_INTEGER4 ) +ELVECT_GETVALUE ( UINT4, UINT4, ID_PHYS_TYPE_UNS_INTEGER4 ) +ELVECT_GETVALUES_ARRAY( UINT4, UINT4, ID_PHYS_TYPE_UNS_INTEGER4 ) + +ELVECT_SETVALUE ( REAL4, REAL4, ID_PHYS_TYPE_REAL4 ) +ELVECT_SETVALUES_ARRAY( REAL4, REAL4, ID_PHYS_TYPE_REAL4 ) +ELVECT_GETVALUE ( REAL4, REAL4, ID_PHYS_TYPE_REAL4 ) +ELVECT_GETVALUES_ARRAY( REAL4, REAL4, ID_PHYS_TYPE_REAL4 ) + +ELVECT_SETVALUE ( REAL8, REAL8, ID_PHYS_TYPE_REAL8 ) +ELVECT_SETVALUES_ARRAY( REAL8, REAL8, ID_PHYS_TYPE_REAL8 ) +ELVECT_GETVALUE ( REAL8, REAL8, ID_PHYS_TYPE_REAL8 ) +ELVECT_GETVALUES_ARRAY( REAL8, REAL8, ID_PHYS_TYPE_REAL8 ) + +ELVECT_SETVALUE ( TimeStamp, TIMESTAMPPQDIF, ID_PHYS_TYPE_TIMESTAMPPQDIF ) +ELVECT_SETVALUES_ARRAY( TimeStamp, TIMESTAMPPQDIF, ID_PHYS_TYPE_TIMESTAMPPQDIF ) +ELVECT_GETVALUE ( TimeStamp, TIMESTAMPPQDIF, ID_PHYS_TYPE_TIMESTAMPPQDIF ) +ELVECT_GETVALUES_ARRAY( TimeStamp, TIMESTAMPPQDIF, ID_PHYS_TYPE_TIMESTAMPPQDIF ) + diff --git a/LFtid1056/pqdif/include/el_vect.h b/LFtid1056/pqdif/include/el_vect.h new file mode 100644 index 0000000..078f2b2 --- /dev/null +++ b/LFtid1056/pqdif/include/el_vect.h @@ -0,0 +1,87 @@ +// File name: $Workfile: el_vect.h $ +// Last modified: $Modtime: 11/13/00 2:39p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/el_vect.h $ +// VCS revision: $Revision: 13 $ + +class CPQDIF_E_Vector : public CPQDIF_Element + { + public: + CPQDIF_E_Vector(); + virtual ~CPQDIF_E_Vector(); + + // Operator(s) + public: + + // Attributes + public: + virtual long GetElementType( void ) const + { return ID_ELEMENT_TYPE_VECTOR; } + virtual void SetPhysicalType( long type ); + bool GetCount( long& count ) const; + bool SetCount( long count ); + long GetSizeBytes( void ); + + // Operations + public: +#ifdef PQDIF_USE_COM + bool SetValue( long index, VARIANT & value ); + bool GetValue( long index, VARIANT & value ) const; +#endif + bool SetValue( long index, const PQDIFValue& value ); + bool GetValue( long index, PQDIFValue& value ) const; + bool SetValue( long index, double value ); + bool GetValue( long index, double& value ) const; + + // Specific types + void SetValueINT1 ( long idx, INT1 value ); + void SetValuesINT1 ( const INT1 * array, long count ); + bool GetValueINT1 ( long idx, INT1& value ) const; + long GetValuesINT1 ( INT1 * array, long max ) const; + + void SetValueINT2 ( long idx, INT2 value ); + void SetValuesINT2 ( const INT2 * array, long count ); + bool GetValueINT2 ( long idx, INT2& value ) const; + long GetValuesINT2 ( INT2 * array, long max ) const; + + void SetValueINT4 ( long idx, INT4 value ); + void SetValuesINT4 ( const INT4 * array, long count ); + bool GetValueINT4 ( long idx, INT4& value ) const; + long GetValuesINT4 ( INT4 * array, long max ) const; + + void SetValueUINT4( long index, UINT4 value ); + void SetValuesUINT4 ( const UINT4 * array, long count ); + bool GetValueUINT4( long index, UINT4& value ) const; + long GetValuesUINT4 ( UINT4 * array, long max ) const; + + void SetValueREAL4 ( long idx, REAL4 value ); + void SetValuesREAL4 ( const REAL4 * array, long count ); + bool GetValueREAL4 ( long idx, REAL4& value ) const; + long GetValuesREAL4 ( REAL4 * array, long max ) const; + + void SetValueREAL8 ( long idx, REAL8 value ); + void SetValuesREAL8 ( const REAL8 * array, long count ); + bool GetValueREAL8 ( long idx, REAL8& value ) const; + long GetValuesREAL8 ( REAL8 * array, long max ) const; + + void SetValueTimeStamp ( long idx, TIMESTAMPPQDIF value ); + void SetValuesTimeStamp ( const TIMESTAMPPQDIF * array, long count ); + bool GetValueTimeStamp ( long idx, TIMESTAMPPQDIF& value ) const; + long GetValuesTimeStamp ( TIMESTAMPPQDIF * array, long max ) const; + + bool SetValues( const char * text ); + bool GetValues( string& text ) const; + + BYTE * GetRawData( void ); + const BYTE * GetRawData( void ) const; + + // Implementation + protected: + BYTE * getPointer( int idx ); + const BYTE * getPointer( int idx ) const; + + // Member data + private: + CPQByteArray m_array; + }; diff --git a/LFtid1056/pqdif/include/name_id.inc b/LFtid1056/pqdif/include/name_id.inc new file mode 100644 index 0000000..838eb73 --- /dev/null +++ b/LFtid1056/pqdif/include/name_id.inc @@ -0,0 +1,517 @@ +ADD_ID_UINT4_ENTRY( ID_COMP_STYLE_NONE, tagCompressionStyleID ); +ADD_ID_UINT4_ENTRY( ID_COMP_STYLE_RECORDLEVEL, tagCompressionStyleID ); +ADD_ID_UINT4_ENTRY( ID_COMP_STYLE_TOTALFILE, tagCompressionStyleID ); +ADD_ID_UINT4_ENTRY( ID_COMP_ALG_NONE, tagCompressionAlgorithmID ); +ADD_ID_UINT4_ENTRY( ID_COMP_ALG_ZLIB, tagCompressionAlgorithmID ); +ADD_ID_UINT4_ENTRY( ID_COMP_ALG_PKZIPCL, tagCompressionAlgorithmID ); +ADD_ID_GUID_ENTRY( ID_DS_TYPE_MEASURE, tagDataSourceTypeID ); +ADD_ID_GUID_ENTRY( ID_DS_TYPE_MANUAL, tagDataSourceTypeID ); +ADD_ID_GUID_ENTRY( ID_DS_TYPE_SIMULATE, tagDataSourceTypeID ); +ADD_ID_GUID_ENTRY( ID_DS_TYPE_BENCHMARK, tagDataSourceTypeID ); +ADD_ID_GUID_ENTRY( ID_DS_TYPE_DEBUG, tagDataSourceTypeID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_SATEC, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_WPT, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_NONE, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_BMI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_BPA, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_CESI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_COOPER, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_DCG, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_DRANETZ, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_EDF, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_EPRI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_ELECTROTEK, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_FLUKE, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_HYDROQUEBEC, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_IEEE, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_KREISSJOHNSON, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_METROSONIC, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_PML, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_PSI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_PTI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_PUBLICDOMAIN, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_RPM, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_SQUAREDPOWERLOGIC, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_TELOG, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_PMI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_METONE, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_TRINERGI, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_GE, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_LEM, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_ACTL, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_ADVANTECH, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_VENDOR_ELCOM, tagVendorID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5530, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5540, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_BMI_3100, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_BMI_7100, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_BMI_8010, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_BMI_8020, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_BMI_9010, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_COOPER_VHARM, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_COOPER_VFLICKER, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_DCG_EMTP, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_DRANETZ_656, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_DRANETZ_658, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_TESTPROGRAM, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_DRANETZ_8000, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_PQDIFEDITOR, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_PASS, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_SUPERHARM, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_SUPERTRAN, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_TOP, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_PQVIEW, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_HARMONI, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_FLUKE_CUR, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_IEEE_COMTRADE, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_FLUKE_F41, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PUBLIC_ATP, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_METROSONIC_M1, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_SQD_SMS, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_TELOG_M1, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_3710, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_3720, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_3800, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_7300, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_7700, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_VIP, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PML_LOGSERVER, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_METONE_ELT15, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_PMI_SCANNER, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4017, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_DSS, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4018, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4018M, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4052, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_BMI_8800, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_TRINERGI_PQM, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_MEDCAL, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_GE_KV, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_GE_KV2, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ACUMENTRICS_CONTROL, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_TEXTPQDIF, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_PQWEB, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_POWER_DISTRIBUTION, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_POWER_TRANSMISSION, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_MICRO, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_TWIN, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_PREMIUM, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_LIGHT, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QWAVE_NOMAD, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_EWON_4000, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_QUALIMETRE, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_ANALYST3Q, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_ANALYST1Q, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_ANALYST2050, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_ANALYST2060, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MIDGET200, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MBX300, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MBX800, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MBX601, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MBX602, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MBX603, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_MBX686, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_PERMA701, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_PERMA702, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_PERMA705, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_PERMA706, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVEMICRO, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVENOMAD, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVELIGHT, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVETWIN, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVEPOWER_DISTRIBUTION, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVEPREMIUM, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_QWAVEPOWER_TRANSPORT, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_TOPASLT, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_TOPAS1000, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_TOPAS1019, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_TOPAS1020, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_TOPAS1040, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_BEN5000, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_BEN6000, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_EWAVE, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_LEM_EWON4000, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5510, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5520, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5530T, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5560, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_5590, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ETK_NODECENTER, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_WPT_DRANVIEW, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM5017, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM5018, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM5080, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM5052, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4050, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4053, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM4080, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM5050, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ADVANTECH_ADAM5051, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_EQUIP_ELCOM_BK550, tagEquipmentID ); +ADD_ID_GUID_ENTRY( ID_INSTR_TYPE_SCOPE, tagInstrumentTypeID ); +ADD_ID_GUID_ENTRY( ID_INSTR_TYPE_FR, tagInstrumentTypeID ); +ADD_ID_GUID_ENTRY( ID_INSTR_TYPE_PQM, tagInstrumentTypeID ); +ADD_ID_GUID_ENTRY( ID_INSTR_TYPE_VR, tagInstrumentTypeID ); +ADD_ID_GUID_ENTRY( ID_INSTR_TYPE_SA, tagInstrumentTypeID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_NONE, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_AN , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_BN , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_CN , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_NG , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_AB , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_BC , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_CA , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_RES , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_NET , tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_TOTAL, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_LN_AVE, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_LL_AVE, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_WORST, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_PLUS, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_MINUS, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_1, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_2, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_3, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_4, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_5, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_6, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_7, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_8, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_9, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_10, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_11, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_12, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_13, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_14, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_15, tagPhaseID ); +ADD_ID_UINT4_ENTRY( ID_PHASE_GENERAL_16, tagPhaseID ); +ADD_ID_GUID_ENTRY( ID_QT_WAVEFORM, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_VALUELOG, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_PHASOR, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_RESPONSE, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_FLASH, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_HISTOGRAM, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_HISTOGRAM3D, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_CPF, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_XY, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_MAGDUR, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_XYZ, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_MAGDURTIME, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_QT_MAGDURCOUNT, tagQuantityTypeID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_NONE, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_IMPULSIVE, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_IMPULSIVE_NANO, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_IMPULSIVE_MICRO, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_IMPULSIVE_MILLI, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_OSCILLATORY, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_OSCILLATORY_LOWFREQ, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_OSCILLATORY_MEDFREQ, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_TRANSIENT_OSCILLATORY_HIGHFREQ, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_INSTANT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_INSTANT_SAG, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_INSTANT_SWELL, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_MOMENT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_MOMENT_INTERRUPT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_MOMENT_SAG, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_MOMENT_SWELL, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_TEMP, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_TEMP_INTERRUPT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_TEMP_SAG, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_SHORTDUR_TEMP_SWELL, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_LONGDUR, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_LONGDUR_INTERRUPT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_LONGDUR_SAG, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_LONGDUR_SWELL, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_IMBALANCE, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_POWERFREQVARIATION, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_VOLTAGEFLUCTUATION, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_WAVEDISTORT, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_WAVEDISTORT_DCOFFSET, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_WAVEDISTORT_HARMONIC, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_WAVEDISTORT_INTERHARMONIC, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_WAVEDISTORT_NOTCHING, tagDisturbanceCategoryID ); +ADD_ID_GUID_ENTRY( ID_DISTURB_1159_WAVEDISTORT_NOISE, tagDisturbanceCategoryID ); +ADD_ID_UINT4_ENTRY( ID_QU_NONE , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_SECONDS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_TIMESTAMP , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_CYCLES , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VOLTS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_AMPS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VA , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_WATTS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VARS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_OHMS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_SIEMENS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VOLTSPERAMP, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_JOULES , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_HERTZ , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_CELCIUS , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_DEGREES , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_DB , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_PERCENT , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_PERUNIT , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_SAMPLES , tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VARHOURS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_WATTHOURS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VAHOURS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_MPS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_MPH, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_BARS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_PASCALS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_NEWTONS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_NEWTONMETERS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_RPM, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_RADPERSEC, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_METERS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_WEBERTURNS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_TESLAS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_WEBERS, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_VOLTSPERVOLT, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_AMPSPERAMP, tagQuantityUnitsID ); +ADD_ID_UINT4_ENTRY( ID_QU_AMPSPERVOLT, tagQuantityUnitsID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_VAL, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_TIME, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_MIN, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_MAX, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_AVG, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_INST, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_PHASEANGLE, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_PHASEANGLE_MIN, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_PHASEANGLE_MAX, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_PHASEANGLE_AVG, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_AREA, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_LATITUDE, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_DURATION, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_LONGITUDE, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_POLARITY, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_ELLIPSE, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_BINID, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_BINHIGH, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_BINLOW, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_XBINHIGH, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_XBINLOW, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_YBINHIGH, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_YBINLOW, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_COUNT, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_TRANSITION, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_PROB, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_INTERVAL, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_STATUS, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_P1, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_P5, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_P10, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_P90, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_P95, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_P99, tagValueTypeID ); +ADD_ID_GUID_ENTRY( ID_SERIES_VALUE_TYPE_FREQUENCY, tagValueTypeID ); +ADD_ID_UINT4_ENTRY( ID_SERIES_METHOD_VALUES , tagStorageMethodID ); +ADD_ID_UINT4_ENTRY( ID_SERIES_METHOD_SCALED, tagStorageMethodID ); +ADD_ID_UINT4_ENTRY( ID_SERIES_METHOD_INCREMENT, tagStorageMethodID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_DONTCARE, tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_FEMTO , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_PICO , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_NANO , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_MICRO , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_MILLI , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_NONE , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_KILO , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_MEGA , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_TERA, tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_GREEK_GIGA , tagHintGreekPrefixID ); +ADD_ID_UINT4_ENTRY( ID_PREFER_ENG, tagHintPreferredUnitsID ); +ADD_ID_UINT4_ENTRY( ID_PREFER_PCT, tagHintPreferredUnitsID ); +ADD_ID_UINT4_ENTRY( ID_PREFER_PU , tagHintPreferredUnitsID ); +ADD_ID_UINT4_ENTRY( ID_DEFAULT_DONTCARE, tagHintDefaultDisplayID ); +ADD_ID_UINT4_ENTRY( ID_DEFAULT_MAG , tagHintDefaultDisplayID ); +ADD_ID_UINT4_ENTRY( ID_DEFAULT_ANG , tagHintDefaultDisplayID ); +ADD_ID_UINT4_ENTRY( ID_DEFAULT_REAL , tagHintDefaultDisplayID ); +ADD_ID_UINT4_ENTRY( ID_DEFAULT_IMAG, tagHintDefaultDisplayID ); +ADD_ID_UINT4_ENTRY( ID_DEFAULT_RX, tagHintDefaultDisplayID ); +ADD_ID_UINT4_ENTRY( ID_TRIG_NONE , tagTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_TRIG_LOW , tagTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_TRIG_HIGH , tagTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_TRIG_RATE , tagTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_TRIG_SHAPE, tagTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_TRIG_OTHER, tagTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_XFORMER_TYPE_CT, tagXDTransformerTypeID ); +ADD_ID_UINT4_ENTRY( ID_XFORMER_TYPE_PT, tagXDTransformerTypeID ); +ADD_ID_UINT4_ENTRY( ID_TRIGGER_METH_NONE, tagTriggerMethodID ); +ADD_ID_UINT4_ENTRY( ID_TRIGGER_METH_CHANNEL, tagTriggerMethodID ); +ADD_ID_UINT4_ENTRY( ID_TRIGGER_METH_PERIODIC, tagTriggerMethodID ); +ADD_ID_UINT4_ENTRY( ID_TRIGGER_METH_EXTERNAL, tagTriggerMethodID ); +ADD_ID_UINT4_ENTRY( ID_TRIGGER_METH_PERIODIC_STATS, tagTriggerMethodID ); +ADD_ID_GUID_ENTRY( ID_QC_NONE, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_INSTANTANEOUS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_SPECTRA, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PEAK, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_RMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_HRMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FREQUENCY, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TOTAL_THD, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_EVEN_THD, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_ODD_THD, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_CREST_FACTOR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FORM_FACTOR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_ARITH_SUM, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S0S1, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S2S1, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_SPOS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_SNEG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_SZERO, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_AVG_IMBAL, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TOTAL_THD_RMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_ODD_THD_RMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_EVEN_THD_RMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TID, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TID_RMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_IHRMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_SPECTRA_HGROUP, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_SPECTRA_IGROUP, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TIF, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_MAG_AVG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_MAX_DVV, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_FREQ_MAX, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_MAG_MAX, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_WGT_AVG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_SPECTRUM, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PST, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PLT, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TIF_RMS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PLTSLIDE, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PILPF, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PIMAX, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PIROOT, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_FLKR_PIROOTLPF, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_IT, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_RMS_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_ANSI_TDF, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_K_FACTOR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TDD, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_RMS_PEAK_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DF, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DF_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_PRED_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_PRED_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_PRED_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_CO_Q_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_CO_S_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_CO_P_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_CO_S_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DF_CO_S_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF_CO_S_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF_CO_P_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF_CO_Q_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_ANGLE_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF_VECTOR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DF_VECTOR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_VECTOR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_VECTOR_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_CO_P_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_CO_Q_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_PF_ARITH, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DF_ARITH, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_ARITH, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_ARITH_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_PEAK_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_PEAK_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_PEAK_DEMAND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_HARMONIC, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_HARMONIC_UNSIGNED, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_INTG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_INTG_POS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_INTG_POS_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_INTG_NEG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_INTG_NEG_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_INTG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_INTG_POS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_INTG_POS_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_INTG_NEG_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_INTG_NEG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_INTG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_INTG_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_IVL_INTG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_IVL_INTG_POS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_IVL_INTG_POS_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_IVL_INTG_NEG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_P_IVL_INTG_NEG_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_IVL_INTG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_IVL_INTG_POS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_IVL_INTG_POS_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_IVL_INTG_NEG_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_Q_IVL_INTG_NEG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_IVL_INTG, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_S_IVL_INTG_FUND, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DAXISFIELD, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_QAXIS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_ROTATIONAL, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_DAXIS, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_LINEAR, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_TRANSFERFUNC, tagQuantityCharacteristicID ); +ADD_ID_GUID_ENTRY( ID_QC_STATUS, tagQuantityCharacteristicID ); +ADD_ID_UINT4_ENTRY( ID_QM_NONE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_VOLTAGE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_CURRENT, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_POWER, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_ENERGY, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_TEMPERATURE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_PRESSURE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_CHARGE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_EFIELD, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_MFIELD, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_VELOCITY, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_BEARING, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_FORCE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_TORQUE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_POSITION, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_FLUXLINKAGE, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_FLUXDENSITY, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_QM_STATUS, tagQuantityMeasuredID ); +ADD_ID_UINT4_ENTRY( ID_CTT_NONE, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_NORMAL_TO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_NORMAL_TO_LO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_NORMAL_TO_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_NORMAL_TO_HI_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_LO_TO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_LO_TO_NORMAL, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_LO_TO_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_LO_TO_HI_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_TO_LO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_TO_NORMAL, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_TO_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_LO_TO_HI_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_TO_LO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_TO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_TO_NORMAL, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_TO_HI_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_HI_TO_LO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_HI_TO_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_HI_TO_NORMAL, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_HI_HI_TO_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_DB_LO, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_DB_HI, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_PERIODIC, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_MANUAL, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_INT_CROSS_TRIG, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_EXT_CROSS_TRIG, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_MODULE, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_CTT_RATE, tagChanTriggerTypeID ); +ADD_ID_UINT4_ENTRY( ID_SINGLE_PHASE, tagSettingPhysicalConnection ); +ADD_ID_UINT4_ENTRY( ID_2ELEMENT_DELTA, tagSettingPhysicalConnection ); +ADD_ID_UINT4_ENTRY( ID_2_5ELEMENT_WYE, tagSettingPhysicalConnection ); +ADD_ID_UINT4_ENTRY( ID_3ELMENT_WYE, tagSettingPhysicalConnection ); +ADD_ID_UINT4_ENTRY( ID_3ELEMENT_DELTA, tagSettingPhysicalConnection ); +ADD_ID_UINT4_ENTRY( ID_SPLIT_PHASE, tagSettingPhysicalConnection ); +ADD_ID_UINT4_ENTRY( ID_2ELEMENT_2PHASE, tagSettingPhysicalConnection ); diff --git a/LFtid1056/pqdif/include/name_tag.inc b/LFtid1056/pqdif/include/name_tag.inc new file mode 100644 index 0000000..897e6cd --- /dev/null +++ b/LFtid1056/pqdif/include/name_tag.inc @@ -0,0 +1,136 @@ +ADD_TAG_ENTRY( tagContainer ); +ADD_TAG_ENTRY( tagRecDataSource ); +ADD_TAG_ENTRY( tagRecMonitorSettings ); +ADD_TAG_ENTRY( tagRecObservation ); +ADD_TAG_ENTRY( tagVersionInfo ); +ADD_TAG_ENTRY( tagFileName ); +ADD_TAG_ENTRY( tagCreation ); +ADD_TAG_ENTRY( tagLastSaved ); +ADD_TAG_ENTRY( tagTimesSaved ); +ADD_TAG_ENTRY( tagLanguage ); +ADD_TAG_ENTRY( tagTitle ); +ADD_TAG_ENTRY( tagSubject ); +ADD_TAG_ENTRY( tagAuthor ); +ADD_TAG_ENTRY( tagKeywords ); +ADD_TAG_ENTRY( tagComments ); +ADD_TAG_ENTRY( tagLastSavedBy ); +ADD_TAG_ENTRY( tagApplication ); +ADD_TAG_ENTRY( tagSecurity ); +ADD_TAG_ENTRY( tagOwner ); +ADD_TAG_ENTRY( tagCopyright ); +ADD_TAG_ENTRY( tagTrademarks ); +ADD_TAG_ENTRY( tagNotes ); +ADD_TAG_ENTRY( tagCompressionStyleID ); +ADD_TAG_ENTRY( tagCompressionAlgorithmID ); +ADD_TAG_ENTRY( tagCompressionChecksum ); +ADD_TAG_ENTRY( tagName ); +ADD_TAG_ENTRY( tagAddress1 ); +ADD_TAG_ENTRY( tagAddress2 ); +ADD_TAG_ENTRY( tagCity ); +ADD_TAG_ENTRY( tagState ); +ADD_TAG_ENTRY( tagPostalCode ); +ADD_TAG_ENTRY( tagCountry ); +ADD_TAG_ENTRY( tagPhoneVoice ); +ADD_TAG_ENTRY( tagPhoneFAX ); +ADD_TAG_ENTRY( tagEMail ); +ADD_TAG_ENTRY( tagDataSourceTypeID ); +ADD_TAG_ENTRY( tagVendorID ); +ADD_TAG_ENTRY( tagEquipmentID ); +ADD_TAG_ENTRY( tagCustomSourceInfo ); +ADD_TAG_ENTRY( tagSerialNumberDS ); +ADD_TAG_ENTRY( tagVersionDS ); +ADD_TAG_ENTRY( tagNameDS ); +ADD_TAG_ENTRY( tagOwnerDS ); +ADD_TAG_ENTRY( tagLocationDS ); +ADD_TAG_ENTRY( tagTimeZoneDS ); +ADD_TAG_ENTRY( tagCoordinatesDS ); +ADD_TAG_ENTRY( tagChannelDefns ); +ADD_TAG_ENTRY( tagInstrumentTypeID ); +ADD_TAG_ENTRY( tagInstrumentModelName ); +ADD_TAG_ENTRY( tagInstrumentModelNumber ); +ADD_TAG_ENTRY( tagOneChannelDefn ); +ADD_TAG_ENTRY( tagChannelName ); +ADD_TAG_ENTRY( tagPhaseID ); +ADD_TAG_ENTRY( tagOtherChannelIdentifier ); +ADD_TAG_ENTRY( tagGroupName ); +ADD_TAG_ENTRY( tagQuantityTypeID ); +ADD_TAG_ENTRY( tagQuantityMeasuredID ); +ADD_TAG_ENTRY( tagPhysicalChannel ); +ADD_TAG_ENTRY( tagQuantityName ); +ADD_TAG_ENTRY( tagPrimarySeriesIdx ); +ADD_TAG_ENTRY( tagSeriesDefns ); +ADD_TAG_ENTRY( tagOneSeriesDefn ); +ADD_TAG_ENTRY( tagValueTypeID ); +ADD_TAG_ENTRY( tagQuantityUnitsID ); +ADD_TAG_ENTRY( tagQuantityCharacteristicID ); +ADD_TAG_ENTRY( tagQuantitySignificantDigitsID ); +ADD_TAG_ENTRY( tagQuantityResolutionID ); +ADD_TAG_ENTRY( tagStorageMethodID ); +ADD_TAG_ENTRY( tagValueTypeName ); +ADD_TAG_ENTRY( tagHintGreekPrefixID ); +ADD_TAG_ENTRY( tagHintPreferredUnitsID ); +ADD_TAG_ENTRY( tagHintDefaultDisplayID ); +ADD_TAG_ENTRY( tagProbInterval ); +ADD_TAG_ENTRY( tagProbPercentile ); +ADD_TAG_ENTRY( tagSeriesNominalQuantity ); +ADD_TAG_ENTRY( tagEffective ); +ADD_TAG_ENTRY( tagTimeInstalled ); +ADD_TAG_ENTRY( tagTimeRemoved ); +ADD_TAG_ENTRY( tagUseCalibration ); +ADD_TAG_ENTRY( tagUseTransducer ); +ADD_TAG_ENTRY( tagChannelSettingsArray ); +ADD_TAG_ENTRY( tagNominalFrequency ); +ADD_TAG_ENTRY( tagSettingPhysicalConnection ); +ADD_TAG_ENTRY( tagOneChannelSetting ); +ADD_TAG_ENTRY( tagChannelDefnIdx ); +ADD_TAG_ENTRY( tagTriggerTypeID ); +ADD_TAG_ENTRY( tagFullScale ); +ADD_TAG_ENTRY( tagNoiseFloor ); +ADD_TAG_ENTRY( tagTriggerShapeParam ); +ADD_TAG_ENTRY( tagXDTransformerTypeID ); +ADD_TAG_ENTRY( tagXDSystemSideRatio ); +ADD_TAG_ENTRY( tagXDMonitorSideRatio ); +ADD_TAG_ENTRY( tagXDFrequencyResponse ); +ADD_TAG_ENTRY( tagCalTimeSkew ); +ADD_TAG_ENTRY( tagCalOffset ); +ADD_TAG_ENTRY( tagCalRatio ); +ADD_TAG_ENTRY( tagCalMustUseARCal ); +ADD_TAG_ENTRY( tagCalApplied ); +ADD_TAG_ENTRY( tagCalRecorded ); +ADD_TAG_ENTRY( tagTriggerHighHigh ); +ADD_TAG_ENTRY( tagTriggerHigh ); +ADD_TAG_ENTRY( tagTriggerLow ); +ADD_TAG_ENTRY( tagTriggerLowLow ); +ADD_TAG_ENTRY( tagTriggerDeadBand ); +ADD_TAG_ENTRY( tagTriggerRate ); +ADD_TAG_ENTRY( tagObservationName ); +ADD_TAG_ENTRY( tagTimeCreate ); +ADD_TAG_ENTRY( tagTimeStart ); +ADD_TAG_ENTRY( tagTriggerMethodID ); +ADD_TAG_ENTRY( tagTimeTriggered ); +ADD_TAG_ENTRY( tagChannelTriggerIdx ); +ADD_TAG_ENTRY( tagObservationSerial ); +ADD_TAG_ENTRY( tagObservationAggregationSerial ); +ADD_TAG_ENTRY( tagDisturbanceCategoryID ); +ADD_TAG_ENTRY( tagChannelInstances ); +ADD_TAG_ENTRY( tagCharactDisturbDirection ); +ADD_TAG_ENTRY( tagCharactDisturbDirectionQuality ); +ADD_TAG_ENTRY( tagOneChannelInst ); +ADD_TAG_ENTRY( tagCharactDuration ); +ADD_TAG_ENTRY( tagSeriesInstances ); +ADD_TAG_ENTRY( tagCharactMagnitude ); +ADD_TAG_ENTRY( tagCharactFrequency ); +ADD_TAG_ENTRY( tagChanTriggerModuleInfo ); +ADD_TAG_ENTRY( tagChanTriggerModuleName ); +ADD_TAG_ENTRY( tagCrossTriggerDeviceName ); +ADD_TAG_ENTRY( tagCrossTriggerChanIdx ); +ADD_TAG_ENTRY( tagChanTriggerTypeID ); +ADD_TAG_ENTRY( tagChannelFrequency ); +ADD_TAG_ENTRY( tagChannelGroupID ); +ADD_TAG_ENTRY( tagOneSeriesInstance ); +ADD_TAG_ENTRY( tagSeriesBaseQuantity ); +ADD_TAG_ENTRY( tagSeriesScale ); +ADD_TAG_ENTRY( tagSeriesOffset ); +ADD_TAG_ENTRY( tagSeriesShareChannelIdx ); +ADD_TAG_ENTRY( tagSeriesShareSeriesIdx ); +ADD_TAG_ENTRY( tagSeriesValues ); diff --git a/LFtid1056/pqdif/include/pcn_base.cpp b/LFtid1056/pqdif/include/pcn_base.cpp new file mode 100644 index 0000000..8c837d5 --- /dev/null +++ b/LFtid1056/pqdif/include/pcn_base.cpp @@ -0,0 +1,385 @@ +/* +** CPQDIF_PersistController class. The base class for persistence controller +** classes. These classes are used to control how the PQDIF data is stored +** and retrieved from a particular medium. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: pcn_base.cpp $ +** Last modified: $Modtime: 7/07/99 5:08p $ +** Last modified by: $Author: Erich $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/pcn_base.cpp $ +** VCS revision: $Revision: 9 $ +*/ +#include "PQDIF_classes.h" + + +// Construction +// ============ + +CPQDIF_PersistController::CPQDIF_PersistController() + { + m_arrayRecords.SetSize( 0, 8 ); + m_state = pqpc_Empty; + } + + +CPQDIF_PersistController::~CPQDIF_PersistController() + { + CPQDIFRecord * prec = NULL; + // Delete record objects in array + for( int idx = 0; idx < m_arrayRecords.GetSize(); idx++ ) + { + prec = (CPQDIFRecord *)(m_arrayRecords[ idx ]); + delete prec; + } + } + + +CPQDIFRecord * CPQDIF_PersistController::GetRecord( long index ) + { + CPQDIFRecord * prec = NULL; + + if( index >= 0 && index < m_arrayRecords.GetSize() ) + { + prec = (CPQDIFRecord *) m_arrayRecords[ index ]; + } + + return prec; + } + + +long CPQDIF_PersistController::GetRecordCount( void ) const + { + return m_arrayRecords.GetSize(); + } + + +bool CPQDIF_PersistController::InsertRecord( CPQDIFRecord * prec, long indexToInsert ) + { + bool status = FALSE; + + if( indexToInsert >= 0 && indexToInsert <= m_arrayRecords.GetSize() ) + { + m_arrayRecords.InsertAt( indexToInsert, prec ); + status = TRUE; + } + + return status; + } + + +bool CPQDIF_PersistController::RemoveRecord( long index ) + { + bool status = FALSE; + CPQDIFRecord * prec = NULL; + + if( index >= 0 && index < m_arrayRecords.GetSize() ) + { + m_arrayRecords.RemoveAt( index ); + status = TRUE; + } + + return status; + } + + +long CPQDIF_PersistController::CreateContainerRecord + ( + const char * language, + const char * title, + const char * subject, + const char * author, + const char * keywords, + const char * comments, + const char * lastSavedBy, + const char * application, + const char * security, + const char * owner, + const char * copyright, + const char * trademarks, + const char * notes + ) + { + CPQDIFRecord * prec; + long idxNewRecord = 0; + CPQDIF_E_Collection * pcollMain; + + prec = theFactory.NewRecord( PFR_Container ); + if( prec ) + { + // Create main collection for new record + pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollMain ) + { + // Add string entries + pcollMain->SetVectorString( tagLanguage, language ); + pcollMain->SetVectorString( tagTitle, title ); + pcollMain->SetVectorString( tagSubject, subject ); + pcollMain->SetVectorString( tagAuthor, author ); + pcollMain->SetVectorString( tagKeywords, keywords ); + pcollMain->SetVectorString( tagComments, comments ); + pcollMain->SetVectorString( tagLastSavedBy, lastSavedBy ); + pcollMain->SetVectorString( tagApplication, application ); + pcollMain->SetVectorString( tagSecurity, security ); + + pcollMain->SetVectorString( tagOwner, owner ); + pcollMain->SetVectorString( tagCopyright, copyright ); + pcollMain->SetVectorString( tagTrademarks, trademarks ); + + pcollMain->SetVectorString( tagNotes, notes ); + + // Hand it over to the record object + prec->SetMainCollection( pcollMain ); + + // Stuff the record into the first slot + m_arrayRecords.SetAtGrow( 0, prec ); + } + } + + return idxNewRecord; + } + +long CPQDIF_PersistController::CreateContainerRecord + ( + const char * szFileName, + const TIMESTAMPPQDIF * timeCreate, + const long lMajor, + const long lMinor, + const long lCompatMajor, + const long lCompatMinor + ) + { + CPQDIFRecord * prec; + long idxNewRecord = 0; + CPQDIF_E_Collection * pcollMain; + + prec = theFactory.NewRecord( PFR_Container ); + if( prec ) + { + // Create main collection for new record + pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollMain ) + { + // Add string entries + pcollMain->SetVectorString( tagFileName, szFileName ); + + pcollMain->SetScalarTimeStamp( tagCreation, *timeCreate ); + + UINT4 aVer[4]; + + aVer[0] = lMajor; + aVer[1] = lMinor; + aVer[2] = lCompatMajor; + aVer[3] = lCompatMinor; + + pcollMain->SetVectorUINT4( tagVersionInfo, aVer, 4 ); + + // Hand it over to the record object + prec->SetMainCollection( pcollMain ); + + // Stuff the record into the first slot + m_arrayRecords.SetAtGrow( 0, prec ); + } + } + + return idxNewRecord; + } + + + +long CPQDIF_PersistController::CreateDataSourceRecord + ( + long indexInsert, + const GUID& idDataSourceType, + const GUID& idVendor, + const GUID& idEquipment, + const char * serialNumberDS, // Optional (can be NULL) + const char * versionDS, // Optional + const char * nameDS, + const char * ownerDS, // Optional + const char * locationDS, // Optional + const char * timeZoneDS // Optional + ) + { + CPQDIFRecord * prec; + long idxNewRecord = indexInsert; // Is this right? need to fix + CPQDIF_E_Collection * pcollMain; + CPQDIF_E_Collection * pcollDefinitions; + + prec = theFactory.NewRecord( PFR_DataSource ); + if( prec ) + { + // Create main collection for new record + pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollMain ) + { + // Add GUID & string entries + pcollMain->SetScalarGUID( tagDataSourceTypeID, idDataSourceType ); + pcollMain->SetScalarGUID( tagVendorID, idVendor ); + pcollMain->SetScalarGUID( tagEquipmentID, idEquipment ); + + pcollMain->SetVectorString( tagSerialNumberDS, serialNumberDS ); + pcollMain->SetVectorString( tagVersionDS, versionDS ); + pcollMain->SetVectorString( tagNameDS, nameDS ); + pcollMain->SetVectorString( tagOwnerDS, ownerDS ); + pcollMain->SetVectorString( tagLocationDS, locationDS ); + pcollMain->SetVectorString( tagTimeZoneDS, timeZoneDS ); + + // Insert an empty collection ... + pcollDefinitions = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollDefinitions->SetTag( tagChannelDefns ); + pcollMain->Add( pcollDefinitions ); + + // Hand it over to the record object + prec->SetMainCollection( pcollMain ); + + // Add the record + InsertRecord( prec, indexInsert ); + } + } + + return idxNewRecord; + } + +long CPQDIF_PersistController::CreateMonitorSettingsRecord + ( + long indexInsert, + const TIMESTAMPPQDIF * timeEffective, + const TIMESTAMPPQDIF * timeInstalled, + const TIMESTAMPPQDIF * timeRemoved, + bool useCal, + bool useTrans + ) + { + long idxNewRecord = indexInsert; // Is this right? need to fix + CPQDIF_R_Settings * prec; + CPQDIF_E_Collection * pcollMain; + + prec = (CPQDIF_R_Settings *) theFactory.NewRecord( PFR_MonitorSettings ); + if( prec ) + { + // Create main collection for new record + pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollMain ) + { + prec->SetMainCollection( pcollMain ); + + prec->SetInfo( *timeEffective, + *timeInstalled, + *timeRemoved, + useCal, + useTrans ); + + // Add the record + InsertRecord( prec, indexInsert ); + } + } + + return idxNewRecord; + } + +long CPQDIF_PersistController::CreateMonitorSettingsRecord + ( + long indexInsert + ) + { + long idxNewRecord = indexInsert; // Is this right? need to fix + CPQDIF_R_Settings * prec; + CPQDIF_E_Collection * pcollMain; + + prec = (CPQDIF_R_Settings *) theFactory.NewRecord( PFR_MonitorSettings ); + if( prec ) + { + // Create main collection for new record + pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollMain ) + { + prec->SetMainCollection( pcollMain ); + + // Add the record + InsertRecord( prec, indexInsert ); + } + } + + return idxNewRecord; + } + +long CPQDIF_PersistController::CreateObservationRecord + ( + long indexInsert, + const char * name, + const TIMESTAMPPQDIF * timeCreate, + const TIMESTAMPPQDIF * timeStart, + UINT4 idTriggerMethod, + const TIMESTAMPPQDIF * timeTriggered, // Optional (can be NULL) + long countTriggers, + UINT4 * aidxChannelTrigger // Array of channel indices[ countTriggers ] + // Optional (can be NULL) + ) + { + CPQDIFRecord * prec; + long idxNewRecord = indexInsert; // Is this right? need to fix + CPQDIF_E_Collection * pcollMain; + CPQDIF_E_Collection * pcollInstances; + + // Triggers + long idxTrigger; + CPQDIF_E_Vector * pvectChannelIdx; + PQDIFValue valuePQDIF; + + // Create and populate the new record + prec = theFactory.NewRecord( PFR_Observation ); + if( prec ) + { + // Create main collection for new record + pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollMain ) + { + // Add entries + pcollMain->SetVectorString( tagObservationName, name ); + pcollMain->SetScalarTimeStamp( tagTimeCreate, *timeCreate ); + pcollMain->SetScalarTimeStamp( tagTimeStart, *timeStart ); + pcollMain->SetScalarUINT4( tagTriggerMethodID, idTriggerMethod ); + + // Optional time triggered + if( timeTriggered ) + { + pcollMain->SetScalarTimeStamp( tagTimeTriggered, *timeTriggered ); + } + + // Optional triggers + if( countTriggers > 0 && aidxChannelTrigger ) + { + pvectChannelIdx = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); + if( pvectChannelIdx ) + { + pvectChannelIdx->SetTag( tagChannelTriggerIdx ); + pvectChannelIdx->SetPhysicalType( ID_PHYS_TYPE_UNS_INTEGER4 ); + pvectChannelIdx->SetCount( countTriggers ); + + for( idxTrigger = 0; idxTrigger < countTriggers; idxTrigger++ ) + { + valuePQDIF.uint4 = aidxChannelTrigger[ idxTrigger ]; + pvectChannelIdx->SetValue( idxTrigger, valuePQDIF ); + } + + pcollMain->Add( pvectChannelIdx ); + } + } + + // Insert an empty collection ... + pcollInstances = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollInstances->SetTag( tagChannelInstances ); + pcollMain->Add( pcollInstances ); + + // Hand it over to the record object + prec->SetMainCollection( pcollMain ); + + // Add the record + InsertRecord( prec, indexInsert ); + } + } + + return idxNewRecord; + } diff --git a/LFtid1056/pqdif/include/pcn_base.h b/LFtid1056/pqdif/include/pcn_base.h new file mode 100644 index 0000000..71f5366 --- /dev/null +++ b/LFtid1056/pqdif/include/pcn_base.h @@ -0,0 +1,98 @@ +class CPQDIFRecord; + +typedef enum + { + pqpc_Empty, // Newly created + pqpc_MatchesFile, // Contents of memory same as disk + pqpc_Modified // Contents of memory have been modified + } PQPC_Status; + +class CPQDIF_PersistController + { + public: + CPQDIF_PersistController(); + virtual ~CPQDIF_PersistController(); + + // Public member functions + public: + virtual long GetRecordCount( void ) const; + virtual CPQDIFRecord * GetRecord( long index ); + virtual CPQDIFRecord * GetRecordFull( long index ) = 0; + virtual bool InsertRecord( CPQDIFRecord * prec, long indexToInsert ); + virtual bool RemoveRecord( long index ); + + // Other public member functions + public: + virtual long CreateContainerRecord + ( + const char * language, + const char * title, + const char * subject, + const char * author, + const char * keywords, + const char * comments, + const char * lastSavedBy, + const char * application, + const char * security, + const char * owner, + const char * copyright, + const char * trademarks, + const char * notes + ); + virtual long CreateContainerRecord + ( + const char * szFileName, + const TIMESTAMPPQDIF * timeCreate, + const long lMajor, + const long lMinor, + const long lCompatMajor, + const long lCompatMinor + ); + + long CreateDataSourceRecord + ( + long indexInsert, + const GUID& idDataSourceType, + const GUID& idVendor, + const GUID& idEquipment, + const char * serialNumberDS, // Optional (can be NULL) + const char * versionDS, // Optional + const char * nameDS, + const char * ownerDS, // Optional + const char * locationDS, // Optional + const char * timeZoneDS // Optional + ); + long CreateMonitorSettingsRecord + ( + long indexInsert + ); + + long CreateMonitorSettingsRecord + ( + long indexInsert, + const TIMESTAMPPQDIF * timeEffective, + const TIMESTAMPPQDIF * timeInstalled, + const TIMESTAMPPQDIF * timeRemoved, + bool useCal, + bool useTrans + ); + + long CreateObservationRecord + ( + long indexInsert, + const char * name, + const TIMESTAMPPQDIF * timeCreate, + const TIMESTAMPPQDIF * timeStart, + UINT4 idTriggerMethod, + const TIMESTAMPPQDIF * timeTriggered, // Optional (can be NULL) + long countTriggers, + UINT4 * aidxChannelTrigger // Array of channel indices[ countTriggers ] + // Optional (can be NULL) + ); + + // Member data + protected: + CPQPtrArray m_arrayRecords; + PQPC_Status m_state; + }; + diff --git a/LFtid1056/pqdif/include/pcn_flat.cpp b/LFtid1056/pqdif/include/pcn_flat.cpp new file mode 100644 index 0000000..fac6b66 --- /dev/null +++ b/LFtid1056/pqdif/include/pcn_flat.cpp @@ -0,0 +1,1115 @@ +/* +** CPQDIF_PC_FlatFile class. Implements a persistence controller +** for a flat file on disk. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: pcn_flat.cpp $ +** Last modified: $Modtime: 4/20/99 4:07p $ +** Last modified by: $Author: Jamie $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pcn_flat.cpp $ +** VCS revision: $Revision: 6 $ +*/ +#include "PQDIF_classes.h" + + +// Construction +// ============ + +CPQDIF_PC_FlatFile::CPQDIF_PC_FlatFile() + { + m_chunk = NULL; + m_sizeChunk = 0; + + m_fname = _T( "" ); + + m_pstream = NULL; + m_pprocHeader = NULL; + m_pprocBody = NULL; + } + + +CPQDIF_PC_FlatFile::~CPQDIF_PC_FlatFile() + { + if( m_pstream ) + delete m_pstream; + if( m_pprocHeader ) + delete m_pprocHeader; + if( m_pprocBody ) + delete m_pprocBody; + } + +bool CPQDIF_PC_FlatFile::ImportContainerAndRecordsFromChunk( BYTE * chunk, long size, bool &bCompressed ) + { + bool status = false; + // + // + // Initialize compression flag + // + bCompressed = false; + + // Get rid of any old stream and processors hanging around + if( m_pstream ) + { + delete m_pstream; + m_pstream = NULL; + } + if( m_pprocHeader ) + { + delete m_pprocHeader; + m_pprocHeader = NULL; + } + if( m_pprocBody ) + { + delete m_pprocBody; + m_pprocBody = NULL; + } + + if( chunk == NULL || size <= 0) + return false; + + // Create streams and default processors + m_pstream = theFactory.NewStreamIO( PSIO_Chunk ); + m_pprocHeader = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + m_pprocBody = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + + // Open the stream + ((CPQDIF_S_Chunk *) m_pstream)->SetInput( chunk, size ); + + // Read first header w/NOTHING processors + m_pstream->ConnectProcessor( m_pprocHeader ); + + LINKABS4 posNext = 0; + + CPQDIFRecord * precord = theFactory.NewRecord( PFR_Record ); + if( precord ) + { + status = precord->ReadHeader( m_pstream ); + if( status ) + { + // Go ahead and read the first record body + status = precord->ReadBody( m_pstream ); + if( status ) + { + bool foundCompInfo = false; + UINT4 styleComp; + UINT4 algComp; + + CPQDIF_R_Container * pcont; + + // Assume it's a container and try to get compression info + pcont = (CPQDIF_R_Container *) precord; + foundCompInfo = pcont->GetCompressionInfo( styleComp, algComp ); + + // Do we need to change processors? + if( foundCompInfo ) + { + switch( styleComp ) + { + case ID_COMP_STYLE_TOTALFILE: + // Unsupported + status = FALSE; + break; + + case ID_COMP_STYLE_RECORDLEVEL: + // Yup! Check what algorithm we should use... + delete m_pprocBody; + m_pprocBody = theFactory.NewStreamProcessor( algComp ); + if (m_pprocBody) + { + bCompressed = true; + } + else + { + // Can we support it? + status = false; + } + break; + + case ID_COMP_STYLE_NONE: + default: + // Do nothing + break; + } + } + + if( status ) + { + // Done -- add the first record to the array + m_arrayRecords.Add( precord ); + } + + } // Read body OK + } // Read header OK + if (!status) + delete precord; + } // Record object created OK + + // Read through record headers and build list + while( status ) + { + // + // + // This function always returns true so we + // must check the position. If the link recod + // is zero, then we are done. If we get a chunk + // that doesn't set this to zero, then we will + // stop when the position is checked against the + // size in the statement that follows. + // + precord->HeaderGetPosNextRecord( posNext ); + // + // + // Are we at the end? + // + if( posNext > 0 && posNext < size) + { + m_pstream->SeekPos( posNext ); + + precord = theFactory.NewRecord( PFR_Record ); + if( precord ) + { + status = precord->ReadHeader( m_pstream ); + if( status ) + { + m_arrayRecords.Add( precord ); + } + } + } + else + { + // + // + // yep, we are at the end + // use a break so the status flag is true indicating + // no failure so far. + // + break; + } + + } // while() + + if( status ) + { + for( long idxRec = 0; idxRec < GetRecordCount(); idxRec++ ) + { + GetRecordFull( idxRec ); + } + } + + m_state = pqpc_Modified; + + return status; + } + +// +// +// This function imports record from a chunk and appends them +// to the internal array of records. +// +bool CPQDIF_PC_FlatFile::ImportRecordsFromChunk( BYTE * chunk, long size, bool bCompressed ) + { + bool status = false; + + // Get rid of any old stream and processors hanging around + if( m_pstream ) + { + delete m_pstream; + m_pstream = NULL; + } + if( m_pprocHeader ) + { + delete m_pprocHeader; + m_pprocHeader = NULL; + } + if( m_pprocBody ) + { + delete m_pprocBody; + m_pprocBody = NULL; + } + + if( chunk == NULL || size <= 0) + return status; + // + // + // Create streams and default processors + // + m_pstream = theFactory.NewStreamIO( PSIO_Chunk ); + m_pprocHeader = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + + if (bCompressed) + m_pprocBody = theFactory.NewStreamProcessor( ID_COMP_ALG_ZLIB ); + else + m_pprocBody = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + + // Open the stream + ((CPQDIF_S_Chunk *) m_pstream)->SetInput( chunk, size ); + + LINKABS4 posNext = 0; + CPQDIFRecord * precord; + + status = true; + // Read through record headers and build list + while( status && posNext < size) + { + // + // + // Cue up to next record in stream + // + m_pstream->SeekPos( posNext ); + // + // + // Make a new record object + // + precord = theFactory.NewRecord( PFR_Record ); + if( precord ) + { + // + // + // Read the record header with the appropriate + // stream processor (no compression) + // + m_pstream->ConnectProcessor( m_pprocHeader ); + status = precord->ReadHeader( m_pstream ); + if( status ) + { + // + // + // Read the body with the appropriate stream + // processor (may or may not do compression) + // + m_pstream->ConnectProcessor( m_pprocBody ); + status = precord->ReadBody( m_pstream ); + if (status) + { + // + // + // Add the record to our array + // + m_arrayRecords.Add( precord ); + // + // + // This function always returns true so we + // must check the position. If the link recod + // is zero, then we are done. If we get a chunk + // that doesn't set this to zero, then we will + // die when the position is checked against the + // size in the while statement + // + precord->HeaderGetPosNextRecord( posNext ); + if (posNext == 0) + break; + } + } + else + { + // + // + // if we got here, we probably tried to read past the + // end of the stream so we clean up. + // + delete precord; + } + } + } // while() + +// m_state = pqpc_Empty; + m_state = pqpc_Modified; + + return status; + } + +int CPQDIF_PC_FlatFile::ReadHeaders( void ) + { + bool status = FALSE; + int readResault = 0; + LINKABS4 posNext = 0; + + // Get rid of any old stream hanging around + if( m_pstream ) + { + delete m_pstream; + m_pstream = NULL; + } + + // Are we dealing with a chunk or a file? + if( m_chunk ) + m_whichStream = PSIO_Chunk; + else + m_whichStream = PSIO_FlatFile; + // Create streams and default processors + m_pstream = theFactory.NewStreamIO( m_whichStream ); + m_pprocHeader = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + m_pprocBody = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + +#ifdef WIN32 + printf("ReadHeaders 346 \n"); +#endif // WIN32 + + // Open the stream + if( m_whichStream == PSIO_Chunk ) + { + ((CPQDIF_S_Chunk *) m_pstream)->SetInput( m_chunk, m_sizeChunk ); + } + else + { + ((CPQDIF_S_FlatFile *) m_pstream)->Open( m_fname.c_str(), true ); + } + + // Read first header w/NOTHING processors + m_pstream->ConnectProcessor( m_pprocHeader ); + +#ifdef WIN32 + printf("ReadHeaders 363 \n"); +#endif // WIN32 + CPQDIFRecord * precord = theFactory.NewRecord( PFR_Record ); + if( precord ) + { + status = precord->ReadHeader( m_pstream ); + if (status) + { + // Go ahead and read the first record body + status = precord->ReadBody(m_pstream); + if (status) + { + bool foundCompInfo = FALSE; + UINT4 styleComp; + UINT4 algComp; + + CPQDIF_R_Container * pcont; + + // Assume it's a container and try to get compression info + pcont = (CPQDIF_R_Container *)precord; + foundCompInfo = pcont->GetCompressionInfo(styleComp, algComp); + + // Do we need to change processors? + if (foundCompInfo) + { + switch (styleComp) + { + case ID_COMP_STYLE_TOTALFILE: + // Unsupported + status = FALSE; + readResault = -3; + break; + + case ID_COMP_STYLE_RECORDLEVEL: + // Yup! Check what algorithm we should use... +#ifdef WIN32 + printf("ReadHeaders 399 \n"); +#endif // WIN32 + delete m_pprocBody; + m_pprocBody = theFactory.NewStreamProcessor(algComp); + + // Can we support it? + if (!m_pprocBody) + { + readResault = -4; + status = FALSE; + } + break; + + case ID_COMP_STYLE_NONE: + default: + // Do nothing + break; + } + } + + if (status) + { + // Done -- add the first record to the array + m_arrayRecords.Add(precord); + readResault = 0; + } + + } // Read body OK + else + readResault = -2; + } // Read header OK + else + readResault = -1; + } // Record object created OK + + + +#ifdef WIN32 + printf("ReadHeaders 437 \n"); +#endif // WIN32 + // Read through record headers and build list + while( status ) + { + status = precord->HeaderGetPosNextRecord( posNext ); + + // Are we at the end? + if( status && posNext == 0 ) + break; + + if( status ) + { + m_pstream->SeekPos( posNext ); + + precord = theFactory.NewRecord( PFR_Record ); + if( precord ) + { + status = precord->ReadHeader( m_pstream ); + if( status ) + { + m_arrayRecords.Add( precord ); + readResault = 0; + + } + else + readResault = -6; + } + } + else + readResault = -5; + + } // while() + + +#ifdef WIN32 + printf("ReadHeaders 473 \n"); +#endif // WIN32 + // If this is a chunk, we need to force it to read in ALL records + // immediately. + if( status && m_whichStream == PSIO_Chunk ) + { + for( long idxRec = 0; idxRec < GetRecordCount(); idxRec++ ) + { + GetRecordFull( idxRec ); + } + } + +#ifdef WIN32 + printf("ReadHeaders 486 \n"); +#endif // WIN32 + m_state = pqpc_Empty; + + return readResault; + } + + +CPQDIFRecord * CPQDIF_PC_FlatFile::GetRecordFull( long index ) + { + bool status = TRUE; + CPQDIFRecord * prec = NULL; + + prec = GetRecord( index ); + //ASSERT_VALID( prec ); + if( prec && m_pstream && m_pprocBody ) + { + // Connect the appropriate processor + m_pstream->ConnectProcessor( m_pprocBody ); + + // Read the body + status = prec->ReadBody( m_pstream ); + } + + // If it didn't work, don't return the record pointer + if( !status ) + prec = NULL; + + return prec; + } + + +bool CPQDIF_PC_FlatFile::WriteRecordsToFile( void ) + { + bool status = false; + + CPQDIF_StreamIO * pstrmWrite; + CPQDIF_StreamProcessor * pprocWriteHeader; + CPQDIF_StreamProcessor * pprocWriteBody; + CPQDIF_StreamProcessor * pprocWriteBodyFirstRecord; + // + // + // Clear out the old stream and processor stuff + // + if( m_pstream ) + delete m_pstream; + if( m_pprocHeader ) + delete m_pprocHeader; + if( m_pprocBody ) + delete m_pprocBody; + // + // + // This function does file output only + // + m_whichStream = PSIO_FlatFile; + // + // + // Init the basic stuff + // + pstrmWrite = theFactory.NewStreamIO( m_whichStream ); + pprocWriteHeader = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + pprocWriteBodyFirstRecord = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + + // Init the streams + ((CPQDIF_S_FlatFile *) pstrmWrite)->New( m_fname.c_str() ); + + // Should we use a different body processor? + switch( GetCompressionStyle() ) + { + case ID_COMP_STYLE_TOTALFILE: + // We don't support this yet + pprocWriteBody = NULL; + break; + + case ID_COMP_STYLE_RECORDLEVEL: + pprocWriteBody = theFactory.NewStreamProcessor( GetCompressionAlgorithm() ); + break; + + case ID_COMP_STYLE_NONE: + default: + pprocWriteBody = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + break; + } + + // Check all the objects + if( pstrmWrite && pprocWriteHeader && pprocWriteBody && pprocWriteBodyFirstRecord ) + { + status = true; + } + else + { + status = false; + } + + // Write the file out + if( status ) + { + long countRecords; + long idxRecord; + LINKABS4 posCurrentRecord; + LINKABS4 posCurrentRecordBody; + LINKABS4 posNextRecord; + SIZE4 sizeHeader; + SIZE4 sizeBody; + CPQDIFRecord * precord; + + // Init + countRecords = m_arrayRecords.GetSize(); + posCurrentRecord = 0; + posNextRecord = 0; + + for( idxRecord = 0; idxRecord < countRecords; idxRecord++ ) + { + precord = (CPQDIFRecord *) m_arrayRecords[ idxRecord ]; + if( !precord ) + break; + + // GET HEADER INFO (& set initial header info) + posCurrentRecord = posNextRecord; + precord->HeaderSetPos( posCurrentRecord ); + precord->HeaderGetSize( sizeHeader, sizeBody ); + posCurrentRecordBody = posCurrentRecord + sizeHeader; + + // WRITE THE BODY + // Connect the appropriate body processor + // (The first record is a little different) + if( idxRecord == 0 ) + pstrmWrite->ConnectProcessor( pprocWriteBodyFirstRecord ); + else + pstrmWrite->ConnectProcessor( pprocWriteBody ); + status = precord->WriteBody( pstrmWrite ); + + // This determines where the next record will go + // (a new posNextRecord). + pstrmWrite->GetPos( posNextRecord ); + + // UPDATE THE HEADER INFO (w/next record pos and body size) + sizeBody = (SIZE4) ( posNextRecord - posCurrentRecordBody ); + precord->HeaderSetSize( sizeHeader, sizeBody ); + if( idxRecord == (countRecords - 1) ) + { + // Last record! + posNextRecord = 0; + } + precord->HeaderSetPosNextRecord( posNextRecord ); + + // WRITE THE HEADER + pstrmWrite->ConnectProcessor( pprocWriteHeader ); + status = precord->WriteHeader( pstrmWrite ); + } + + pstrmWrite->Flush(); + } + + m_pstream = pstrmWrite; + m_pprocHeader = pprocWriteHeader; + m_pprocBody = pprocWriteBody; + + // Don't keep this one around + if( pprocWriteBodyFirstRecord ) + delete pprocWriteBodyFirstRecord; + + return status; + } + + +bool CPQDIF_PC_FlatFile::WriteNew( void ) + { + bool status = FALSE; + + CPQDIF_StreamIO * pstrmWrite; + CPQDIF_StreamProcessor * pprocWriteHeader; + CPQDIF_StreamProcessor * pprocWriteBody; + CPQDIF_StreamProcessor * pprocWriteBodyFirstRecord; + + // We should have a new file name, but + // the original streams and processors should still be around. + // We will use these if we need to read the full records + // into memory. + + // Are we dealing with a chunk or a file? + if( m_chunk ) + m_whichStream = PSIO_Chunk; + else + m_whichStream = PSIO_FlatFile; + + // Init the basic stuff + pstrmWrite = theFactory.NewStreamIO( m_whichStream ); + pprocWriteHeader = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + pprocWriteBodyFirstRecord = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + + // Init the streams + if( m_whichStream == PSIO_Chunk ) + { + // need to fix + //((CPQDIF_S_Chunk *) pstrmWrite)->SetInput( m_chunk, m_sizeChunk ); + } + else + { + ((CPQDIF_S_FlatFile *) pstrmWrite)->New( m_fname.c_str() ); + } + + // Should we use a different body processor? + switch( GetCompressionStyle() ) + { + case ID_COMP_STYLE_TOTALFILE: + // We don't support this yet + pprocWriteBody = NULL; + break; + + case ID_COMP_STYLE_RECORDLEVEL: + pprocWriteBody = theFactory.NewStreamProcessor( GetCompressionAlgorithm() ); + break; + + case ID_COMP_STYLE_NONE: + default: + pprocWriteBody = theFactory.NewStreamProcessor( ID_COMP_ALG_NONE ); + break; + } + + // Check all the objects + if( pstrmWrite && pprocWriteHeader && pprocWriteBody && pprocWriteBodyFirstRecord ) + { + status = TRUE; + } + else + { + status = FALSE; + } + + // Write the file out + if( status ) + { + long countRecords; + long idxRecord; + LINKABS4 posCurrentRecord; + LINKABS4 posCurrentRecordBody; + LINKABS4 posNextRecord; + SIZE4 sizeHeader; + SIZE4 sizeBody; + CPQDIFRecord * precord; + + // Init + countRecords = m_arrayRecords.GetSize(); + posCurrentRecord = 0; + posNextRecord = 0; + + for( idxRecord = 0; idxRecord < countRecords; idxRecord++ ) + { + precord = (CPQDIFRecord *) m_arrayRecords[ idxRecord ]; + if( !precord ) + break; + + // MAKE SURE THE BODY IS UP-TO-DATE + // -- This must be done before we start making any changes + // to the record; otherwise, it will read using information + // from the new file rather than the old one. + if( m_pstream && m_pprocBody ) + { + m_pstream->ConnectProcessor( m_pprocBody ); + precord->ReadBody( m_pstream ); + } + + // GET HEADER INFO (& set initial header info) + posCurrentRecord = posNextRecord; + precord->HeaderSetPos( posCurrentRecord ); + precord->HeaderGetSize( sizeHeader, sizeBody ); + posCurrentRecordBody = posCurrentRecord + sizeHeader; + + // WRITE THE BODY + // Connect the appropriate body processor + // (The first record is a little different) + if( idxRecord == 0 ) + pstrmWrite->ConnectProcessor( pprocWriteBodyFirstRecord ); + else + pstrmWrite->ConnectProcessor( pprocWriteBody ); + status = precord->WriteBody( pstrmWrite ); + + // This determines where the next record will go + // (a new posNextRecord). + pstrmWrite->GetPos( posNextRecord ); + + // UPDATE THE HEADER INFO (w/next record pos and body size) + sizeBody = (SIZE4) ( posNextRecord - posCurrentRecordBody ); + precord->HeaderSetSize( sizeHeader, sizeBody ); + if( idxRecord == (countRecords - 1) ) + { + // Last record! + posNextRecord = 0; + } + precord->HeaderSetPosNextRecord( posNextRecord ); + + // WRITE THE HEADER + pstrmWrite->ConnectProcessor( pprocWriteHeader ); + status = precord->WriteHeader( pstrmWrite ); + } + + pstrmWrite->Flush(); + } + + // Replace the old stream & processors + if( m_pstream ) + delete m_pstream; + if( m_pprocHeader ) + delete m_pprocHeader; + if( m_pprocBody ) + delete m_pprocBody; + m_pstream = pstrmWrite; + m_pprocHeader = pprocWriteHeader; + m_pprocBody = pprocWriteBody; + + // Don't keep this one around + if( pprocWriteBodyFirstRecord ) + delete pprocWriteBodyFirstRecord; + + return status; + } + + +bool CPQDIF_PC_FlatFile::WriteIncremental( void ) + { + bool status = TRUE; + + if( !m_pstream->CanWriteIncremental() ) + status = FALSE; + + // Write the file out + if( status ) + { + long countRecords; + long idxRecord; + LINKABS4 posCurrentRecord; + LINKABS4 posCurrentRecordBody; + LINKABS4 posCurrentRecordEnd; + LINKABS4 posNextNewRecord; + SIZE4 sizeHeader; + SIZE4 sizeBody; + CPQDIFRecord * precord; + CPQDIFRecord * precordPrevious; + + // Init + countRecords = m_arrayRecords.GetSize(); + posCurrentRecord = 0; + + // Find the end of the file + posNextNewRecord = 0; + for( idxRecord = 1; idxRecord < countRecords; idxRecord++ ) + { + precord = (CPQDIFRecord *) m_arrayRecords[ idxRecord ]; + if( precord ) + { + // Find the end of this record + precord->HeaderGetPos( posCurrentRecord ); + precord->HeaderGetSize( sizeHeader, sizeBody ); + posCurrentRecordEnd = posCurrentRecord + sizeHeader + sizeBody; + + // Is this the max so far? + if( posNextNewRecord < posCurrentRecordEnd ) + { + posNextNewRecord = posCurrentRecordEnd; + } + } + } + + // Don't even bother with record 0 + for( idxRecord = 1; idxRecord < countRecords; idxRecord++ ) + { + precord = (CPQDIFRecord *) m_arrayRecords[ idxRecord ]; + precordPrevious = (CPQDIFRecord *) m_arrayRecords[ idxRecord - 1 ]; + if( !precord || !precordPrevious ) + break; + + // Has this record changed? + // If not, don't do anything. + if( !precord->GetChanged() ) + continue; + + // This record now requires a new location -- + // we'll position it at posNextNewRecord. + + // GET HEADER INFO + // The sizeBody is NOT necessarily correct. + posCurrentRecord = posNextNewRecord; + precord->HeaderGetSize( sizeHeader, sizeBody ); + posCurrentRecordBody = posCurrentRecord + sizeHeader; + + // WRITE THE BODY + // Connect the appropriate body processor + m_pstream->ConnectProcessor( m_pprocBody ); + status = precord->WriteBody( m_pstream ); + // This determines where any more new records go + // (a new posNextNewRecord). + m_pstream->GetPos( posNextNewRecord ); + + // UPDATE THE HEADER INFO + if( idxRecord == (countRecords - 1) ) + { + // Last record! + precord->HeaderSetPosNextRecord( 0 ); + } + precord->HeaderSetPos( posCurrentRecord ); + sizeBody = (SIZE4) ( posNextNewRecord - posCurrentRecordBody ); + precord->HeaderSetSize( sizeHeader, sizeBody ); + + // We don't need to change this, since the next record + // has probably not changed. If it has, this header will be modified + // again anyway. + // precord->HeaderSetPosNextRecord( posNextRecord ); + + // WRITE THE HEADER + m_pstream->ConnectProcessor( m_pprocHeader ); + status = precord->WriteHeader( m_pstream ); + + // UPDATE & WRITE THE HEADER FOR THE PREVIOUS RECORD + precordPrevious->HeaderSetPosNextRecord( posCurrentRecord ); + status = precordPrevious->WriteHeader( m_pstream ); + } + } + + return status; + } + + + + +long CPQDIF_PC_FlatFile::GetCompressionAlgorithm() + { + long algReturn = 0; + CPQDIF_Element * pel; + long typePhysical; + PQDIFValue value; + CPQDIFRecord * precord; + CPQDIF_E_Collection * pcollFirst; + + if( GetRecordCount() > 0 ) + { + // Get the main collection of the first record + precord = GetRecord( 0 ); + //ASSERT( precord ); + pcollFirst = precord->GetMainCollection(); + + // Add it to this collection + if( pcollFirst ) + { + pel = pcollFirst->GetElement( tagCompressionAlgorithmID ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + CPQDIF_E_Scalar * psc = (CPQDIF_E_Scalar *) pel; + //ASSERT_VALID( psc ); + + psc->GetValue( typePhysical, value ); + if( typePhysical == ID_PHYS_TYPE_UNS_INTEGER4 ) + { + algReturn = value.uint4; + } + } + } + } + } // Enough records + + return algReturn; + } + + +void CPQDIF_PC_FlatFile::SetCompressionAlgorithm( long algNew ) + { + CPQDIF_E_Scalar * psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( psc ) + { + PQDIFValue value; + CPQDIFRecord * precord; + CPQDIF_E_Collection * pcollFirst; + + // Specify it... + value.uint4 = algNew; + psc->SetValue( ID_PHYS_TYPE_UNS_INTEGER4, value ); + psc->SetTag( tagCompressionAlgorithmID ); + + // Get the main collection of the first record + precord = GetRecord( 0 ); + pcollFirst = precord->GetMainCollection(); + + // Add it to this collection + if( pcollFirst ) + { + pcollFirst->AddOrReplace( psc ); + //m_canWriteIncremental = FALSE; // need to fix + } + } + } + + +long CPQDIF_PC_FlatFile::GetCompressionStyle() + { + long styleReturn = 0; + CPQDIF_Element * pel; + long typePhysical; + PQDIFValue value; + CPQDIFRecord * precord; + CPQDIF_E_Collection * pcollFirst; + + if( GetRecordCount() > 0 ) + { + // Get the main collection of the first record + precord = GetRecord( 0 ); + //ASSERT( precord ); + pcollFirst = precord->GetMainCollection(); + + // Add it to this collection + if( pcollFirst ) + { + pel = pcollFirst->GetElement( tagCompressionStyleID ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + CPQDIF_E_Scalar * psc = (CPQDIF_E_Scalar *) pel; + //ASSERT_VALID( psc ); + + psc->GetValue( typePhysical, value ); + if( typePhysical == ID_PHYS_TYPE_UNS_INTEGER4 ) + { + styleReturn = value.uint4; + } + } + } + } + } + + return styleReturn; + } + + +void CPQDIF_PC_FlatFile::SetCompressionStyle( long styleNew ) + { + CPQDIF_E_Scalar * psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( psc ) + { + PQDIFValue value; + CPQDIFRecord * precord; + CPQDIF_E_Collection * pcollFirst; + + // Specify it... + value.uint4 = styleNew; + psc->SetValue( ID_PHYS_TYPE_UNS_INTEGER4, value ); + psc->SetTag( tagCompressionStyleID ); + + // Get the main collection of the first record + precord = GetRecord( 0 ); + pcollFirst = precord->GetMainCollection(); + + // Add it to this collection + if( pcollFirst ) + { + pcollFirst->AddOrReplace( psc ); + //m_canWriteIncremental = FALSE; // need to fix + } + } + } + + +void CPQDIF_PC_FlatFile::UpdateInformation( void ) + { + CPQDIFRecord * precord; + bool m_canWriteIncremental = false; // need to fix + + // See if this flag needs to be deactivated... + if( m_canWriteIncremental ) + { + precord = GetRecord( 0 ); + if( !precord ) + { + m_canWriteIncremental = FALSE; + } + else + { + // The first record must not be changed. + // Otherwise, we cannot write incremental. + if( precord->GetChanged() ) + { + m_canWriteIncremental = FALSE; + } + } + } + } + + +void CPQDIF_PC_FlatFile::SetChunkInput( BYTE * chunk, long size ) + { + if( chunk && size > 0 ) + { + m_chunk = chunk; + m_sizeChunk = size; + } + else + { + m_chunk = NULL; + m_sizeChunk = 0; + } + } + + +bool CPQDIF_PC_FlatFile::GetChunkOutputSize( long& size ) + { + bool status = FALSE; + + // If it's a chunk, then pull out all the data + if( m_whichStream == PSIO_Chunk ) + { + status = ((CPQDIF_S_Chunk *) m_pstream)->GetOutputSize( size ); + } + + return status; + } + + +bool CPQDIF_PC_FlatFile::GetChunkOutput( BYTE * chunk, long size ) + { + bool status = FALSE; + + // If it's a chunk, then pull out all the data + if( m_whichStream == PSIO_Chunk ) + { + status = ((CPQDIF_S_Chunk *) m_pstream)->GetOutput( chunk, size ); + } + + return status; + } diff --git a/LFtid1056/pqdif/include/pcn_flat.h b/LFtid1056/pqdif/include/pcn_flat.h new file mode 100644 index 0000000..4d7ab41 --- /dev/null +++ b/LFtid1056/pqdif/include/pcn_flat.h @@ -0,0 +1,68 @@ + +class CPQDIF_StreamIO; +class CPQDIF_StreamProcessor; +enum PF_StreamIO; + + +class CPQDIF_PC_FlatFile : public CPQDIF_PersistController + { + public: + CPQDIF_PC_FlatFile(); + ~CPQDIF_PC_FlatFile(); + + // Overridables + public: + virtual CPQDIFRecord * GetRecordFull( long index ); + + // Public interface + public: + void SetFileName( const char * fname ) + { m_fname = fname; } + const char * GetFileName( void ) + { return m_fname.c_str(); } + + void SetChunkInput( BYTE * chunk, long size ); + bool GetChunkOutputSize( long& size ); + bool GetChunkOutput( BYTE * chunk, long size ); + + bool GetCanWriteIncremental( void ) + { + UpdateInformation(); // need to fix + return false; + //return m_pstream->CanWriteIncremental(); + } + + int ReadHeaders( void ); + + bool ImportContainerAndRecordsFromChunk( BYTE * chunk, long size, bool &bCompressed ); + bool ImportRecordsFromChunk( BYTE * chunk, long size, bool bCompressed ); + + bool WriteIncremental( void ); + bool WriteNew( void ); + bool WriteRecordsToFile( void ); + + long GetCompressionAlgorithm(); + void SetCompressionAlgorithm( long algNew ); + long GetCompressionStyle(); + void SetCompressionStyle( long styleNew ); + + // Implementation + protected: + void UpdateInformation( void ); + + // Member data + private: + // Chunk (if NULL, assume physical file) + BYTE * m_chunk; + long m_sizeChunk; + + // Physical flat file path + string m_fname; + + // Keep track of which stream type + enum PF_StreamIO m_whichStream; + + CPQDIF_StreamIO * m_pstream; + CPQDIF_StreamProcessor * m_pprocHeader; + CPQDIF_StreamProcessor * m_pprocBody; + }; diff --git a/LFtid1056/pqdif/include/pqbytearray.cpp b/LFtid1056/pqdif/include/pqbytearray.cpp new file mode 100644 index 0000000..3e1676e --- /dev/null +++ b/LFtid1056/pqdif/include/pqbytearray.cpp @@ -0,0 +1,89 @@ +// File name: $Workfile: pqbytearray.cpp $ +// Last modified: $Modtime: 9/21/00 8:51a $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pqbytearray.cpp $ +// VCS revision: $Revision: 7 $ + +#include "PQDIF_classes.h" + + +CPQByteArray::CPQByteArray() +{ + m_data = NULL; + m_size = 0; + m_max = 0; + m_growBy = 64; +} + + +CPQByteArray::~CPQByteArray() +{ + if( m_data ) + { + free( m_data ); + } +} + + +bool CPQByteArray::SetSize( int NewSize, int GrowBy ) +{ + + if( GrowBy > 0 ) + m_growBy = GrowBy; + + // Grow? + if( NewSize > m_max ) + { + int max = (( NewSize/m_growBy ) + 1)*m_growBy; + BYTE * data = (BYTE *) realloc( (void *) m_data, max ); + if( data != NULL || max == 0 ) + { + m_data = data; + m_size = NewSize; + m_max = max; + } + } + else + { + m_size = NewSize; + } + + return ( m_size == NewSize ); + +} + + +int CPQByteArray::Add( BYTE value ) +{ + int pos = m_size; + + if( SetSize( m_size + 1 ) ) + { + m_data[ pos ] = value; + return pos; + } + else + { + return -1; + } +} + + +int CPQByteArray::Append( BYTE * values, int count ) +{ + int pos = m_size; + + if( SetSize( m_size + count, m_growBy ) ) + { + memcpy( m_data + pos, values, count ); + return pos; + } + else + { + return -1; + } +} + + + diff --git a/LFtid1056/pqdif/include/pqbytearray.h b/LFtid1056/pqdif/include/pqbytearray.h new file mode 100644 index 0000000..0696a16 --- /dev/null +++ b/LFtid1056/pqdif/include/pqbytearray.h @@ -0,0 +1,59 @@ +// File name: $Workfile: pqbytearray.h $ +// Last modified: $Modtime: 9/20/00 4:19p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pqbytearray.h $ +// VCS revision: $Revision: 4 $ + +class CPQByteArray +{ +public: + CPQByteArray(); + ~CPQByteArray(); + +public: + inline int GetSize( void ) const + { + return m_size; + } + bool SetSize( int NewSize, int GrowBy = -1 ); + + inline BYTE GetAt( int idx ) const + { + //ASSERT( m_data != NULL && idx >= 0 && idx < m_size ); + return m_data[ idx ]; + } + inline void SetAt( int idx, BYTE value ) + { + //ASSERT( m_data != NULL && idx >= 0 && idx < m_size ); + m_data[ idx ] = value; + } + BYTE& ElementAt( int idx ) const + { + //ASSERT( m_data != NULL && idx >= 0 && idx < m_size ); + return m_data[ idx ]; + } + + inline const BYTE * GetData( void ) const { return m_data; } + inline BYTE * GetData( void ) { return m_data; } + + int Add( BYTE value ); + int Append( BYTE * values, int count ); + + BYTE operator[] ( int idx ) const + { + //ASSERT( m_data != NULL && idx >= 0 && idx < m_size ); + return m_data[ idx ]; + } + BYTE& operator[] ( int idx ) + { + //ASSERT( m_data != NULL && idx >= 0 && idx < m_size ); + return m_data[ idx ]; + } + +protected: + BYTE * m_data; + int m_size; + int m_max; + int m_growBy; +}; diff --git a/LFtid1056/pqdif/include/pqdfacty.cpp b/LFtid1056/pqdif/include/pqdfacty.cpp new file mode 100644 index 0000000..d42a295 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdfacty.cpp @@ -0,0 +1,262 @@ +/* +** CPQDIF_Factory class. Implements two sets of member functions: +** - The "abstract factory" methods such as NewPersistController() are +** used to create objects in such a way that the caller does not need to +** know the exact "concrete" class. +** +** -------------------------------------------------------------------------- +** This class is a Singleton class; this means that only one instance of it +** should ever be created. This instance is made global, and is one of the +** only global objects in the entire system. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: pqdfacty.cpp $ +** Last modified: $Modtime: 3/21/99 10:11p $ +** Last modified by: $Author: Erich $ +** +** VCS archive path: $Archive: /Hank/Tools/INEx/pqdiflib/pqdfacty.cpp $ +** VCS revision: $Revision: 11 $ +*/ +#include "PQDIF_classes.h" + +// The one and only factory object (Singleton) +CPQDIF_Factory theFactory; + +// Construction +// ============ + +CPQDIF_Factory::CPQDIF_Factory() + { + } + +CPQDIF_Factory::~CPQDIF_Factory() + { + } + + +#ifndef _PQDIF_NO_PERSIST_CONTROLLER +// Creates a new persistence contoller of the specified concrete class. +// +CPQDIF_PersistController * CPQDIF_Factory::NewPersistController( PF_PersistController which ) + { + CPQDIF_PersistController * ppc = NULL; + + switch( which ) + { + case PFPC_FlatFile: + ppc = new CPQDIF_PC_FlatFile(); + break; + + default: + // Cannot support... + ppc = NULL; + break; + } + + return ppc; + } +#endif + + +// Creates a new stream object of the specified concrete class. +// +CPQDIF_StreamIO * CPQDIF_Factory::NewStreamIO( PF_StreamIO which ) + { + CPQDIF_StreamIO * pstream = NULL; + + switch( which ) + { + case PSIO_FlatFile: + pstream = new CPQDIF_S_FlatFile(); + break; + + case PSIO_Chunk: + pstream = new CPQDIF_S_Chunk(); + break; + +#ifdef _PQDIF_HANK_PQDIF_STUFF + case PSIO_HCOM: + pstream = new CPQDIF_S_HCOM(); + break; +#endif + default: + // Cannot support... + pstream = NULL; + break; + } + + return pstream; + } + + +// Creates a new stream processor object. The list of concrete classes +// is extensible. +// +CPQDIF_StreamProcessor * CPQDIF_Factory::NewStreamProcessor( long which ) + { + CPQDIF_StreamProcessor * pproc = NULL; + + switch( which ) + { + case ID_COMP_ALG_NONE: + pproc = new CPQDIF_SP_Nothing(); + break; + + case ID_COMP_ALG_ZLIB: + pproc = new CPQDIF_SP_ZLIB(); + break; + + case ID_COMP_ALG_PKZIPCL: + // No longer supported + //pproc = new CPQDIF_SP_PKZIP(); + break; + + default: + // Cannot support... + pproc = NULL; + break; + } + + return pproc; + } + + +// Creates a new PQDIF record object of the specified concrete class. +// +CPQDIFRecord * CPQDIF_Factory::NewRecord( PF_Record which ) + { + CPQDIFRecord * prec = NULL; + + switch( which ) + { + // In all cases, create a general record, but with different header tags. + case PFR_Record: + prec = new CPQDIF_R_General(); + prec->HeaderSetTag( tagBlank ); + break; + + case PFR_Container: + prec = new CPQDIF_R_General(); + prec->HeaderSetTag( tagContainer ); + break; + + case PFR_DataSource: + prec = new CPQDIF_R_General(); + prec->HeaderSetTag( tagRecDataSource ); + break; + + case PFR_MonitorSettings: + prec = new CPQDIF_R_General(); + prec->HeaderSetTag( tagRecMonitorSettings ); + break; + case PFR_Observation: + prec = new CPQDIF_R_General(); + prec->HeaderSetTag( tagRecObservation ); + break; + + default: + prec = NULL; + break; + } + + return prec; + } + + +CPQDIF_R_Observation * CPQDIF_Factory::NewObservationWrapper + ( + CPQDIFRecord * precBase, + CPQDIFRecord * precDataSource + ) +{ + CPQDIF_R_Observation * pobs = NULL; + CPQDIF_R_DataSource * pds = NULL; + + pobs = new CPQDIF_R_Observation( *precBase ); + if( pobs ) + { + // + // + // Replaced dynamic cast with static cast. I don't understand why + // dynamic does not work (RTTI is enabled). Rob has a comment in another + // code module in the Hank data manager code that says a static cast has to + // be used in this situation since the classes involved have no data members. + // +// pds = dynamic_cast( precDataSource ); + pds = static_cast( precDataSource ); + if( pds ) + { + pobs->SetDataSource( pds ); + } + } + + return pobs; +} + + +CPQDIF_R_Observation * CPQDIF_Factory::NewObservationWrapper2 + ( + CPQDIFRecord * precBase, + CPQDIFRecord * precDataSource, + CPQDIFRecord * precSettings + ) + { + CPQDIF_R_Observation * pobs = NULL; + CPQDIF_R_DataSource * pds; + CPQDIF_R_Settings * psett; + + pobs = new CPQDIF_R_Observation( *precBase ); + if( pobs ) + { + // Check the casts first + // + // + // Replaced dynamic cast with static cast. I don't understand why + // dynamic does not work (RTTI is enabled). Rob has a comment in another + // code module in the Hank data manager code that says a static cast has to + // be used in this situation since the classes involved have no data members. + // + pds = static_cast( precDataSource ); +// pds = dynamic_cast( precDataSource ); + if( pds ) + pobs->SetDataSource( pds ); + +// psett = dynamic_cast( precSettings ); + psett = static_cast( precSettings ); + if( psett ) + pobs->SetMonitorSettings( psett ); + } + + return pobs; + } + + +// Creates a new PQDIF element object from the specified concrete +// class. +// +CPQDIF_Element * CPQDIF_Factory::NewElement( long which ) + { + CPQDIF_Element * pel = NULL; + + switch( which ) + { + case ID_ELEMENT_TYPE_COLLECTION: + pel = new CPQDIF_E_Collection(); + break; + + case ID_ELEMENT_TYPE_SCALAR: + pel = new CPQDIF_E_Scalar(); + break; + + case ID_ELEMENT_TYPE_VECTOR: + pel = new CPQDIF_E_Vector(); + break; + + default: + pel = NULL; + break; + } + + return pel; + } + diff --git a/LFtid1056/pqdif/include/pqdfacty.h b/LFtid1056/pqdif/include/pqdfacty.h new file mode 100644 index 0000000..339d5fc --- /dev/null +++ b/LFtid1056/pqdif/include/pqdfacty.h @@ -0,0 +1,79 @@ +// File name: $Workfile: pqdfacty.h $ +// Last modified: $Modtime: 2/09/98 4:18p $ +// Last modified by: $Author: Rob $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pqdfacty.h $ +// VCS revision: $Revision: 5 $ + +#include "pqdif_lg.h" + +// Interface declarations +class CPQDIF_StreamIO; +class CPQDIF_StreamProcessor; +class CPQDIF_Element; +class IPQDIF_Importer; + +// Parameters +enum PF_PersistController + { + PFPC_FlatFile, + PFPC_HCOM // Hank DMM (550x) implementation + }; + +enum PF_StreamIO + { + PSIO_FlatFile, + PSIO_Chunk, + PSIO_HCOM // Hank DMM (550x) implementation + }; + +enum PF_Record + { + PFR_Record, + PFR_Container, + PFR_DataSource, + PFR_MonitorSettings, + PFR_Observation + }; + + +class CPQDIF_Factory + { + public: + CPQDIF_Factory(); + ~CPQDIF_Factory(); + + // Attributes + public: + + // Operations + public: +#ifndef _PQDIF_NO_PERSIST_CONTROLLER + CPQDIF_PersistController * NewPersistController( PF_PersistController which ); +#endif + + CPQDIF_StreamIO * NewStreamIO( PF_StreamIO which ); + CPQDIF_StreamProcessor * NewStreamProcessor( long which ); + + CPQDIF_Element * NewElement( long which ); + + CPQDIFRecord * NewRecord( PF_Record which ); + CPQDIF_R_Observation * NewObservationWrapper + ( + CPQDIFRecord * precBase, + CPQDIFRecord * precDataSource + ); + CPQDIF_R_Observation * NewObservationWrapper2 + ( + CPQDIFRecord * precBase, + CPQDIFRecord * precDataSource, + CPQDIFRecord * precSettings + ); + + // Implementation + protected: + }; + + +// The one and only factory object (Singleton) +extern CPQDIF_Factory theFactory; diff --git a/LFtid1056/pqdif/include/pqdif_custom_1.h b/LFtid1056/pqdif/include/pqdif_custom_1.h new file mode 100644 index 0000000..a1443aa --- /dev/null +++ b/LFtid1056/pqdif/include/pqdif_custom_1.h @@ -0,0 +1,31 @@ +// +// This file is included just after the windows.h and STL library includes +// using namespace std; declaration and just before the standard PQDIF headers +// in PQDIF_classes.h +// +// Use this file to add custom headers for your implementation of PQDIF +// +// ============================================================================= +// +// Begin Custom Header +// +// ============================================================================= +// +#ifdef __BORLANDC__ +#define _stricmp stricmp +#else +#if _MSC_VER >= 1100 +#include +#endif +#include +#include +#endif + +#undef ASSERT +#define ASSERT(x) + +#undef ASSERT_VALID +#define ASSERT_VALID(x) + +#undef _T +#define _T diff --git a/LFtid1056/pqdif/include/pqdif_custom_2.h b/LFtid1056/pqdif/include/pqdif_custom_2.h new file mode 100644 index 0000000..957fe65 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdif_custom_2.h @@ -0,0 +1,13 @@ +// +// This file is included after all standard PQDIF header includes in PQDIF_classes.h +// +// Use this file to add custom headers for your implementation of PQDIF +// +// ============================================================================= +// +// Begin Custom Header +// +// ============================================================================= +// + +#include "pqdsupport.h" // COM (VARIANT) support class \ No newline at end of file diff --git a/LFtid1056/pqdif/include/pqdif_id.h b/LFtid1056/pqdif/include/pqdif_id.h new file mode 100644 index 0000000..f732676 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdif_id.h @@ -0,0 +1,1983 @@ +/* +** PQDIF - Power Quality Data Interchange Format +** Version 1.5 +** +** File name: $Workfile: pqdif_id.h $ +** Last modified: $Modtime: 7/03/02 2:21p $ +** Last modified by: $Author: Jack $ +** +** VCS archive path: $Archive: /PQDIF/Document/Version15/pqdif_id.h $ +** VCS revision: $Revision: 50 $ +** +** STANDARD ID DEFINITIONS +** ====================================================================== +** This file contains the current list of standard IDs for the various +** tags in the PQDIF standard. The IDs consist of two types: GUIDs +** and integers (UINT4). For now, the integer uses a #define and the GUID +** uses a const GUID ... +** ====================================================================== +** The current version of this file and related information +** can be found at URL: +** +** http://grouper.ieee.org/groups/1159/3/docs.html +** +** ====================================================================== +** +*/ + +#ifndef PQDIF_ID_H +#define PQDIF_ID_H + +// ====================================================================== +// Do not modify anything after the following comment: +// {{{{ AUTO-GENERATED CONSTANTS }}}} + +// ========================================================== +// The following IDs are the legal values for +// tagCompressionStyleID +// ========================================================== + +// Description: No compression is used. +// Version: 1.0 +#define ID_COMP_STYLE_NONE 0 + +// Description: The body of each record is compressed individually. The checksums will be found in the header of each record. +// Version: 1.0 +#define ID_COMP_STYLE_RECORDLEVEL 2 + +// Description: Everything after the container record is compressed as a single block. This feature has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +#define ID_COMP_STYLE_TOTALFILE 1 + +// ========================================================== +// The following IDs are the legal values for +// tagCompressionAlgorithmID +// ========================================================== + +// Description: No compression algorithm is used. +// Version: 1.0 +#define ID_COMP_ALG_NONE 0 + +// Description: A standard compression algorithm -- ZLIB -- standardized by the IETF (Internet Engineering Task Force). See http://quest.jpl.nasa.gov/zlib/ for details. +// Version: 1.0 +#define ID_COMP_ALG_ZLIB 1 + +// Description: A commercial package, the PKZIP data compression library, was used to compress the data. This feature has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +#define ID_COMP_ALG_PKZIPCL 64 + +// ========================================================== +// The following IDs are the legal values for +// tagDataSourceTypeID +// ========================================================== + +// Version: 1.0 +const GUID ID_DS_TYPE_MEASURE = { 0xe6b51730, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_DS_TYPE_MANUAL = { 0xe6b51731, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_DS_TYPE_SIMULATE = { 0xe6b51732, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_DS_TYPE_BENCHMARK = { 0xe6b51733, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_DS_TYPE_DEBUG = { 0xe6b51734, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// ========================================================== +// The following IDs are the legal values for +// tagVendorID +// ========================================================== + +const GUID ID_VENDOR_SATEC = { 0xe2da5081, 0x7fdb, 0x11d3, { 0x9b, 0x39, 0x0, 0x40, 0x5, 0x2c, 0x2d, 0x28 } }; + +const GUID ID_VENDOR_WPT = { 0xe2da5082, 0x7fdb, 0x11d3, { 0x9b, 0x39, 0x0, 0x40, 0x5, 0x2c, 0x2d, 0x28 } }; + +const GUID ID_VENDOR_NONE = { 0xe6b51701, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_BMI = { 0xe6b51702, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_BPA = { 0xe6b51703, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_CESI = { 0xe6b51704, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_COOPER = { 0xe6b51705, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_DCG = { 0xe6b51706, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_DRANETZ = { 0xe6b51707, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_EDF = { 0xe6b51708, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_EPRI = { 0xe6b51709, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_ELECTROTEK = { 0xe6b5170a, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_FLUKE = { 0xe6b5170b, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_HYDROQUEBEC = { 0xe6b5170c, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_IEEE = { 0xe6b5170d, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_KREISSJOHNSON = { 0xe6b5170e, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_METROSONIC = { 0xe6b5170f, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_PML = { 0xe6b51710, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_PSI = { 0xe6b51711, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_PTI = { 0xe6b51712, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_PUBLICDOMAIN = { 0xe6b51713, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_RPM = { 0xe6b51714, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_SQUAREDPOWERLOGIC = { 0xe6b51715, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_VENDOR_TELOG = { 0xe6b51716, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.5 +const GUID ID_VENDOR_PMI = { 0x609acec0, 0x993d, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_VENDOR_METONE = { 0xb5b5da61, 0xe2e1, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: Trinergi +// Version: 1.5 +const GUID ID_VENDOR_TRINERGI = { 0xfd5a3a8, 0xd73a, 0x11d2, { 0xac, 0x3e, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: General Electric US +// Version: 1.5 +const GUID ID_VENDOR_GE = { 0x5202bd00, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_VENDOR_LEM = { 0x80c4a722, 0x2816, 0x11d4, { 0x8a, 0xb4, 0x0,0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_VENDOR_ACTL = { 0x80c4a761, 0x2816, 0x11d4, { 0x8a, 0xb4,0x0,0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Description: Advantech +// Version: 1.5 +const GUID ID_VENDOR_ADVANTECH = { 0x650f988f, 0x378c, 0x47b8, { 0xba, 0xed, 0xcc, 0xcb, 0x3f, 0x95, 0x9a, 0xd7 } }; + +// Description: Elcom +// Version: 1.5 +const GUID ID_VENDOR_ELCOM = { 0xf7e9eb70, 0x6f1d, 0x11d6, {0x9c, 0xb3, 0x00, 0x20, 0xe0, 0x10, 0x45, 0x3b } }; + +// ========================================================== +// The following IDs are the legal values for +// tagEquipmentID +// ========================================================== + +const GUID ID_EQUIP_WPT_5530 = { 0xe2da5083, 0x7fdb, 0x11d3, { 0x9b, 0x39, 0x0, 0x40, 0x5, 0x2c, 0x2d, 0x28 } }; + +const GUID ID_EQUIP_WPT_5540 = { 0xe2da5084, 0x7fdb, 0x11d3, { 0x9b, 0x39, 0x0, 0x40, 0x5, 0x2c, 0x2d, 0x28 } }; + +const GUID ID_EQUIP_BMI_3100 = { 0xf1c04780, 0x50fb, 0x11d3, { 0xac, 0x3e, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +const GUID ID_EQUIP_BMI_7100 = { 0xe6b51717, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_BMI_8010 = { 0xe6b51718, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_BMI_8020 = { 0xe6b51719, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_BMI_9010 = { 0xe6b5171a, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_COOPER_VHARM = { 0xe6b5171b, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_COOPER_VFLICKER = { 0xe6b5171c, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_DCG_EMTP = { 0xe6b5171d, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_DRANETZ_656 = { 0xe6b5171e, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_DRANETZ_658 = { 0xe6b5171f, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_TESTPROGRAM = { 0xe6b51721, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_DRANETZ_8000 = { 0xe6b51720, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_PQDIFEDITOR = { 0xe6b51722, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_PASS = { 0xe6b51723, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_SUPERHARM = { 0xe6b51724, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_SUPERTRAN = { 0xe6b51725, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_TOP = { 0xe6b51726, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_PQVIEW = { 0xe6b51727, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_ETK_HARMONI = { 0xe6b51728, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_FLUKE_CUR = { 0xe6b51729, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_IEEE_COMTRADE = { 0xe6b5172b, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_FLUKE_F41 = { 0xe6b5172a, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PUBLIC_ATP = { 0xe6b5172c, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_METROSONIC_M1 = { 0xe6b5172d, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_SQD_SMS = { 0xe6b5172e, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_TELOG_M1 = { 0xe6b5172f, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_3710 = { 0x85726d0, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_3720 = { 0x85726d1, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_3800 = { 0x85726d2, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_7300 = { 0x85726d3, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_7700 = { 0x85726d4, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_VIP = { 0x85726d5, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +const GUID ID_EQUIP_PML_LOGSERVER = { 0x85726d6, 0x1dc0, 0x11d0, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.5 +const GUID ID_EQUIP_METONE_ELT15 = { 0xb5b5da62, 0xe2e1, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Version: 1.5 +const GUID ID_EQUIP_PMI_SCANNER = { 0x609acec1, 0x993d, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Advantech ADAM 4017 +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4017 = { 0x92b7977b, 0xc02, 0x4766, { 0x95, 0xcf, 0xdd, 0x37, 0x9c, 0xae, 0xb4, 0x17 } }; + +// Description: Electrotek DSS +// Version: 1.5 +const GUID ID_EQUIP_ETK_DSS = { 0xd347ba66, 0xe34c, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: Advantech ADAM 4018 +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4018 = { 0x3008151e, 0x2317, 0x4405, { 0xa5, 0x9e, 0xe7, 0xb3, 0xb2, 0x6, 0x67, 0xa9 } }; + +// Description: Advantech ADAM 4018M +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4018M = { 0x3a1af807, 0x1347, 0x45f8, { 0x96, 0x6a, 0xf4, 0x81, 0xc6, 0xae, 0x20, 0x8e } }; + +// Description: Advantech ADAM 4052 +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4052 = { 0x8bba416b, 0xa7ec, 0x4616, { 0x8b, 0x8f, 0x59, 0xfe, 0xd7, 0x49, 0x32, 0x3d } }; + +// Description: BMI 8800 +// Version: 1.5 +const GUID ID_EQUIP_BMI_8800 = { 0xe77d1a81, 0x1235, 0x11d5, { 0xa3, 0x90, 0x0, 0x10, 0xa4, 0x92, 0x4e, 0xcc } }; + +// Description: Trinergi PQM +// Version: 1.5 +const GUID ID_EQUIP_TRINERGI_PQM = { 0xfd5a3aa, 0xd73a, 0x11d2, { 0xac, 0x3e, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Medcal +// Version: 1.5 +const GUID ID_EQUIP_MEDCAL = { 0xf3bfa0a1, 0xeb87, 0x11d2, { 0xac, 0x3e, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: GE kV Energy Meter +// Version: 1.5 +const GUID ID_EQUIP_GE_KV = { 0x5202bd01, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: GE kV2 Energy Meter +// Version: 1.5 +const GUID ID_EQUIP_GE_KV2 = { 0x5202bd03, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ACUMENTRICS_CONTROL = { 0x5202bd04, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ETK_TEXTPQDIF = { 0x5202bd05, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ETK_PQWEB = { 0x5202bd06, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_POWER_DISTRIBUTION = { 0x80c4a723, 0x2816,0x11d4,{ 0x8a, 0xb4, 0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_POWER_TRANSMISSION = { 0x80c4a725, 0x2816,0x11d4,{ 0x8a, 0xb4, 0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_MICRO = { 0x80c4a727, 0x2816, 0x11d4, { 0x8a,0xb4, 0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_TWIN = { 0x80c4a728, 0x2816, 0x11d4, { 0x8a,0xb4,0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_PREMIUM = { 0x80c4a729, 0x2816, 0x11d4, { 0x8a,0xb4, 0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_LIGHT = { 0x80c4a72a, 0x2816, 0x11d4, { 0x8a,0xb4, 0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QWAVE_NOMAD = { 0x80c4a72b, 0x2816, 0x11d4, { 0x8a,0xb4, 0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_EWON_4000 = { 0x80c4a762, 0x2816, 0x11d4, { 0x8a, 0xb4,0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_QUALIMETRE = { 0x80c4a764, 0x2816, 0x11d4, { 0x8a,0xb4,0x0, 0x40, 0x5, 0x69, 0x8d, 0x26 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_ANALYST3Q = { 0xd567cb71, 0xbcc0, 0x41ee, { 0x8e, 0x8c, 0x35, 0x85, 0x15, 0x53, 0xf6, 0x55 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_ANALYST1Q = { 0x477ecb3b, 0x917f, 0x4915, { 0xaf, 0x99, 0xa6, 0xc2, 0x9a, 0xc1, 0x87, 0x64 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_ANALYST2050 = { 0x9878ccab, 0xa842, 0x4cac, { 0x95, 0xf, 0x6d, 0x47, 0x21, 0x5b, 0xff, 0xdf } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_ANALYST2060 = { 0x312471a2, 0xb586, 0x491c, { 0x85, 0x5a, 0xca, 0x5, 0x45, 0x9a, 0x7e, 0x20 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MIDGET200 = { 0x8449f6b9, 0x10f4, 0x40a7, { 0xa1, 0xc3, 0xbe, 0x33, 0x8e, 0xb9, 0x74, 0x22 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MBX300 = { 0xd4578d61, 0xdf2b, 0x4218, { 0xa7, 0xb1, 0x5e, 0xf1, 0xa9, 0xbb, 0x85, 0xfa } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MBX800 = { 0x1c14b57a, 0xba25, 0x47fb, { 0x88, 0xfa, 0x5f, 0xe5, 0xce, 0xc9, 0x9e, 0x6a } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MBX601 = { 0x1f3cda7b, 0x2ce1, 0x4030, { 0xa3, 0x90, 0xe3, 0xd4, 0x9c, 0x56, 0x15, 0xd2 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MBX602 = { 0x4a157756, 0x414a, 0x427b, { 0x99, 0x32, 0x55, 0x76, 0xe, 0xd5, 0xf7, 0x7 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MBX603 = { 0xf7b4677b, 0xb277, 0x45b5, { 0xaa, 0xae, 0x5f, 0xb3, 0x93, 0x41, 0xb3, 0x90 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_MBX686 = { 0x40004266, 0xa978, 0x4991, { 0x9e, 0xd6, 0xc1, 0xcd, 0x73, 0xf, 0x5b, 0xf5 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_PERMA701 = { 0x9b0dfd9d, 0xd4e9, 0x419d, { 0xba, 0x10, 0xc1, 0xce, 0xe6, 0xcf, 0x8f, 0x93 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_PERMA702 = { 0x7f5d62ac, 0x9fab, 0x400f, { 0xb5, 0x1a, 0xf0, 0xf3, 0x94, 0x1f, 0xb5, 0xaa } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_PERMA705 = { 0xd85fea9c, 0x14d5, 0x45eb, { 0x83, 0x1f, 0xe0, 0x39, 0x73, 0x9, 0x2b, 0xd8 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_PERMA706 = { 0x16d6bbfc, 0xb5a, 0x4cf0, { 0x81, 0xcf, 0x48, 0xa3, 0x10, 0x5e, 0xff, 0x4f } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVEMICRO = { 0xe0380e52, 0xc205, 0x43a0, { 0x9f, 0xf4, 0x76, 0xfb, 0xd6, 0x76, 0x5f, 0x37 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVENOMAD = { 0x165f145d, 0x90c3, 0x4591, { 0x95, 0x9a, 0x33, 0xb1, 0x1, 0xd4, 0xbf, 0x8b } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVELIGHT = { 0x5198ceb9, 0x4b4e, 0x439c, { 0xa1, 0xc0, 0x21, 0x8c, 0x96, 0x3d, 0x6a, 0x9c } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVETWIN = { 0x67a42a2d, 0xb831, 0x4222, { 0x80, 0x5e, 0xd5, 0xfd, 0xeb, 0xdd, 0x3a, 0x46 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVEPOWER_DISTRIBUTION = { 0x2401bf48, 0x9db2, 0x46ec, { 0xac, 0xde, 0x5d, 0xed, 0xde, 0x25, 0xe5, 0x4e } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVEPREMIUM = { 0x6b609a29, 0x4a64, 0x4d1c, { 0xa6, 0xe3, 0xca, 0xef, 0x94, 0xfa, 0x56, 0xa0 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_QWAVEPOWER_TRANSPORT = { 0xd4422eeb, 0xb1cd, 0x4ba9, { 0xa7, 0xc8, 0x5d, 0x14, 0x1d, 0xf4, 0x5, 0x18 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_TOPASLT = { 0x9c46483a, 0x541e, 0x4d66, { 0x9c, 0x10, 0xf9, 0x43, 0xab, 0xfc, 0x34, 0x8a } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_TOPAS1000 = { 0x459b8614, 0x6724, 0x48fb, { 0xb5, 0xd4, 0xf1, 0x49, 0xed, 0xc, 0x62, 0xf5 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_TOPAS1019 = { 0x7b11408b, 0x9d2c, 0x407c, { 0x84, 0xa5, 0x89, 0x44, 0x2, 0x18, 0xdc, 0xf8 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_TOPAS1020 = { 0xd1def77d, 0x990f, 0x484e, { 0xa1, 0x66, 0xf7, 0x92, 0x11, 0x70, 0xa6, 0x4b } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_TOPAS1040 = { 0xd3cc1de2, 0x6e6b, 0x4b6e, { 0xad, 0x90, 0x10, 0xd6, 0x58, 0x5f, 0x8f, 0xa2 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_BEN5000 = { 0xa70e32b1, 0x2f1a, 0x4543, { 0xa6, 0x84, 0x78, 0xa4, 0xb5, 0xbe, 0x34, 0xbb } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_BEN6000 = { 0x5a4c1b5, 0x6681, 0x47e6, { 0x9f, 0x64, 0x8d, 0xa1, 0x25, 0xdb, 0xec, 0x32 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_EWAVE = { 0xe46981d5, 0x708d, 0x4822, { 0x97, 0xaa, 0xfd, 0xb6, 0xf7, 0x3b, 0x3a, 0xf2 } }; + +// Version: 1.5 +const GUID ID_EQUIP_LEM_EWON4000 = { 0xd4c0895c, 0xfd48, 0x4981, { 0x99, 0x7c, 0x9e, 0x70, 0xd8, 0xe, 0xfb, 0x6 } }; + +// Version: 1.5 +const GUID ID_EQUIP_WPT_5510 = { 0x752871de, 0x583, 0x4d44, { 0xa9, 0xae, 0xc5, 0xfa, 0xdc, 0x1, 0x44, 0xac } }; + +// Version: 1.5 +const GUID ID_EQUIP_WPT_5520 = { 0xb72d289, 0x7645, 0x40b8, { 0x94, 0x6e, 0xc3, 0xce, 0x4f, 0x1b, 0xcd, 0x37 } }; + +// Version: 1.5 +const GUID ID_EQUIP_WPT_5530T = { 0x8f88ea9e, 0x1007, 0x4569, { 0xab, 0x47, 0x75, 0x6f, 0x29, 0x2a, 0x23, 0xed } }; + +// Version: 1.5 +const GUID ID_EQUIP_WPT_5560 = { 0x5fd9c0ff, 0x4432, 0x41b5, { 0x9a, 0x9e, 0x9a, 0x32, 0xba, 0x2c, 0xf0, 0x5 } }; + +// Version: 1.5 +const GUID ID_EQUIP_WPT_5590 = { 0x2861d5ca, 0x23ac, 0x4a51, { 0xa5, 0xa0, 0x49, 0x8d, 0xa6, 0x1d, 0x26, 0xdd } }; + +// Version: 1.5 +const GUID ID_EQUIP_ETK_NODECENTER = { 0xc52e8460, 0x58b4, 0x4f1a, { 0x84, 0x69, 0x69, 0xca, 0x3f, 0xef, 0x9f, 0xf1 } }; + +// Version: 1.5 +const GUID ID_EQUIP_WPT_DRANVIEW = { 0x8d97aa1, 0x1719, 0x11d6, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM5017 = { 0x2f46263c, 0x92ac, 0x4717, { 0x8a, 0x8, 0xa6, 0x17, 0x7d, 0xf3, 0xf6, 0x11 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM5018 = { 0xcc2d3247, 0xfe65, 0x4db6, { 0x82, 0x6, 0x50, 0xa, 0x23, 0x15, 0x1b, 0xb2 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM5080 = { 0x6c37b63c, 0xe770, 0x4b85, { 0xbd, 0x32, 0x47, 0x39, 0xd6, 0xeb, 0x98, 0x46 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM5052 = { 0xe9261dfe, 0x3d44, 0x47e3, { 0xac, 0x36, 0x3b, 0x9, 0x7f, 0xaa, 0x8c, 0xda } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4050 = { 0x9212066d, 0xea65, 0x477e, { 0xbf, 0x95, 0xe4, 0xa0, 0x6, 0x6d, 0x25, 0xce } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4053 = { 0xdc29b83f, 0xbebe, 0x4cf3, { 0xb3, 0xfb, 0x0, 0xdc, 0x63, 0x62, 0x6d, 0xd9 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM4080 = { 0x64fc42c6, 0x3c90, 0x4633, { 0x99, 0xdf, 0x2c, 0x60, 0x58, 0x21, 0x4b, 0x72 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM5050 = { 0xc950a2e3, 0x7a35, 0x440c, { 0x86, 0x60, 0x63, 0xf6, 0x11, 0x97, 0x25, 0x19 } }; + +// Version: 1.5 +const GUID ID_EQUIP_ADVANTECH_ADAM5051 = { 0xc8f92334, 0xa69b, 0x4856, { 0xb2, 0x53, 0xec, 0x24, 0x71, 0xd1, 0x37, 0xd6 } }; + +// Description: ELCOM_BK550 +// Version: 1.5 +const GUID ID_EQUIP_ELCOM_BK550 = { 0xf4380a60, 0x6f1d, 0x11d6, {0x9c, 0xb3, 0x00, 0x20, 0xe0, 0x10, 0x45, 0x3b } }; + +// ========================================================== +// The following IDs are the legal values for +// tagInstrumentTypeID +// ========================================================== + +// Version: 1.0 +const GUID ID_INSTR_TYPE_SCOPE = { 0xe6b51735, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Frequency recorder. +// Version: 1.0 +const GUID ID_INSTR_TYPE_FR = { 0xe6b51736, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Power quality meter. +// Version: 1.0 +const GUID ID_INSTR_TYPE_PQM = { 0xe6b51737, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Voltage recorder. +// Version: 1.0 +const GUID ID_INSTR_TYPE_VR = { 0xe6b51738, 0xf747, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_INSTR_TYPE_SA = { 0xc690e871, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// ========================================================== +// The following IDs are the legal values for +// tagPhaseID +// ========================================================== + +// Description: Phase is not applicable. +// Version: 1.0 +#define ID_PHASE_NONE 0 + +// Description: A-to-neutral. +// Version: 1.0 +#define ID_PHASE_AN 1 + +// Description: B-to-neutral. +// Version: 1.0 +#define ID_PHASE_BN 2 + +// Description: C-to-neutral. +// Version: 1.0 +#define ID_PHASE_CN 3 + +// Description: Neutral-to-ground. +// Version: 1.0 +#define ID_PHASE_NG 4 + +// Description: A-to-B. +// Version: 1.0 +#define ID_PHASE_AB 5 + +// Description: B-to-C. +// Version: 1.0 +#define ID_PHASE_BC 6 + +// Description: C-to-A. +// Version: 1.0 +#define ID_PHASE_CA 7 + +// Description: Residual - the vector or point-on-wave sum of Phases A, B, and C. Should be zero in a perfectly balanced system. +// Version: 1.0 +#define ID_PHASE_RES 8 + +// Description: Net - the vector or point-on-wave sum of Phases A, B, C and the Neutral phase. Should be zero in a 4 wire system with no earth return path. +// Version: 1.0 +#define ID_PHASE_NET 9 + +// Description: The value representing a total or other summarizing value in a multi-phase system. +// Version: 1.5 +#define ID_PHASE_TOTAL 13 + +// Description: The value representing average of 3 line-neutral values +// Version: 1.5 +#define ID_PHASE_LN_AVE 14 + +// Description: The value representing average of 3 line-line values +// Version: 1.5 +#define ID_PHASE_LL_AVE 15 + +// Description: The value representing the "worst" of the 3 phases +// Version: 1.5 +#define ID_PHASE_WORST 16 + +// Description: DC Positive +// Version: 1.5 +#define ID_PHASE_PLUS 17 + +// Description: DC Negative +// Version: 1.5 +#define ID_PHASE_MINUS 18 + +// Description: Generic Phase 1 +// Version: 1.5 +#define ID_PHASE_GENERAL_1 19 + +// Description: Generic Phase 2 +// Version: 1.5 +#define ID_PHASE_GENERAL_2 20 + +// Description: Generic Phase 3 +// Version: 1.5 +#define ID_PHASE_GENERAL_3 21 + +// Description: Generic Phase 4 +// Version: 1.5 +#define ID_PHASE_GENERAL_4 22 + +// Description: Generic Phase 5 +// Version: 1.5 +#define ID_PHASE_GENERAL_5 23 + +// Description: Generic Phase 6 +// Version: 1.5 +#define ID_PHASE_GENERAL_6 24 + +// Description: Generic Phase 7 +// Version: 1.5 +#define ID_PHASE_GENERAL_7 25 + +// Description: Generic Phase 8 +// Version: 1.5 +#define ID_PHASE_GENERAL_8 26 + +// Description: Generic Phase 9 +// Version: 1.5 +#define ID_PHASE_GENERAL_9 27 + +// Description: Generic Phase 10 +// Version: 1.5 +#define ID_PHASE_GENERAL_10 28 + +// Description: Generic Phase 11 +// Version: 1.5 +#define ID_PHASE_GENERAL_11 29 + +// Description: Generic Phase 12 +// Version: 1.5 +#define ID_PHASE_GENERAL_12 30 + +// Description: Generic Phase 13 +// Version: 1.5 +#define ID_PHASE_GENERAL_13 31 + +// Description: Generic Phase 14 +// Version: 1.5 +#define ID_PHASE_GENERAL_14 32 + +// Description: Generic Phase 15 +// Version: 1.5 +#define ID_PHASE_GENERAL_15 33 + +// Description: Generic Phase 16 +// Version: 1.5 +#define ID_PHASE_GENERAL_16 34 + +// ========================================================== +// The following IDs are the legal values for +// tagQuantityTypeID +// ========================================================== + +// Description: TIME, VAL / For point-on-wave measurements, +// Version: 1.0 +const GUID ID_QT_WAVEFORM = { 0x67f6af80, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: TIME, MIN, MAX, AVG, INST, VAL ?/ For time-based logged entries. +// Version: 1.5 +const GUID ID_QT_VALUELOG = { 0x67f6af82, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: TIME, MIN, MAX, AVG, INST, VAL, PHASEANGLE ?/ For time-domain measurements including magnitudes and (optionally) phase angle. +// Version: 1.5 +const GUID ID_QT_PHASOR = { 0x67f6af81, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: VAL (FREQUENCY), VAL, PHASEANGLE / For frequency-domain measurements including magnitude and (optionally) phase angle. +// Version: 1.0 +const GUID ID_QT_RESPONSE = { 0x67f6af85, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: TIME, LAT, LON, VAL, POLARITY, ELLIPSE +// Version: 1.0 +const GUID ID_QT_FLASH = { 0x67f6af83, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: BINLOW, BINHIGH, BINID, COUNT +// Version: 1.0 +const GUID ID_QT_HISTOGRAM = { 0x67f6af87, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: XBINLOW, XBINHIGH, YBINLOW, YBINHIGH, BINID, COUNT +// Version: 1.0 +const GUID ID_QT_HISTOGRAM3D = { 0x67f6af88, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: PROB, VAL. (Note that the specific P1 value types have been deprecated.) +// Version: 1.0 +const GUID ID_QT_CPF = { 0x67f6af89, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: VAL, VAL +// Version: 1.0 +const GUID ID_QT_XY = { 0x67f6af8a, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: VAL, DUR +// Version: 1.0 +const GUID ID_QT_MAGDUR = { 0x67f6af8b, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: VAL, VAL, VAL +// Version: 1.0 +const GUID ID_QT_XYZ = { 0x67f6af8c, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: TIME, VAL, DUR +// Version: 1.0 +const GUID ID_QT_MAGDURTIME = { 0x67f6af8d, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: TIME, VAL, DUR, COUNT +// Version: 1.0 +const GUID ID_QT_MAGDURCOUNT = { 0x67f6af8e, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// ========================================================== +// The following IDs are the legal values for +// tagDisturbanceCategoryID +// ========================================================== + +// Description: No IEEE 1159 definition applicable or desired +// Version: 1.0 +const GUID ID_DISTURB_1159_NONE = { 0x67f6af8f, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: IEEE 1159 Transient +// Version: 1.0 +const GUID ID_DISTURB_1159_TRANSIENT = { 0x67f6af90, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: IEEE 1159 Impulsive Transient +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_IMPULSIVE = { 0xdd56ef60, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Impulsive Transient - nanosecond duration +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_IMPULSIVE_NANO = { 0xdd56ef61, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Impulsive Transient - microsecond duration +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_IMPULSIVE_MICRO = { 0xdd56ef63, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Impulsive Transient - millisecond duration +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_IMPULSIVE_MILLI = { 0xdd56ef64, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Oscillatory Transient +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_OSCILLATORY = { 0xdd56ef65, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Oscillatory Transient - Low Frequency +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_OSCILLATORY_LOWFREQ = { 0xdd56ef66, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Oscillatory Transient - Medium Frequency +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_OSCILLATORY_MEDFREQ = { 0xdd56ef67, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Oscillatory Transient - High Frequency +// Version: 1.5 +const GUID ID_DISTURB_1159_TRANSIENT_OSCILLATORY_HIGHFREQ = { 0xdd56ef68, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation +// Version: 1.0 +const GUID ID_DISTURB_1159_SHORTDUR = { 0x67f6af91, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Instantaneous duration +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_INSTANT = { 0xdd56ef69, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Instantaneous Sag +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_INSTANT_SAG = { 0xdd56ef6a, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Instantaneous Swell +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_INSTANT_SWELL = { 0xdd56ef6b, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Momentary Duration +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_MOMENT = { 0xdd56ef6c, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Momentary Interruption +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_MOMENT_INTERRUPT = { 0xdd56ef6d, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Momentary Sag +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_MOMENT_SAG = { 0xdd56ef6e, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Momentary Swell +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_MOMENT_SWELL = { 0xdd56ef6f, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Temporary Duration +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_TEMP = { 0xdd56ef70, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Temporary Interruption +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_TEMP_INTERRUPT = { 0xdd56ef71, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Temporary Sag +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_TEMP_SAG = { 0xdd56ef72, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Short Duration RMS Variation - Temporary Swell +// Version: 1.5 +const GUID ID_DISTURB_1159_SHORTDUR_TEMP_SWELL = { 0xdd56ef73, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Long Duration RMS Variation +// Version: 1.0 +const GUID ID_DISTURB_1159_LONGDUR = { 0x67f6af92, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: IEEE 1159 Long Duration RMS Variation - Interruption +// Version: 1.5 +const GUID ID_DISTURB_1159_LONGDUR_INTERRUPT = { 0xdd56ef74, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Long Duration RMS Variation - Undervoltage +// Version: 1.5 +const GUID ID_DISTURB_1159_LONGDUR_SAG = { 0xdd56ef75, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Long Duration RMS Variation - Overvoltage +// Version: 1.5 +const GUID ID_DISTURB_1159_LONGDUR_SWELL = { 0xdd56ef76, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Imbalance +// Version: 1.5 +const GUID ID_DISTURB_1159_IMBALANCE = { 0xdd56ef77, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Power Frequency Variation +// Version: 1.5 +const GUID ID_DISTURB_1159_POWERFREQVARIATION = { 0xdd56ef7e, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Voltage Fluctuation (causes light flicker) +// Version: 1.5 +const GUID ID_DISTURB_1159_VOLTAGEFLUCTUATION = { 0x67f6af93, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: IEEE 1159 Waveform Distortion +// Version: 1.5 +const GUID ID_DISTURB_1159_WAVEDISTORT = { 0x67f6af94, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: DC offset of voltage or current waveform +// Version: 1.5 +const GUID ID_DISTURB_1159_WAVEDISTORT_DCOFFSET = { 0xdd56ef78, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Waveform Harmonics Present +// Version: 1.5 +const GUID ID_DISTURB_1159_WAVEDISTORT_HARMONIC = { 0xdd56ef79, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Waveform Interharmonics Present +// Version: 1.5 +const GUID ID_DISTURB_1159_WAVEDISTORT_INTERHARMONIC = { 0xdd56ef7a, 0x7edd, 0x11d2, { 0xb3, 0xa, 0x0, 0x60, 0x97, 0x89, 0xd1, 0x93 } }; + +// Description: IEEE 1159 Waveform Notching Present +// Version: 1.5 +const GUID ID_DISTURB_1159_WAVEDISTORT_NOTCHING = { 0x67f6af95, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: IEEE 1159 Waveform Noise Present +// Version: 1.5 +const GUID ID_DISTURB_1159_WAVEDISTORT_NOISE = { 0x67f6af96, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// ========================================================== +// The following IDs are the legal values for +// tagQuantityUnitsID +// ========================================================== + +// Description: Unitless. +// Version: 1.0 +#define ID_QU_NONE 0 + +// Description: Seconds -- relative from the beginning time of the observation (using tagTimeStart as the beginning time). +// Version: 1.0 +#define ID_QU_SECONDS 2 + +// Description: Absolute time. Each timestamp in the series must be in absolute time using the TIMESTAMPPQDIF physical type. This is generally *not* recommended, but is acceptible when _VALUELOG is used. +// Version: 1.0 +#define ID_QU_TIMESTAMP 1 + +// Description: The timestamps are in cycles, relative to tagTimeStart. +// Version: 1.0 +#define ID_QU_CYCLES 3 + +// Description: Volts. +// Version: 1.0 +#define ID_QU_VOLTS 6 + +// Description: Amperes. +// Version: 1.0 +#define ID_QU_AMPS 7 + +// Description: Volt-amperes. +// Version: 1.0 +#define ID_QU_VA 8 + +// Description: Watts. +// Version: 1.0 +#define ID_QU_WATTS 9 + +// Description: Volt-amperes reactive. +// Version: 1.0 +#define ID_QU_VARS 10 + +// Description: Ohms. +// Version: 1.0 +#define ID_QU_OHMS 11 + +// Description: Siemens. +// Version: 1.0 +#define ID_QU_SIEMENS 12 + +// Description: Volts per amp. +// Version: 1.0 +#define ID_QU_VOLTSPERAMP 13 + +// Description: Joules. +// Version: 1.0 +#define ID_QU_JOULES 14 + +// Description: Hertz. +// Version: 1.0 +#define ID_QU_HERTZ 15 + +// Description: Celcius. +// Version: 1.0 +#define ID_QU_CELCIUS 16 + +// Description: Degrees of arc. +// Version: 1.0 +#define ID_QU_DEGREES 17 + +// Description: Decibels. +// Version: 1.0 +#define ID_QU_DB 18 + +// Description: Percent. +// Version: 1.0 +#define ID_QU_PERCENT 19 + +// Description: Per-unit. +// Version: 1.0 +#define ID_QU_PERUNIT 20 + +// Description: Number of counts or samples +// Version: 1.0 +#define ID_QU_SAMPLES 21 + +// Description: Energy - var-hours +// Version: 1.5 +#define ID_QU_VARHOURS 22 + +// Description: Energy - Watt-hours +// Version: 1.5 +#define ID_QU_WATTHOURS 23 + +// Description: Energy - VA-hours +// Version: 1.5 +#define ID_QU_VAHOURS 24 + +// Description: Meters/Second +// Version: 1.5 +#define ID_QU_MPS 25 + +// Description: Miles/Hr +// Version: 1.5 +#define ID_QU_MPH 26 + +// Description: Pressure, Bars +// Version: 1.5 +#define ID_QU_BARS 27 + +// Description: Pressure, Pascals +// Version: 1.5 +#define ID_QU_PASCALS 28 + +// Description: Force, Newtons +// Version: 1.5 +#define ID_QU_NEWTONS 29 + +// Description: Torque, Newton Meters +// Version: 1.5 +#define ID_QU_NEWTONMETERS 30 + +// Description: Revolutions/minute +// Version: 1.5 +#define ID_QU_RPM 31 + +// Description: Radians/Second +// Version: 1.5 +#define ID_QU_RADPERSEC 32 + +// Description: Meters +// Version: 1.5 +#define ID_QU_METERS 33 + +// Description: Flux Linkage - Weber Turns +// Version: 1.5 +#define ID_QU_WEBERTURNS 34 + +// Description: Flux Density - Teslas +// Version: 1.5 +#define ID_QU_TESLAS 35 + +// Description: Magnetic Field - Webers +// Version: 1.5 +#define ID_QU_WEBERS 36 + +// Description: Volts/Volts transfer function +// Version: 1.5 +#define ID_QU_VOLTSPERVOLT 37 + +// Description: Amps/Amps transfer function +// Version: 1.5 +#define ID_QU_AMPSPERAMP 38 + +// Description: Impedance Transfer Funtion +// Version: 1.5 +#define ID_QU_AMPSPERVOLT 39 + +// ========================================================== +// The following IDs are the legal values for +// tagValueTypeID +// ========================================================== + +// Description: This should be the default value type for a measurement -- a value. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_VAL = { 0x67f6af97, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Time. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_TIME = { 0xc690e862, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Minimum. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_MIN = { 0x67f6af98, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Maximum. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_MAX = { 0x67f6af99, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Average. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_AVG = { 0x67f6af9a, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Instantaneous. (depricated - use VAL instead) +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_INST = { 0x67f6af9b, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Phase angle (used for a _VAL series or when it applies to all). +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_PHASEANGLE = { 0x3d786f9d, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Phase angle which corresponds to a _MIN series (completing a complex pair). +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_PHASEANGLE_MIN = { 0xdc762340, 0x3c56, 0x11d2, { 0xae, 0x44, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Phase angle which corresponds to a _MAX series. +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_PHASEANGLE_MAX = { 0xdc762341, 0x3c56, 0x11d2, { 0xae, 0x44, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Phase angle which corresponds to an _AVG series. +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_PHASEANGLE_AVG = { 0xdc762342, 0x3c56, 0x11d2, { 0xae, 0x44, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Area under the signal, usually an rms voltage, current or other quantity. +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_AREA = { 0xc7825ce0, 0x8ace, 0x11d3, { 0xb9, 0x2f, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: Latitude. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_LATITUDE = { 0xc690e864, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Duration. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_DURATION = { 0xc690e863, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Longitude. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_LONGITUDE = { 0xc690e865, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Polarity. +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_POLARITY = { 0xc690e866, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Ellipse (for lightning flash density). +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_ELLIPSE = { 0xc690e867, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_BINID = { 0xc690e869, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_BINHIGH = { 0xc690e86a, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_BINLOW = { 0xc690e86b, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_XBINHIGH = { 0xc690e86c, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_XBINLOW = { 0xc690e86d, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_YBINHIGH = { 0xc690e86e, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_YBINLOW = { 0xc690e86f, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Version: 1.0 +const GUID ID_SERIES_VALUE_TYPE_COUNT = { 0xc690e870, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Transition event code series. This series contains codes cooresponding to values in a value series that indicates what kind of transition caused the event to be recorded. Used only with VALUELOG data. +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_TRANSITION = { 0x5369c260, 0xc347, 0x11d2, { 0x92, 0x3f, 0x0, 0x10, 0x4b, 0x2b, 0x84, 0xb1 } }; + +// Description: Cumulative probability in percent. +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_PROB = { 0x6763cc71, 0x17d6, 0x11d4, { 0x9f, 0x1c, 0x0, 0x20, 0x78, 0xe0, 0xb7, 0x23 } }; + +// Description: Interval data +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_INTERVAL = { 0x72e82a40, 0x336c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Status Data +// Version: 1.5 +const GUID ID_SERIES_VALUE_TYPE_STATUS = { 0xb82b5c82, 0x55c7, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Probability: 1%. This has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_P1 = { 0x67f6af9c, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Probability: 5%. This has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_P5 = { 0x67f6af9d, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Probability: 10%. This has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_P10 = { 0x67f6af9e, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Probability: 90%. This has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_P90 = { 0x67f6af9f, 0xf753, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Probability: 95%. This has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_P95 = { 0xc690e860, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Probability: 99%. This has been deprecated under 1.5 and should not be used. +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_P99 = { 0xc690e861, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Frequency. This has been deprecated under 1.5 and should not be used. (It is now a characteristic instead of a value type.) +// Version: 1.5 Deprecated +const GUID ID_SERIES_VALUE_TYPE_FREQUENCY = { 0xc690e868, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// ========================================================== +// The following IDs are the legal values for +// tagStorageMethodID +// ========================================================== + +// Description: The data in tagSeriesValues are a straight array of data points. +// Version: 1.0 +#define ID_SERIES_METHOD_VALUES 0x01 + +// Description: All values in tagSeriesValues will be multiplied by tagSeriesScale. +// Version: 1.0 +#define ID_SERIES_METHOD_SCALED 0x02 + +// Description: The data in tagSeriesValues consists of a special sequence to indicate the contents of a regular rate series (see main documentation for details). The vector contains: #rates, numpts1, rate1 ... numptsN, rateN. +// Version: 1.0 +#define ID_SERIES_METHOD_INCREMENT 0x04 + +// ========================================================== +// The following IDs are the legal values for +// tagHintGreekPrefixID +// ========================================================== + +// Version: 1.0 +#define ID_GREEK_DONTCARE 0 + +// Version: 1.0 +#define ID_GREEK_FEMTO 1 + +// Version: 1.0 +#define ID_GREEK_PICO 2 + +// Version: 1.0 +#define ID_GREEK_NANO 3 + +// Version: 1.0 +#define ID_GREEK_MICRO 4 + +// Version: 1.0 +#define ID_GREEK_MILLI 5 + +// Version: 1.0 +#define ID_GREEK_NONE 6 + +// Version: 1.0 +#define ID_GREEK_KILO 7 + +// Version: 1.0 +#define ID_GREEK_MEGA 8 + +// Version: 1.0 +#define ID_GREEK_TERA 10 + +// Version: 1.0 +#define ID_GREEK_GIGA 9 + +// ========================================================== +// The following IDs are the legal values for +// tagHintPreferredUnitsID +// ========================================================== + +// Version: 1.0 +#define ID_PREFER_ENG 1 + +// Version: 1.0 +#define ID_PREFER_PCT 2 + +// Version: 1.0 +#define ID_PREFER_PU 3 + +// ========================================================== +// The following IDs are the legal values for +// tagHintDefaultDisplayID +// ========================================================== + +// Version: 1.0 +#define ID_DEFAULT_DONTCARE 0 + +// Version: 1.0 +#define ID_DEFAULT_MAG 1 + +// Version: 1.0 +#define ID_DEFAULT_ANG 2 + +// Version: 1.0 +#define ID_DEFAULT_REAL 3 + +// Version: 1.0 +#define ID_DEFAULT_IMAG 4 + +// Version: 1.0 +#define ID_DEFAULT_RX 5 + +// ========================================================== +// The following IDs are the legal values for +// tagTriggerTypeID +// ========================================================== + +// Version: 1.0 +#define ID_TRIG_NONE 0x00 + +// Version: 1.0 +#define ID_TRIG_LOW 0x01 + +// Version: 1.0 +#define ID_TRIG_HIGH 0x02 + +// Version: 1.0 +#define ID_TRIG_RATE 0x04 + +// Version: 1.0 +#define ID_TRIG_SHAPE 0x08 + +// Version: 1.0 +#define ID_TRIG_OTHER 0x10 + +// ========================================================== +// The following IDs are the legal values for +// tagXDTransformerTypeID +// ========================================================== + +// Version: 1.0 +#define ID_XFORMER_TYPE_CT 2 + +// Version: 1.0 +#define ID_XFORMER_TYPE_PT 1 + +// ========================================================== +// The following IDs are the legal values for +// tagTriggerMethodID +// ========================================================== + +// Version: 1.0 +#define ID_TRIGGER_METH_NONE 0 + +// Description: A specific channel (or channels) caused the trigger; should be used with tagChannelTriggerIdx to specify which channels. +// Version: 1.0 +#define ID_TRIGGER_METH_CHANNEL 1 + +// Version: 1.0 +#define ID_TRIGGER_METH_PERIODIC 2 + +// Version: 1.0 +#define ID_TRIGGER_METH_EXTERNAL 3 + +// Description: Periodic Statistical Data +// Version: 1.5 +#define ID_TRIGGER_METH_PERIODIC_STATS 4 + +// ========================================================== +// The following IDs are the legal values for +// tagQuantityCharacteristicID +// ========================================================== + +// Version: 1.5 +const GUID ID_QC_NONE = { 0xa6b31adf, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Instantaneous f(t) +// Version: 1.5 +const GUID ID_QC_INSTANTANEOUS = { 0xa6b31add, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Spectra F(F) +// Version: 1.5 +const GUID ID_QC_SPECTRA = { 0xa6b31ae9, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Peak value +// Version: 1.5 +const GUID ID_QC_PEAK = { 0xa6b31ae2, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: RMS value +// Version: 1.5 +const GUID ID_QC_RMS = { 0xa6b31ae5, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Harmonic RMS +// Version: 1.5 +const GUID ID_QC_HRMS = { 0xa6b31adc, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Frequency +// Version: 1.5 +const GUID ID_QC_FREQUENCY = { 0x7ef68af, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Total harmonic distortion (%) +// Version: 1.5 +const GUID ID_QC_TOTAL_THD = { 0xa6b31aec, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Even harmonic distortion (%) +// Version: 1.5 +const GUID ID_QC_EVEN_THD = { 0xa6b31ad4, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Odd harmonic distortion (%) +// Version: 1.5 +const GUID ID_QC_ODD_THD = { 0xa6b31ae0, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Crest factor +// Version: 1.5 +const GUID ID_QC_CREST_FACTOR = { 0xa6b31ad2, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Form factor +// Version: 1.5 +const GUID ID_QC_FORM_FACTOR = { 0xa6b31adb, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Arithmetic sum +// Version: 1.5 +const GUID ID_QC_ARITH_SUM = { 0xa6b31ad0, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Zero sequence component unbalance (%) +// Version: 1.5 +const GUID ID_QC_S0S1 = { 0xa6b31ae7, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Negative sequence component unbalance (%) +// Version: 1.5 +const GUID ID_QC_S2S1 = { 0xa6b31ae8, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Positive sequence component +// Version: 1.5 +const GUID ID_QC_SPOS = { 0xa6b31aea, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Negative sequence component +// Version: 1.5 +const GUID ID_QC_SNEG = { 0xd71a4b91, 0x3c92, 0x11d4, { 0x9f, 0x2c, 0x0, 0x20, 0x78, 0xe0, 0xb7, 0x23 } }; + +// Description: Zero sequence component +// Version: 1.5 +const GUID ID_QC_SZERO = { 0xd71a4b92, 0x3c92, 0x11d4, { 0x9f, 0x2c, 0x0, 0x20, 0x78, 0xe0, 0xb7, 0x23 } }; + +// Description: Imbalance by max deviation from average +// Version: 1.5 +const GUID ID_QC_AVG_IMBAL = { 0xa6b31ad1, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Total THD normalized to RMS +// Version: 1.5 +const GUID ID_QC_TOTAL_THD_RMS = { 0xf3d216e0, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Odd THD normalized to RMS +// Version: 1.5 +const GUID ID_QC_ODD_THD_RMS = { 0xf3d216e1, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Even THD normalized to RMS +// Version: 1.5 +const GUID ID_QC_EVEN_THD_RMS = { 0xf3d216e2, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } };; + +// Description: Total Interharmonic Distortion +// Version: 1.5 +const GUID ID_QC_TID = { 0xf3d216e3, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Total Interharmonic Distortion Normalized to RMS +// Version: 1.5 +const GUID ID_QC_TID_RMS = { 0xf3d216e4, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Interharmonic RMS +// Version: 1.5 +const GUID ID_QC_IHRMS = { 0xf3d216e5, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Spectra by Harmonic Group index +// Version: 1.5 +const GUID ID_QC_SPECTRA_HGROUP = { 0x53be6ba8, 0x789, 0x455b, { 0x9a, 0x95, 0xda, 0x12, 0x86, 0x83, 0xdd, 0xa7 } }; + +// Description: Spectra by Interharmonic Group Index +// Version: 1.5 +const GUID ID_QC_SPECTRA_IGROUP = { 0x5e51e006, 0x9c95, 0x4c5e, { 0x87, 0x8f, 0x7c, 0xa8, 0x7c, 0xd, 0x2a, 0xe } }; + +// Description: TIF +// Version: 1.5 +const GUID ID_QC_TIF = { 0xa6b31aeb, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Flicker average RMS value +// Version: 1.5 +const GUID ID_QC_FLKR_MAG_AVG = { 0xa6b31ad6, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: dV/V base +// Version: 1.5 +const GUID ID_QC_FLKR_MAX_DVV = { 0xa6b31ad8, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Frequence of maximum flicker harmonic +// Version: 1.5 +const GUID ID_QC_FLKR_FREQ_MAX = { 0xa6b31ad5, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Magnitude of maximum flicker harmonic +// Version: 1.5 +const GUID ID_QC_FLKR_MAG_MAX = { 0xa6b31ad7, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Spectrum weighted average +// Version: 1.5 +const GUID ID_QC_FLKR_WGT_AVG = { 0xa6b31ada, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Flicker spectrum VRMS(F) +// Version: 1.5 +const GUID ID_QC_FLKR_SPECTRUM = { 0xa6b31ad9, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Short Term Flicker +// Version: 1.5 +const GUID ID_QC_FLKR_PST = { 0x515bf320, 0x71ca, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Long Term Flicker +// Version: 1.5 +const GUID ID_QC_FLKR_PLT = { 0x515bf321, 0x71ca, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: TIF normalized to RMS +// Version: 1.5 +const GUID ID_QC_TIF_RMS = { 0xf3d216e6, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Sliding PLT +// Version: 1.5 +const GUID ID_QC_FLKR_PLTSLIDE = { 0x2257ec05, 0x6ea, 0x4709, { 0xb4, 0x3a, 0xc, 0x0, 0x53, 0x4d, 0x55, 0x4a } }; + +// Version: 1.5 +const GUID ID_QC_FLKR_PILPF = { 0x4d693eec, 0x5d1d, 0x4531, { 0x99, 0x3a, 0x79, 0x3b, 0x53, 0x56, 0xc6, 0x3d } }; + +// Version: 1.5 +const GUID ID_QC_FLKR_PIMAX = { 0x126de61c, 0x6691, 0x4d16, { 0x8f, 0xdf, 0x46, 0x48, 0x2b, 0xca, 0x46, 0x94 } }; + +// Version: 1.5 +const GUID ID_QC_FLKR_PIROOT = { 0xe065b621, 0xffdb, 0x4598, { 0x93, 0x30, 0x4d, 0x9, 0x35, 0x39, 0x88, 0xb6 } };; + +// Version: 1.5 +const GUID ID_QC_FLKR_PIROOTLPF = { 0x7d11f283, 0x1ce7, 0x4e58, { 0x8a, 0xf0, 0x79, 0x4, 0x87, 0x93, 0xb8, 0xa7 } }; + +// Description: IT +// Version: 1.5 +const GUID ID_QC_IT = { 0xa6b31ade, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: RMS value of current for a demand interval +// Version: 1.5 +const GUID ID_QC_RMS_DEMAND = { 0x7ef68a0, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Transformer Derating Factor +// Version: 1.5 +const GUID ID_QC_ANSI_TDF = { 0x8786ca10, 0x9113, 0x11d3, { 0xb9, 0x30, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: Transformer K Factor +// Version: 1.5 +const GUID ID_QC_K_FACTOR = { 0x8786ca11, 0x9113, 0x11d3, { 0xb9, 0x30, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: Total Demand Distortion +// Version: 1.5 +const GUID ID_QC_TDD = { 0xf3d216e7, 0x2aa5, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Peak Demand Current +// Version: 1.5 +const GUID ID_QC_RMS_PEAK_DEMAND = { 0x72e82a44, 0x336c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Real power (watts) +// Version: 1.5 +const GUID ID_QC_P = { 0xa6b31ae1, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Reactive power (VAR) +// Version: 1.5 +const GUID ID_QC_Q = { 0xa6b31ae4, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Apparent power (VA) +// Version: 1.5 +const GUID ID_QC_S = { 0xa6b31ae6, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: True Power Factor - (Vrms * Irms) / P. +// Version: 1.5 +const GUID ID_QC_PF = { 0xa6b31ae3, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Displacement Factor - Cosine of the phase angle between fundamental frequency voltage and current phasors. +// Version: 1.5 +const GUID ID_QC_DF = { 0xa6b31ad3, 0xb451, 0x11d1, { 0xae, 0x17, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Value of active power for a demand interval +// Version: 1.5 +const GUID ID_QC_P_DEMAND = { 0x7ef68a1, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of reactive power for a demand interval +// Version: 1.5 +const GUID ID_QC_Q_DEMAND = { 0x7ef68a2, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of apparent power for a demand interval +// Version: 1.5 +const GUID ID_QC_S_DEMAND = { 0x7ef68a3, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of displacement power factor for a demand interval +// Version: 1.5 +const GUID ID_QC_DF_DEMAND = { 0x7ef68a4, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of true power factor for a demand interval +// Version: 1.5 +const GUID ID_QC_PF_DEMAND = { 0x7ef68a5, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Predicted value of active power for current demand interval +// Version: 1.5 +const GUID ID_QC_P_PRED_DEMAND = { 0x672d0305, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Predicted value of reactive power for current demand interval +// Version: 1.5 +const GUID ID_QC_Q_PRED_DEMAND = { 0x672d0306, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Pedicted value of apparent power for current demand interval +// Version: 1.5 +const GUID ID_QC_S_PRED_DEMAND = { 0x672d0307, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active power coincident with reactive power demand +// Version: 1.5 +const GUID ID_QC_P_CO_Q_DEMAND = { 0x672d030a, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active power coincident with apparent power demand +// Version: 1.5 +const GUID ID_QC_P_CO_S_DEMAND = { 0x672d030b, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reative power coincident with active power demand +// Version: 1.5 +const GUID ID_QC_Q_CO_P_DEMAND = { 0x672d030d, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reactive power coincident with apparent power demand +// Version: 1.5 +const GUID ID_QC_Q_CO_S_DEMAND = { 0x672d030e, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of displacement power factor coincident with apparent power demand +// Version: 1.5 +const GUID ID_QC_DF_CO_S_DEMAND = { 0x7ef68ad, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of true power factor coincident with apparent power demand +// Version: 1.5 +const GUID ID_QC_PF_CO_S_DEMAND = { 0x7ef68ae, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of true power factor coincident with active power demand +// Version: 1.5 +const GUID ID_QC_PF_CO_P_DEMAND = { 0x672d0308, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of true power factor coincident with reactive power demand +// Version: 1.5 +const GUID ID_QC_PF_CO_Q_DEMAND = { 0x672d0309, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of the power angle at fundamental +// Version: 1.5 +const GUID ID_QC_ANGLE_FUND = { 0x672d030f, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of the reactive power at fundamental frequency +// Version: 1.5 +const GUID ID_QC_Q_FUND = { 0x672d0310, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: True Power Factor - IEEE vector calculations +// Version: 1.5 +const GUID ID_QC_PF_VECTOR = { 0x672d0311, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Displacement Factor - IEEE vector calculations +// Version: 1.5 +const GUID ID_QC_DF_VECTOR = { 0x672d0312, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of apparent power - IEEE vector calculations +// Version: 1.5 +const GUID ID_QC_S_VECTOR = { 0x672d0314, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fundamental frequency apparent power - IEEE vector calculations +// Version: 1.5 +const GUID ID_QC_S_VECTOR_FUND = { 0x672d0315, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fundamental frequency apparent power +// Version: 1.5 +const GUID ID_QC_S_FUND = { 0x672d0316, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Apparent power coincident with active power demand +// Version: 1.5 +const GUID ID_QC_S_CO_P_DEMAND = { 0x672d0317, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Apparent power coincident with reactive power demand +// Version: 1.5 +const GUID ID_QC_S_CO_Q_DEMAND = { 0x672d0318, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: True Power Factor - IEEE arithmetic calculations +// Version: 1.5 +const GUID ID_QC_PF_ARITH = { 0x1c39fb00, 0xa6aa, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Displacement Factor - IEEE Arithmetic calculations +// Version: 1.5 +const GUID ID_QC_DF_ARITH = { 0x1c39fb01, 0xa6aa, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of apparent power - IEEE Arithmetic calculations +// Version: 1.5 +const GUID ID_QC_S_ARITH = { 0x1c39fb02, 0xa6aa, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fundamental frequency apparent power - IEEE Arithmetic calculations +// Version: 1.5 +const GUID ID_QC_S_ARITH_FUND = { 0x1c39fb03, 0xa6aa, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Peak Apparent Power Demand +// Version: 1.5 +const GUID ID_QC_S_PEAK_DEMAND = { 0x72e82a43, 0x336c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Peak Reactive Power Demand +// Version: 1.5 +const GUID ID_QC_Q_PEAK_DEMAND = { 0x72e82a42, 0x336c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Peak Active Power Demand +// Version: 1.5 +const GUID ID_QC_P_PEAK_DEMAND = { 0x72e82a41, 0x336c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Net Harmonic Actve Power +// Version: 1.5 +const GUID ID_QC_P_HARMONIC = { 0xb82b5c80, 0x55c7, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Arithmetic sum Harmonic Actve Power +// Version: 1.5 +const GUID ID_QC_P_HARMONIC_UNSIGNED = { 0xb82b5c81, 0x55c7, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fundamental frequency real power +// Version: 1.5 +const GUID ID_QC_P_FUND = { 0x1cdda475, 0x1ebb, 0x42d8, { 0x80, 0x87, 0xd0, 0x1b, 0xb, 0x5c, 0xfa, 0x97 } }; + +// Description: Value of active power integrated over time (Energy - watt-hours) +// Version: 1.5 +const GUID ID_QC_P_INTG = { 0x7ef68a6, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of active power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_P_INTG_POS = { 0x7ef68a7, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of active fund. Freq. power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_P_INTG_POS_FUND = { 0x672d0300, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_P_INTG_NEG = { 0x7ef68a8, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of active fund. Freq. power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_P_INTG_NEG_FUND = { 0x672d0301, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reactive power integrated over time (var-hours) +// Version: 1.5 +const GUID ID_QC_Q_INTG = { 0x7ef68a9, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of reactive power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_Q_INTG_POS = { 0x7ef68aa, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of fund. Freq. reactive power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_Q_INTG_POS_FUND = { 0x672d0303, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fund. Freq. reactive power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_Q_INTG_NEG_FUND = { 0x672d0304, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reactive power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_Q_INTG_NEG = { 0x7ef68ab, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of apparent power integrated over time (VA-hours) +// Version: 1.5 +const GUID ID_QC_S_INTG = { 0x7ef68ac, 0x9ff5, 0x11d2, { 0xb3, 0xb, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: Value of fundamental frequency apparent power integrated over time (VA-hours) +// Version: 1.5 +const GUID ID_QC_S_INTG_FUND = { 0x672d0313, 0x7810, 0x11d4, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active power integrated over time (Energy - watt-hours) +// Version: 1.5 +const GUID ID_QC_P_IVL_INTG = { 0xf098a9a0, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_P_IVL_INTG_POS = { 0xf098a9a1, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active fund. Freq. power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_P_IVL_INTG_POS_FUND = { 0xf098a9a2, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_P_IVL_INTG_NEG = { 0xf098a9a3, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of active fund. Freq. power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_P_IVL_INTG_NEG_FUND = { 0xf098a9a4, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reactive power integrated over time (var-hours) +// Version: 1.5 +const GUID ID_QC_Q_IVL_INTG = { 0xf098a9a5, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reactive power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_Q_IVL_INTG_POS = { 0xf098a9a6, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fund. Freq. reactive power integrated over time (Energy - watt-hours) in the positive direction (toward load). +// Version: 1.5 +const GUID ID_QC_Q_IVL_INTG_POS_FUND = { 0xf098a9a7, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fund. Freq. reactive power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_Q_IVL_INTG_NEG_FUND = { 0xf098a9a8, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of reactive power integrated over time (Energy - watt-hours) in the negative direction (away from load). +// Version: 1.5 +const GUID ID_QC_Q_IVL_INTG_NEG = { 0xf098a9a9, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of apparent power integrated over time (VA-hours) +// Version: 1.5 +const GUID ID_QC_S_IVL_INTG = { 0xf098a9aa, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Value of fundamental frequency apparent power integrated over time (VA-hours) +// Version: 1.5 +const GUID ID_QC_S_IVL_INTG_FUND = { 0xf098a9ab, 0x3ee4, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: D Axis Components +// Version: 1.5 +const GUID ID_QC_DAXISFIELD = { 0xd347ba65, 0xe34c, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: Q Axis Components +// Version: 1.5 +const GUID ID_QC_QAXIS = { 0xd347ba64, 0xe34c, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: Rotational Position +// Version: 1.5 +const GUID ID_QC_ROTATIONAL = { 0xd347ba62, 0xe34c, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: D Axis Components +// Version: 1.5 +const GUID ID_QC_DAXIS = { 0xd347ba63, 0xe34c, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: Linear Position +// Version: 1.5 +const GUID ID_QC_LINEAR = { 0xd347ba61, 0xe34c, 0x11d4, { 0x82, 0xd9, 0x0, 0xe0, 0x98, 0x72, 0xa0, 0x94 } }; + +// Description: Transfer function +// Version: 1.5 +const GUID ID_QC_TRANSFERFUNC = { 0x5202bd07, 0x245c, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// Description: Status Data +// Version: 1.5 +const GUID ID_QC_STATUS = { 0xb82b5c83, 0x55c7, 0x11d5, { 0xa4, 0xb3, 0x44, 0x45, 0x53, 0x54, 0x0, 0x0 } }; + +// ========================================================== +// The following IDs are the legal values for +// tagQuantityMeasuredID +// ========================================================== + +// Description: None or not applicable. +// Version: 1.5 +#define ID_QM_NONE 0 + +// Description: Voltage. +// Version: 1.5 +#define ID_QM_VOLTAGE 1 + +// Description: Current. +// Version: 1.5 +#define ID_QM_CURRENT 2 + +// Description: Power - includes all data for a quantity or characteristic derived from multiplying voltage and current components. +// Version: 1.5 +#define ID_QM_POWER 3 + +// Description: Energy - includes all data from an integration of a quantity or characteristic derived from multiplying voltage and current components together. +// Version: 1.5 +#define ID_QM_ENERGY 4 + +// Description: Temperature. +// Version: 1.5 +#define ID_QM_TEMPERATURE 5 + +// Description: Pressure. +// Version: 1.5 +#define ID_QM_PRESSURE 6 + +// Description: Charge. +// Version: 1.5 +#define ID_QM_CHARGE 7 + +// Description: Electrical field. +// Version: 1.5 +#define ID_QM_EFIELD 8 + +// Description: Magnetic field. +// Version: 1.5 +#define ID_QM_MFIELD 9 + +// Description: Velocity +// Version: 1.5 +#define ID_QM_VELOCITY 10 + +// Description: Compass Bearing +// Version: 1.5 +#define ID_QM_BEARING 11 + +// Description: Applied Force, Electrical, Mechanical, etc. +// Version: 1.5 +#define ID_QM_FORCE 12 + +// Description: Torque +// Version: 1.5 +#define ID_QM_TORQUE 13 + +// Description: Spacial Position +// Version: 1.5 +#define ID_QM_POSITION 14 + +// Description: Flux linkage Weber Turns +// Version: 1.5 +#define ID_QM_FLUXLINKAGE 15 + +// Description: Magnetic field Density +// Version: 1.5 +#define ID_QM_FLUXDENSITY 16 + +// Description: Status Data +// Version: 1.5 +#define ID_QM_STATUS 17 + +// ========================================================== +// The following IDs are the legal values for +// tagChanTriggerTypeID +// ========================================================== + +// Description: No transition - should not happen +// Version: 1.5 +#define ID_CTT_NONE 0 + +// Description: Normal to low transition +// Version: 1.5 +#define ID_CTT_NORMAL_TO_LO 1 + +// Description: Normal to low low transition +// Version: 1.5 +#define ID_CTT_NORMAL_TO_LO_LO 2 + +// Description: Normal to High transition +// Version: 1.5 +#define ID_CTT_NORMAL_TO_HI 3 + +// Description: Normal to High High transition +// Version: 1.5 +#define ID_CTT_NORMAL_TO_HI_HI 4 + +// Description: Low Low to Lo transition +// Version: 1.5 +#define ID_CTT_LO_LO_TO_LO 5 + +// Description: Low Low to Normal transition +// Version: 1.5 +#define ID_CTT_LO_LO_TO_NORMAL 6 + +// Description: Low Low to High transition +// Version: 1.5 +#define ID_CTT_LO_LO_TO_HI 7 + +// Description: Low Low to High High transition +// Version: 1.5 +#define ID_CTT_LO_LO_TO_HI_HI 8 + +// Description: Low to Low Low transition +// Version: 1.5 +#define ID_CTT_LO_TO_LO_LO 9 + +// Description: Low to Normal transition +// Version: 1.5 +#define ID_CTT_LO_TO_NORMAL 10 + +// Description: Low to High transition +// Version: 1.5 +#define ID_CTT_LO_TO_HI 11 + +// Description: Low to High High transition +// Version: 1.5 +#define ID_CTT_LO_TO_HI_HI 12 + +// Description: High to Low Low transition +// Version: 1.5 +#define ID_CTT_HI_TO_LO_LO 13 + +// Description: High to Low transition +// Version: 1.5 +#define ID_CTT_HI_TO_LO 14 + +// Description: High to Normal transition +// Version: 1.5 +#define ID_CTT_HI_TO_NORMAL 15 + +// Description: High to High High transition +// Version: 1.5 +#define ID_CTT_HI_TO_HI_HI 16 + +// Description: High High to Low Low transition +// Version: 1.5 +#define ID_CTT_HI_HI_TO_LO_LO 17 + +// Description: High High to Low transition +// Version: 1.5 +#define ID_CTT_HI_HI_TO_LO 18 + +// Description: High High to Normal transition +// Version: 1.5 +#define ID_CTT_HI_HI_TO_NORMAL 19 + +// Description: High High to High transition +// Version: 1.5 +#define ID_CTT_HI_HI_TO_HI 20 + +// Description: Deadband transition lower +// Version: 1.5 +#define ID_CTT_DB_LO 21 + +// Description: Deadband transition higher +// Version: 1.5 +#define ID_CTT_DB_HI 22 + +// Description: Hardware initiated trigger based on periodic trigger rule +// Version: 1.5 +#define ID_CTT_PERIODIC 23 + +// Description: User commanded sample - button was pushed +// Version: 1.5 +#define ID_CTT_MANUAL 24 + +// Description: Channel triggered because of internal cross-trigger rule. tagCrossTriggerChanIdx is index of channel that triggered. +// Version: 1.5 +#define ID_CTT_INT_CROSS_TRIG 25 + +// Description: Channel triggered because of external cross-trigger rule. tagCrossTriggerChanIdx is index of channel that triggered on external device. tagCrossTriggerDeviceName is the name of the external device that initiated the cross trigger. +// Version: 1.5 +#define ID_CTT_EXT_CROSS_TRIG 26 + +// Description: Channel triggered because of hardware or software module, rule or algorithm +// Version: 1.5 +#define ID_CTT_MODULE 27 + +// Description: Rate of change threshold exceeded (dV/dt or dI/dt) +// Version: 1.5 +#define ID_CTT_RATE 28 + +// ========================================================== +// The following IDs are the legal values for +// tagSettingPhysicalConnection +// ========================================================== + +// Description: Single phase connection, 1 voltage, 1 current +// Version: 1.5 +#define ID_SINGLE_PHASE 1 + +// Description: Delta Connected 2 Element Monitoring +// Version: 1.5 +#define ID_2ELEMENT_DELTA 2 + +// Description: Wye 2 Voltages, 3 Currents +// Version: 1.5 +#define ID_2_5ELEMENT_WYE 3 + +// Description: 3 Voltages, 3 Currents +// Version: 1.5 +#define ID_3ELMENT_WYE 4 + +// Description: Delta Connection, 3 voltages, 3 currents +// Version: 1.5 +#define ID_3ELEMENT_DELTA 5 + +// Description: Split Single Phase, 2 Volage, 2 Current +// Version: 1.5 +#define ID_SPLIT_PHASE 6 + +// Description: 2 Phase, 2 Voltages, 2 Currents +// Version: 1.5 +#define ID_2ELEMENT_2PHASE 7 + + + +#endif // PQDIF_ID_H + + diff --git a/LFtid1056/pqdif/include/pqdif_lg.h b/LFtid1056/pqdif/include/pqdif_lg.h new file mode 100644 index 0000000..9202c2e --- /dev/null +++ b/LFtid1056/pqdif/include/pqdif_lg.h @@ -0,0 +1,1112 @@ +/* +** PQDIF - Power Quality Data Interchange Format +** Version 1.5 +** +** File name: $Workfile: pqdif_lg.h $ +** Last modified: $Modtime: 1/17/02 2:04p $ +** Last modified by: $Author: Jack $ +** +** VCS archive path: $Archive: /PQDIF/Document/Version15/pqdif_lg.h $ +** VCS revision: $Revision: 54 $ +** +** LOGICAL FORMAT DEFINITIONS +** ====================================================================== +** This file contains the complete specifications for the logical +** format of a PQDIF file. It is based on the _physical_ structure of +** the file, which is defined in PQDIF_PH.H +** +** ====================================================================== +** The current version of this file and related information +** can be found at URL: +** +** http://grouper.ieee.org/groups/1159/3/docs.html +** +** ====================================================================== +** +** LOGICAL HIERARCHY OF RECORDS +** ====================================================================== +** The records that make up PQDIF are currently of four different kinds: +** Container, Data Source, Monitor Settings, and Observation. +** +** There are absolute links from one record to another (these are +** different from links within a record, which are relative within the +** record). When these links are followed, the records form a logical +** hierarchy: +** +** +-----------+ +** | Container | +** +-----------+ +** | +** | +---------------+ +** +---| Data Source 1 | +** | +---------------+ +** | | +** | | +--------------------+ +** | +---| Monitor Settings 1 | +** | | +--------------------+ +** | | | +** | | | +---------------+ +** | | +---| Observation 1 | +** | | | +---------------+ +** | | | +---------------+ +** | | +---| Observation 2 | +** | | | +---------------+ +** | | ... +** | | | +---------------+ +** | | +---| Observation n | +** | | +---------------+ +** | | +** | | +--------------------+ +** | +---| Monitor Settings 2 | +** | | +--------------------+ +** | ... +** | | +--------------------+ +** | +---| Monitor Settings n | +** | | +--------------------+ +** | ... +** | +---------------+ +** +---| Data Source 2 | +** | +---------------+ +** ... +** | +---------------+ +** +---| Data Source n | +** | +---------------+ +** ... +** +** The first record in a PQDIF file must be of the Container type. +** This data in this record describes attributes of the items +** contained within the PQDIF file. +** +** The container record is then followed by a Data Source +** record which can be followed by one or more Data Source +** records or Observation records. A Data Source record +** describes the source of the data that is contained in the +** Observation records that follow it. +** +** Note that Monitor Settings records are optional; in their absence, +** Observation records fall directly under the appropriate +** Data Source record. +*/ +#ifndef PQDIF_LG_H +#define PQDIF_LG_H + +#pragma pack( 1 ) +/* +** RECORD HEADER +** ====================================================================== +** The first item in a PQDIF File (and in each record) is a 128 bit +** GUID which serves as a unique signature for both the file as a whole +** and each record. +** +** Every record must have this GUID. +*/ +//PQDIF_DEFINE_GUID(guidRecordSignaturePQDIF, 0x4a111440, 0xe49f, 0x11cf, 0x99, 0x00, 0x50, 0x51, 0x44, 0x49, 0x46, 0x00); +const GUID guidRecordSignaturePQDIF = { /* 4a111440-e49f-11cf-9900-505144494600 */ + 0x4a111440, + 0xe49f, + 0x11cf, + {0x99, 0x00, 0x50, 0x51, 0x44, 0x49, 0x46, 0x00} + }; + + +/* +** TAG FOR ANY RECORD +** ====================================================================== +** The following tag can be used to leave space in a collection. To leave +** a collection item blank, specify it as a scalar of less than 8 bytes +** (such as a UINT4), and specify it as embedded. +*/ +const GUID tagBlank = // + { 0x89738618, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + // {89738618-F1C3-11cf-9D89-0080C72E70A3} + + +// ====================================================================== +// Do not modify anything after the following comment: +// {{{{ AUTO-GENERATED CONSTANTS }}}} + +// Description: Record-level tag which identifies the container record (always the first one in the file, and there must be only one per file). +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagContainer = { 0x89738606, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Record-level tag which identifies a data source (an instrument, etc.). +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagRecDataSource = { 0x89738619, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Record-level tag which identifies a set of configuration parameters. +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Optional +// Version: 1.0 +const GUID tagRecMonitorSettings = { 0xb48d858c, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Record-level tag which identifies an observation -- an event, measurement, etc. +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagRecObservation = { 0x8973861a, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Specifies the format version for read/write compatibility. The four required numbers in the vector are described below. +// Element type: Vector [ 4 ] +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.0 +const GUID tagVersionInfo = { 0x89738607, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Original name of the file. +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Required +// Version: 1.0 +const GUID tagFileName = { 0x89738608, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Date/time when the file was created. +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Required +// Version: 1.0 +const GUID tagCreation = { 0x89738609, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Date/time when the file was last saved. +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Optional +// Version: 1.0 +const GUID tagLastSaved = { 0x8973860a, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The number of times the file has been saved/modified. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTimesSaved = { 0x8973860b, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The language (English, etc.) of the file. +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagLanguage = { 0x8973860c, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary title. +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTitle = { 0x8973860d, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary subject string +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagSubject = { 0x8973860e, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Individual/company who caused the file to be written +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagAuthor = { 0x8973860f, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Keywords for assisting searches +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagKeywords = { 0x89738610, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary comments +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagComments = { 0x89738611, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Individual/company who last wrote to file +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagLastSavedBy = { 0x89738612, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Creating application +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagApplication = { 0x89738623, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Security descriptor information +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagSecurity = { 0x89738613, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Owner of file contents (This and some of the following fields are for copyright and trademark information) +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagOwner = { 0x89738614, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Copyright notice +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCopyright = { 0x89738615, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Trademark notice +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTrademarks = { 0x89738616, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: RTF formatted notes associated with this file (This corresponds to the IEEE COMTRADE .HDR file, for example). +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagNotes = { 0x89738617, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Specified how the compression is applied to the file. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCompressionStyleID = { 0x8973861b, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Required if tagCompressionStyleID specifies that compression is turned on. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCompressionAlgorithmID = { 0x8973861c, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: If compression style is _TOTALFILE, this is the checksum for the entire file. This feature has been deprecated under 1.5. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 Deprecated +const GUID tagCompressionChecksum = { 0x8973861d, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagName = { 0xb48d85a2, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagAddress1 = { 0xb48d85a3, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagAddress2 = { 0xb48d85a4, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCity = { 0xb48d85a5, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagState = { 0xb48d85a6, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagPostalCode = { 0xb48d85a7, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCountry = { 0xb48d85a8, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagPhoneVoice = { 0xb48d85a9, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagPhoneFAX = { 0x3d786f80, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: General contact information (all optional) +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagEMail = { 0x3d786f81, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Since this ID is a GUID, you can generate a custom ID if a standard ID is not defined. +// Element type: Scalar +// Physical type: GUID +// Required/opt: Required +// Version: 1.0 +const GUID tagDataSourceTypeID = { 0xb48d8581, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Since this ID is a GUID, you can generate a custom ID if a standard ID is not defined. +// Element type: Scalar +// Physical type: GUID +// Required/opt: Optional +// Version: 1.0 +const GUID tagVendorID = { 0xb48d8582, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Since this ID is a GUID, you can generate a custom ID if a standard ID is not defined. +// Element type: Scalar +// Physical type: GUID +// Required/opt: Optional +// Version: 1.0 +const GUID tagEquipmentID = { 0xb48d8583, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: This collection can include the standard name, address & telephone number tags -- these apply to the vendor -- as well as tags about the instrument itself. +// Element type: Collection +// Physical type: (n/a) +// Required/opt: Optional +// Version: 1.0 +const GUID tagCustomSourceInfo = { 0xb48d8584, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string to hold data souce (instrument) serial number +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagSerialNumberDS = { 0xb48d8585, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string to hold data souce (instrument) version number (if applicable) +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagVersionDS = { 0xb48d8586, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string to hold the name of the data souce (instrument) +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Required +// Version: 1.0 +const GUID tagNameDS = { 0xb48d8587, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string to hold data souce (instrument) owner name +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagOwnerDS = { 0xb48d8588, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string to hold data souce (instrument) location information +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagLocationDS = { 0xb48d8589, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: EST, CST, etc. +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTimeZoneDS = { 0xb48d858a, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Longitude/latitude +// Element type: Vector [ 2 ] +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCoordinatesDS = { 0xb48d858b, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The tagChannelDefns collection must be a collection where the count = the number of channel definitions. Each entry must be another collection, each having the tagOneChannelDefn tag. +// Element type: Collection [ # defs ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagChannelDefns = { 0xb48d858d, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Element type: Scalar +// Physical type: GUID +// Required/opt: Optional +// Version: 1.0 +const GUID tagInstrumentTypeID = { 0x3d786f82, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagInstrumentModelName = { 0x3d786f83, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagInstrumentModelNumber = { 0x3d786f84, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Must have one or more channel definitions +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagOneChannelDefn = { 0xb48d858e, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagChannelName = { 0xb48d8590, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Phase identifier +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.0 +const GUID tagPhaseID = { 0xb48d8591, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagOtherChannelIdentifier = { 0xb48d8593, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: This tag can be repeated if there are multiple groupings. The first one should be the highest-level group (example: a bus), and the next one should be a lower group (example: a feeder). +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagGroupName = { 0xb48d8594, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The high-level description of the type of quantity which is being captured by this channel. In order to guarantee reader compatibility, the following series value types (in order) should be used (ID_SERIES_VALUE_TYPE_VAL, etc.). +// Element type: Scalar +// Physical type: GUID +// Required/opt: Required +// Version: 1.0 +const GUID tagQuantityTypeID = { 0xb48d8592, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Identifies the physical quantity under measurement -- Voltage, Current, Power, etc. In general, there is a one-to-one correspondence between this and the units of the series, but not always. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.5 +const GUID tagQuantityMeasuredID = { 0xc690e872, 0xf755, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The instrument physical channel that this channel definition is associated with. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagPhysicalChannel = { 0x89738622, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Additional quantity information. +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagQuantityName = { 0xb48d8595, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Identifies the series which will be the primary. Index into the tagSeriesDefns collection. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagPrimarySeriesIdx = { 0xb48d8596, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The tagSeriesDefns collection must be a collection where the count = the number of series definitions. Each entry must be another collection, each having the tagOneSeriesDefn tag. +// Element type: Collection [ # sers ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagSeriesDefns = { 0xb48d8598, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: One of these collections per series. +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagOneSeriesDefn = { 0xb48d859a, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: This specifies the meaning of the series data. +// Element type: Scalar +// Physical type: GUID +// Required/opt: Required +// Version: 1.0 +const GUID tagValueTypeID = { 0xb48d859c, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: This specifies the units of the data in this series. The expected physical type for the tagSeriesValues vector is REAL4 or REAL8 (except as noted). +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.0 +const GUID tagQuantityUnitsID = { 0xb48d859b, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: This specifies additional detail about the meaning of the series data. +// Element type: Scalar +// Physical type: GUID +// Required/opt: Required +// Version: 1.5 +const GUID tagQuantityCharacteristicID = { 0x3d786f9e, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Defines the number of significant digits in the data represented by this series. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagQuantitySignificantDigitsID = { 0xa112f421, 0xb111, 0x11d2, { 0x9b, 0x37, 0x0, 0x40, 0x5, 0x2c, 0x2d, 0x28 } }; + +// Description: Contains a double indicating the scaled distance between two values of the quantity represented by this series (e.g. scaled A/D resolution) +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagQuantityResolutionID = { 0xfb228ee0, 0xfc8d, 0x11d2, { 0xb4, 0x9a, 0x0, 0x60, 0x8, 0xb3, 0x71, 0x83 } }; + +// Description: The legal values for this entry are masks, since they are OR-able. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.0 +const GUID tagStorageMethodID = { 0xb48d85a1, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Arbitrary string +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.0 +const GUID tagValueTypeName = { 0xb48d859d, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagHintGreekPrefixID = { 0xb48d859e, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagHintPreferredUnitsID = { 0xb48d859f, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagHintDefaultDisplayID = { 0xb48d85a0, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: For a probability series definition, this specifies its time interval (in seconds; >0). +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagProbInterval = { 0x2747d441, 0x2bd0, 0x11d2, { 0xae, 0x42, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: For a probability series definition, this specifies its probability percentile (in percent; 0-100). +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagProbPercentile = { 0x2747d440, 0x2bd0, 0x11d2, { 0xae, 0x42, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Contains the default nominal base voltage or any or any other necessary normalizing quantity. Display programs may use this value or the tagSeriesBaseQuantity in the series instance for displaying data in percent or per unit. +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagSeriesNominalQuantity = { 0xfa118c8, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: The time that these settings become effective. +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Required +// Version: 1.0 +const GUID tagEffective = { 0x62f28183, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Required +// Version: 1.0 +const GUID tagTimeInstalled = { 0x3d786f85, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Optional +// Version: 1.0 +const GUID tagTimeRemoved = { 0x3d786f86, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: If TRUE, the calibration adjustments *must* be applied to the series data before using. Otherwise the data is for informative use only. +// Element type: Scalar +// Physical type: BOOL4 +// Required/opt: Required +// Version: 1.0 +const GUID tagUseCalibration = { 0x62f28180, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: If TRUE, the transducer adjustments *must* be applied to the series data before using. Otherwise the data is for informative use only. +// Element type: Scalar +// Physical type: BOOL4 +// Required/opt: Required +// Version: 1.0 +const GUID tagUseTransducer = { 0x62f28181, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Channel specific monitor settings stuff +// Element type: Collection [ # chan ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagChannelSettingsArray = { 0x62f28182, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Nominal power system frequency for this instrument in Hertz +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagNominalFrequency = { 0xfa118c3, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: Identifies the physical connection of the instrumentation or insturment transducers. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagSettingPhysicalConnection = { 0x9f256ee0, 0x803b, 0x11d3, { 0xb9, 0x2f, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: One of these collections per channel. +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagOneChannelSetting = { 0x3d786f9a, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The channel definition which these settings apply to. Index into tagChannelDefns collection of the matching data source record. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.0 +const GUID tagChannelDefnIdx = { 0xb48d858f, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Integer ID representing which trigger fields are used. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTriggerTypeID = { 0x62f28184, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Full scale range for this instrument channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagFullScale = { 0x3d786f87, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Noise floor for this instrument channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagNoiseFloor = { 0x3d786f89, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Parameters for shape based triggering algorithms for this channel +// Element type: Vector [ 3 ] +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTriggerShapeParam = { 0x62f28188, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: PT or CT +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagXDTransformerTypeID = { 0x62f28189, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: System side part of ratio +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagXDSystemSideRatio = { 0x62f2818a, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Monitor side part of ratio +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagXDMonitorSideRatio = { 0x62f2818b, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Transducer frequency response +// Element type: Vector [ # freq ] +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagXDFrequencyResponse = { 0x62f2818c, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Chanel time skew +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCalTimeSkew = { 0x62f2818d, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Channel DC offset error +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCalOffset = { 0x62f2818e, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Channel ratio error +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCalRatio = { 0x62f2818f, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Flag indicating that the applied/recordedt calibration arrays must be used to correct data. +// Element type: Scalar +// Physical type: BOOL4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCalMustUseARCal = { 0x62f28190, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Array of applied signals for this channel +// Element type: Vector [ # cal ] +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCalApplied = { 0x62f28191, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Array of recorded actual values for the applied signal +// Element type: Vector [ # cal ] +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagCalRecorded = { 0x62f28192, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: High High trigger for this channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagTriggerHighHigh = { 0x5b12f431, 0xff54, 0x11d3, { 0xb9, 0x68, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: High trigger for this channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTriggerHigh = { 0x62f28186, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Low trigger for this channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTriggerLow = { 0x62f28185, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Low Low trigger for this channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagTriggerLowLow = { 0x5b12f430, 0xff54, 0x11d3, { 0xb9, 0x68, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: Deadband trigger for this channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagTriggerDeadBand = { 0x5b12f432, 0xff54, 0x11d3, { 0xb9, 0x68, 0x0, 0x50, 0xda, 0x2b, 0x1f, 0x4d } }; + +// Description: Rate of change trigger for this channel +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagTriggerRate = { 0x62f28187, 0xf9c4, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Name of the observation +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Required +// Version: 1.0 +const GUID tagObservationName = { 0x3d786f8a, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Time this observation was created +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Required +// Version: 1.0 +const GUID tagTimeCreate = { 0x3d786f8b, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The start time of the observation -- the zero point where the . +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Required +// Version: 1.0 +const GUID tagTimeStart = { 0x3d786f8c, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Type of trigger which caused the observation. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Required +// Version: 1.0 +const GUID tagTriggerMethodID = { 0x3d786f8d, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Tme this observation was triggered if appropriate +// Element type: Scalar +// Physical type: TIMESTAMP +// Required/opt: Optional +// Version: 1.0 +const GUID tagTimeTriggered = { 0x3d786f8e, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Index into tagChannelInstances collection within this record. This specifies which channel(s) initiated the observation. +// Element type: Vector +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagChannelTriggerIdx = { 0x3d786f8f, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: The serial number of the observation (if generated by an instrument, for example). +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagObservationSerial = { 0x3d786f90, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Serial number -- of specific cycle, for example -- that can be used to correlate observations. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagObservationAggregationSerial = { 0x89738621, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Currently uses the IEEE 1159 disturbance categories, but others could be used as well. +// Element type: Scalar +// Physical type: GUID +// Required/opt: Optional +// Version: 1.0 +const GUID tagDisturbanceCategoryID = { 0xb48d8597, 0xf5f5, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: This collection contains a set of channel instances. It is not required to contain the same number of channels as there are channel instances. This can be determined on an observation-by-observation basis. +// Element type: Collection [ # chan ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagChannelInstances = { 0x3d786f91, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Direction of disturbance represented by the data in this observation. Value of 0 means don't know, 1 means originated from load side, 2 means originated from source side. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCharactDisturbDirection = { 0xfa118c0, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: Quality of the direction result given in another tag. Range is from 0 (no confidence), to 100 (darn sure). +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCharactDisturbDirectionQuality = { 0xfa118c1, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: One of these collections per channel instance. +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagOneChannelInst = { 0x3d786f92, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Simple characterization value: duration of disturbance (seconds) +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCharactDuration = { 0x2747d444, 0x2bd0, 0x11d2, { 0xae, 0x42, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: This collection must contain the exact number of series which were defined for the specified channel definition. +// Element type: Collection [ # sers ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagSeriesInstances = { 0x3d786f93, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Simple characterization value: magnitude of disturbance (percent: 100%=nominal) +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCharactMagnitude = { 0x2747d443, 0x2bd0, 0x11d2, { 0xae, 0x42, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Simple characterization value: frequency (Hertz) +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCharactFrequency = { 0x2747d445, 0x2bd0, 0x11d2, { 0xae, 0x42, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: Contains a 32 bit integer that represents module spefic information related to the trigger reason. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagChanTriggerModuleInfo = { 0xfa118c7, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: Contains the name of a device specific code or hardware module, algorithm or rule not necessarily channel based that caused this channel to be recorded +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.5 +const GUID tagChanTriggerModuleName = { 0xfa118c6, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: Contains the name of the device involved in an external cross trigger scenario. +// Element type: Vector [ * ] +// Physical type: CHAR1 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCrossTriggerDeviceName = { 0xfa118c5, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: Contains the channel definition index of the channel that triggered in a cross trigger scenrio. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagCrossTriggerChanIdx = { 0xfa118c4, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: Integer ID representing the trigger type for this channel instance. Used only with type ID_QT_VALUELOG wit a trigger method of channel. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.5 +const GUID tagChanTriggerTypeID = { 0xfa118c2, 0xcb4a, 0x11d2, { 0xb3, 0xb, 0xfe, 0x25, 0xcb, 0x9a, 0x17, 0x60 } }; + +// Description: For a channel which contains multiple instances to represent a sparse log of time-stamped frequency-domain information, this specifies the frequency for which this channel instance applies (in Hertz). If not present, the channel characteristics are frequency independent unless further specified by the quantity characteristic. +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.5 +const GUID tagChannelFrequency = { 0x2747d442, 0x2bd0, 0x11d2, { 0xae, 0x42, 0x0, 0x60, 0x8, 0x3a, 0x26, 0x28 } }; + +// Description: For a channel which contains multiple instances to represent a sparse log of time-stamped frequency-domain information, this specifies the frequency for which this channel instance applies (in Index). The index referes to a harmonic or interharmonic group index. +// Element type: Scalar +// Physical type: INT2 +// Required/opt: Optional +// Version: 1.5 +const GUID tagChannelGroupID = { 0xf90de218, 0xe67b, 0x4cf1, { 0xa2, 0x95, 0xb0, 0x21, 0xa2, 0xd4, 0x67, 0x67 } }; + +// Description: One of these collections per series instance. +// Element type: Collection [ * ] +// Physical type: (n/a) +// Required/opt: Required +// Version: 1.0 +const GUID tagOneSeriesInstance = { 0x3d786f94, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Contains the nominal base voltage, or any other necessary normalizing quantity. +// Element type: Scalar +// Physical type: REAL8 +// Required/opt: Optional +// Version: 1.0 +const GUID tagSeriesBaseQuantity = { 0x3d786f95, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: If not present, assumed to be 1. The physical type should match that of tagSeriesValues. +// Element type: Scalar +// Physical type: (any type) +// Required/opt: Optional +// Version: 1.0 +const GUID tagSeriesScale = { 0x3d786f96, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: If not present, assumed to be 0. Generally used as a starting point when the ID_SERIES_METHOD_INCREMENT storage method is used. The physical type should match that of tagSeriesValues. +// Element type: Scalar +// Physical type: (any type) +// Required/opt: Optional +// Version: 1.0 +const GUID tagSeriesOffset = { 0x3d786f97, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Identifies the channel which owns the series to be shared. An index into the tagChannelInstances collection. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagSeriesShareChannelIdx = { 0x8973861f, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Identifies the series to be shared. An index into the tagSeriesInstances collection. The tagSeriesValues vector from this series is used. This must be present if tagSeriesShareChannelIdx is used. +// Element type: Scalar +// Physical type: UINT4 +// Required/opt: Optional +// Version: 1.0 +const GUID tagSeriesShareSeriesIdx = { 0x89738620, 0xf1c3, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Contains the actual data points of the series. Required unless the data series is shared, in which case both tagSeriesShareChannelIdx and tagSeriesShareSeriesIdx should be present. +// Element type: Vector [ * ] +// Physical type: (any type) +// Required/opt: Required +// Version: 1.0 +const GUID tagSeriesValues = { 0x3d786f99, 0xf76e, 0x11cf, { 0x9d, 0x89, 0x0, 0x80, 0xc7, 0x2e, 0x70, 0xa3 } }; + +// Description: Contains the actual data points of the series. Required unless the data series is shared, in which case both tagSeriesShareChannelIdx and tagSeriesShareSeriesIdx should be present. +// Element type: Vector [ * ] +// Physical type: (any type) +// Required/opt: Required +// Version: 1.0 +const GUID tagApplicationVersion = {0xBE10AE20,0xEC16,0x441F,{0xA7,0x6D,0x2E,0x6A,0x2F,0x15,0xDB,0x46}}; + +// Description: for anhui ww 2008-07-18 modify +// Element type: Vector [ * ] +// Physical type: char +// Required/opt: opt +// Version: 1.0 +const GUID tagSystemName = { 0xB6CADED6, 0xF8EF, 0x4599, { 0x9F, 0xD2, 0xF0, 0x26, 0x93, 0xF3, 0xA8, 0x71} }; + +// Description: for anhui ww 2008-07-18 modify +// Element type: Vector [ * ] +// Physical type: char +// Required/opt: opt +// Version: 1.0 +const GUID tagSystemVersion = { 0xF1310602, 0xE941, 0x4586,{ 0xA6, 0x2A, 0x29, 0xFE, 0xCB, 0x9B, 0x00, 0x27} }; + +// Description: for anhui ww 2008-07-18 modify +// Element type: Vector [ * ] +// Physical type: UINT4 +// Required/opt: opt +// Version: 1.0 +const GUID tagNominalVoltage = { 0x88892480, 0x7440, 0x4B86,{ 0xBD, 0x7B, 0xE3, 0xFC, 0x7A, 0xCC, 0x00, 0x65} }; + +// Description: for anhui ww 2008-07-18 modify +// Element type: Vector [ * ] +// Physical type: BOOL4 +// Required/opt: opt +// Version: 1.0 +const GUID tagIsPCC = { 0x80337EB3, 0xE5F1, 0x4131,{ 0xAC, 0x96, 0xAC, 0x4E, 0x5A, 0x9D, 0x16, 0x60}}; + +#pragma pack( ) +#endif // PQDIF_LG_H + + diff --git a/LFtid1056/pqdif/include/pqdif_ph.h b/LFtid1056/pqdif/include/pqdif_ph.h new file mode 100644 index 0000000..21553ba --- /dev/null +++ b/LFtid1056/pqdif/include/pqdif_ph.h @@ -0,0 +1,466 @@ +/* +** PQDIF - Power Quality Data Interchange Format +** Version 1.5 +** +** File name: $Workfile: pqdif_ph.h $ +** Last modified: $Modtime: 1/07/02 3:59p $ +** Last modified by: $Author: Erich $ +** +** VCS archive path: $Archive: /PQDIF/Document/IEEE/pqdif_ph.h $ +** VCS revision: $Revision: 22 $ +** +** PHYSICAL FORMAT DEFINITIONS +** ====================================================================== +** This file contains the complete definitions for the physical +** format of a PQDIF file. It contains no information about the +** _logical_ structure, which is defined in PQDIF_LG.H +** +** ====================================================================== +** The current version of this file and related information +** can be found at URL: +** +** http://grouper.ieee.org/groups/1159/3/docs.html +** +** ====================================================================== +*/ +#ifndef PQDIF_PH_H +#define PQDIF_PH_H + + +// The structures must be 1-byte packed. +//#ifdef __BORLANDC__ +// #pragma pack( 1 ) +//#elif _MSC_VER +// #pragma pack( push, 1 ) +//#else +// #pragma pack( 1 ) +//#endif +#pragma pack( 1 ) + +/* +** PHYSICAL TYPE IDs AND DEFINITIONS +** ====================================================================== +** The physical types are intended to be fully portable. +** ====================================================================== +*/ + +/* +** Physical representation IDs +** +** NOTE: Larger objects such as strings and BLOBs (Binary Large OBject) +** are represented as vectors of other primitive types. +** +** Examples +** -------- +** ASCII string Vector of ID_PHYS_TYPE_CHAR1, NULL-terminated +** (i.e., the last character must be a NULL, to +** correspond to a C-style string). +** +** Unicode string Vector of ID_PHYS_TYPE_CHAR2. +** +** BLOB vector of ID_PHYS_TYPE_INTEGER1 or +** ID_PHYS_TYPE_UNS_INTEGER1. +*/ +#define ID_PHYS_TYPE_BOOLEAN1 1 +#define ID_PHYS_TYPE_BOOLEAN2 2 +#define ID_PHYS_TYPE_BOOLEAN4 3 + +#define ID_PHYS_TYPE_CHAR1 10 // ASCII +#define ID_PHYS_TYPE_CHAR2 11 // Unicode + +// Signed integers +#define ID_PHYS_TYPE_INTEGER1 20 +#define ID_PHYS_TYPE_INTEGER2 21 +#define ID_PHYS_TYPE_INTEGER4 22 + +// Unsigned integers +#define ID_PHYS_TYPE_UNS_INTEGER1 30 +#define ID_PHYS_TYPE_UNS_INTEGER2 31 +#define ID_PHYS_TYPE_UNS_INTEGER4 32 + +// Real/complex +#define ID_PHYS_TYPE_REAL4 40 +#define ID_PHYS_TYPE_REAL8 41 +#define ID_PHYS_TYPE_COMPLEX8 42 // Two REAL4s: real, imag +#define ID_PHYS_TYPE_COMPLEX16 43 // Two REAL8s: real, imag + +// Date/time variations +#define ID_PHYS_TYPE_TIMESTAMPPQDIF 50 // Physical: TIMESTAMPPQDIF (total 12 bytes) + +// GUID +#define ID_PHYS_TYPE_GUID 60 // Physical: GUID (total 16 bytes) + +//WW 20240520 start +typedef unsigned int DWORD; +typedef int BOOL; +typedef unsigned char BYTE; +typedef unsigned short WORD; +typedef float FLOAT; +typedef FLOAT *PFLOAT; + +typedef int INT; +typedef unsigned int UINT; +typedef unsigned int *PUINT; + +/** FALSE */ +#ifndef FALSE +#define FALSE 0 +#endif +/** TRUE */ +#ifndef TRUE +#define TRUE (!FALSE) +#endif + + +#if (!defined(_T)) && (!defined(__T)) +#ifdef STDTIME_UNICODE +#define __T(x) L##x +#define _T(x) __T(x) +#else +#define __T(x) x +#define _T(x) x +#endif +#endif /* not defined _T and __T */ + +#ifdef _UNICODE +#define TCHAR wchar_t +#else +#define TCHAR char +#endif + +#ifndef strcmpi +#define strcmpi strcasecmp +#endif +//WW 20240520 end + +/* +** Portable primitive type definitions +*/ +typedef char BOOL1; +typedef short BOOL2; +typedef int BOOL4; + +typedef char CHAR1; // ASCII string character +typedef short CHAR2; // Unicode string character + +typedef char INT1; +typedef short INT2; +typedef int INT4; + +typedef unsigned char UINT1; +typedef unsigned short UINT2; +typedef unsigned int UINT4; + +typedef float REAL4; +typedef double REAL8; + +typedef struct _complex8 + { + REAL4 real; + REAL4 image; + } COMPLEX8; + +typedef struct _complex16 + { + REAL8 real; + REAL8 image; + } COMPLEX16; + +/* +** Types used in structures (but not used as primitives for elements) +*/ +typedef int LINKABS4; +typedef int LINKREL4; +typedef int SIZE4; + + +/* +** Portable physical time structure definition +** +** (Modified version of time tracking used by Excel +** Excel counts days since 1900, converts to a double +** and adds to this a number less than 1.0 that +** is the fractional day. This structure enhances +** accuracy of this method by separating out the +** days since 1900 and seconds since midnight.) +*/ +typedef struct ts + { + UINT4 day; // days since January 1, 1900 UCT + // 0xFFFFFFFF -> 4294967295 days -> a long time + REAL8 sec; // fractional seconds since midnight of day + } TIMESTAMPPQDIF; + + +/* +** GUID (Globally Unique IDentifier) definition +** (Used for tagging sections to identify them logically) +** +** The Unique Universal Identifier (UUID) is also known +** as a Globally Unique Identifier (GUID). It is +** a randomly generated number that due to its size, +** is guaranteed to be unique in the universe. This +** guarantees that the tags will be unique and anyone +** can generate "private" tags which will never conflict +** with the standard tags. +** +** GUID tags are used to mark the header of each record, +** as well as identify the elements in the internal structures. +*/ +#ifndef GUID_DEFINED +#define GUID_DEFINED +typedef struct _GUID + { + unsigned int Data1;//WW 20240522 64λ long8ֽ + unsigned short Data2; + unsigned short Data3; + unsigned char Data4[8]; + } GUID; + +#endif /* GUID_DEFINED */ + + +/* +** PHYSICAL TYPE HELPER INFORMATION +** ====================================================================== +** Time structure helpers +** +** The following constant is the number of days between +** 1/1/1900 and 1/1/1970. This is used to convert between +** "C Time" and Excel style day counts +** "C Time" is a 4 byte integer representing the number of +** seconds elapsed since January 1, 1970. +** Excel time is an 8 byte real number that represents +** the number of days elapsed since 1/1/1900. The fractional +** part is therefore convertable to seconds since midnight. +*/ +#define EXCEL_DAYCOUNT_ADJUST 25569L +#define SECONDS_PER_DAY 86400L + + +/* +** Define GUID helpers +*/ +#define PQDIF_IsEqualGUID(rguid1, rguid2) (!memcmp(&rguid1, &rguid2, sizeof(GUID))) +#define PQDIF_DEFINE_GUID(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \ + const GUID name = { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } } + +#define PQDIFGUID_IsEqual(rguid1, rguid2) ( rguid1.Data1==rguid2.Data1 && rguid1.Data2==rguid2.Data2 && rguid1.Data3==rguid2.Data3 \ + && rguid1.Data4[0]==rguid2.Data4[0] && rguid1.Data4[1]==rguid2.Data4[1] \ + && rguid1.Data4[2]==rguid2.Data4[2] && rguid1.Data4[3]==rguid2.Data4[3] \ + && rguid1.Data4[4]==rguid2.Data4[4] && rguid1.Data4[5]==rguid2.Data4[5] \ + && rguid1.Data4[6]==rguid2.Data4[6] && rguid1.Data4[7]==rguid2.Data4[7] ) + +/* +** HIGH-LEVEL FILE STRUCTURE +** ====================================================================== +** The top-level structure is a series of independent records with +** header and body sections. +** +** ====================================================================== +** Fundamental premise for file format writing: File must be capable of +** being written to incrementally. For this reason, the basic structure +** is a series of independent records. Additional records can be appended +** to the file at any time. +** +** ====================================================================== +** The top-level structure is a series of independent records with +** header and body sections: +** +** +--------------------------------+ +** | Record 0 Header | +** /---+--------------------------------+ +** | | Record 0 Body | +** | +--------------------------------+ +** \-->+--------------------------------+ +** | Record 1 Header | +** /---+--------------------------------+ +** | | Record 1 Body | +** | +--------------------------------+ +** ... ... +** \-->+--------------------------------+ +** | Record n Header | +** +--------------------------------+ +** | Record n Body | +** +--------------------------------+ +** +** ====================================================================== +** Note that each record header has a LINKABS4 -- an absolute offset in +** the file -- to the next record. This allows new records to be inserted +** in the middle of the file, and obsolete records to be deleted. +** +** ====================================================================== +** All references which are defined by the type LINKREL4 are offsets +** within the record body itself -- they are not absolute offsets to the +** entire file. Thus, each record body is independent of the others. Only +** the record header need be modified if a record is moved, deleted, or +** inserted. +** +** ====================================================================== +*/ + + +/* +** Record header +** +** The header contains a GUID signature (for testing corruptness), +** header size, the size of the record that follows, record tag, and +** fill bytes to make the header 64 bytes in length +*/ +struct c_record_mainheader + { + GUID guidRecordSignature; // Signature to verify a valid header + + GUID tagRecordType; // Tag to identify the record type + // (This also identifies the first + // collection in the record.) + + SIZE4 sizeHeader; // Size of this header in bytes + + SIZE4 sizeData; // Size of the body in bytes (record data + // that follows header) + + LINKABS4 linkNextRecord; // Offset to the next record -- absolute + // reference within the file. If 0, this + // is the last record in the file. + + UINT4 checksum; // Optional checksum (such as a 32-bit CRC) + // of the record body to verify decompression. + + UINT4 auiReserved[ 4 ]; // Reserved to fill structure to 64 bytes + // -- should be filled with 0 + }; + + + +/* +** RECORD BODY STRUCTURE +** ====================================================================== +** The record body always begins with a Collection element. This is +** defined below in the record structure. +** +** ====================================================================== +** The fundamental premise for the standard structures is to +** assure 4 byte alignment. All of the structures conform to this +** premise. In addition, the data values associated with scalars and +** vectors must be padded out to 4-byte multiples. This _total_ size +** will be specified in the c_collection_element structure (sizeElement). +** +** ====================================================================== +** The three main elements are: +** +** 1. Collection Holds an array of pointers to other elements +** (it could contain another collection) +** 2. Scalar Holds a single data value (of a physical type) +** 3. Vector Holds an array of data values (of a physical type) +** ====================================================================== +*/ + +#define ID_ELEMENT_TYPE_COLLECTION 1 +#define ID_ELEMENT_TYPE_SCALAR 2 +#define ID_ELEMENT_TYPE_VECTOR 3 + + +/* +** The collection element +** +** ... is made by combining a c_collection with an array of +** c_collection_element, which provide pointers to the +** other elements in the collection. +*/ +struct c_collection + { + SIZE4 count; // The number of elements in this + // collection. + +// c_collection_element ceElements[]; // Array [count] of the elements + // in the collection. + }; + +struct c_collection_element + { + GUID tagElement; // Identifier for this element in the collection. + + // (4) 1-byte members keep the structure 4-byte aligned. + INT1 typeElement; // Type of element (ID_ELEMENT_TYPE_COLLECTION, + // _SCALAR or _VECTOR). + + INT1 typePhysical; // Physical type of the value which follows + // (ID_PHYS_TYPE_INTEGER1, etc.). This is unused + // if the element is a collection and should be + // set to 0. + + BOOL1 isEmbedded; // FALSE (0) - use the link to find the next element + // TRUE (1) - the scalar data value is embedded + // (may not be used with vectors) + + INT1 reserved; // Fill with 0 + + // The following 8 bytes can point to another location in the record + // or it can hold the actual data value (if it fits in 8 bytes). + // This allows small scalars to be stored with much less space overhead. + union + { + // isEmbedded What to use + // ---------- ------------------------------------------------- + // FALSE Use link to find the next element (and its size). + // TRUE Use valueEmbedded to find the data directly. + struct + { + LINKREL4 linkElement; // Offset to the element -- this offset + // is relative within the record body. + + SIZE4 sizeElement; // Specifies actual size of the element + // -- should be padded to even + // multiples of 4 bytes + } link; + + UINT1 valueEmbedded[ 8 ]; // The scalar data value + // (less than or equal to 8 bytes) + }; + }; + + +/* +** The scalar element +** +** This structure has no members, but is included +** for completeness. +** +** struct c_scalar +** { +** // (type) value; // A single value follows of variable length, +** // depending on the physical type. +** }; +*/ + +/* +** The vector element +*/ +struct c_vector + { + SIZE4 count; +// (type) values[]; // An array of values [count] follows of + // variable length, depending on the + // physical type. + }; + + +/* +** NOTE +** ====================================================================== +** For more detailed information about how to use these physical +** structures to create a PQDIF file, see the logical structure header +** file -- PQDIF_LG.H +*/ + +// Return to previous packing value +//#ifdef __BORLANDC__ +// #include +//#elif _MSC_VER +// #pragma pack( pop ) +//#else +// #pragma pack() +//#endif + #pragma pack( ) +#endif // PQDIF_PH_H diff --git a/LFtid1056/pqdif/include/pqdiflib.dep b/LFtid1056/pqdif/include/pqdiflib.dep new file mode 100644 index 0000000..9df5380 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdiflib.dep @@ -0,0 +1,945 @@ +# Microsoft Developer Studio Generated Dependency File, included by pqdiflib.mak + +.\el_base.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\el_coll.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\el_scal.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\el_vect.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pcn_base.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pcn_flat.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pqbytearray.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pqdfacty.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pqdinfo.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\name_id.inc"\ + ".\name_tag.inc"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pqdsupport.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\pqptrarray.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\proc_bas.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + ".\zconf.h"\ + ".\zlib.h"\ + + +.\proc_not.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + ".\zconf.h"\ + ".\zlib.h"\ + + +.\proc_zlib.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + ".\zconf.h"\ + ".\zlib.h"\ + + +.\rec_base.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\rec_container.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\rec_datasource.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\rec_general.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\rec_observ.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\rec_settings.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\ser_alloc.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\ser_cont_el.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\ser_iter_el.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\str_base.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\str_chnk.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + + +.\str_flat.cpp : \ + "..\..\..\..\..\program files\microsoft visual studio\vc98\include\basetsd.h"\ + ".\el_base.h"\ + ".\el_coll.h"\ + ".\el_scal.h"\ + ".\el_vect.h"\ + ".\pcn_base.h"\ + ".\pcn_flat.h"\ + ".\pqbytearray.h"\ + ".\pqdfacty.h"\ + ".\PQDIF_classes.h"\ + ".\pqdif_custom_1.h"\ + ".\pqdif_custom_2.h"\ + ".\pqdif_id.h"\ + ".\pqdif_lg.h"\ + ".\pqdif_ph.h"\ + ".\pqdinfo.h"\ + ".\pqdsupport.h"\ + ".\pqptrarray.h"\ + ".\proc_bas.h"\ + ".\proc_not.h"\ + ".\proc_zlib.h"\ + ".\rec_base.h"\ + ".\rec_container.h"\ + ".\rec_datasource.h"\ + ".\rec_general.h"\ + ".\rec_observ.h"\ + ".\rec_settings.h"\ + ".\ser_alloc.h"\ + ".\ser_cont_el.h"\ + ".\ser_iter_el.h"\ + ".\str_base.h"\ + ".\str_chnk.h"\ + ".\str_flat.h"\ + diff --git a/LFtid1056/pqdif/include/pqdinfo.cpp b/LFtid1056/pqdif/include/pqdinfo.cpp new file mode 100644 index 0000000..9265e28 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdinfo.cpp @@ -0,0 +1,832 @@ +/* +** CPQDIF_Info class. Implements informational member functions so that +** certain types of information can be encapsulated here. This allows us +** to concentrate knowledge at one point so it can be more easily managed. +** -------------------------------------------------------------------------- +** This class is a Singleton class; this means that only one instance of it +** should ever be created. This instance is made global, and is one of the +** only global objects in the entire system. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: pqdinfo.cpp $ +** Last modified: $Modtime: 6/19/02 3:51p $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pqdinfo.cpp $ +** VCS revision: $Revision: 17 $ +*/ +#include "PQDIF_classes.h" + +// The one and only information object (Singleton) +// =================================== +CPQDIF_Info theInfo; + + +// String for unrecognized tags and IDs. +static const char * szUnrecognized = "< Unrecognized >"; +static const char * szEmpty = ""; + +// Sorting predicated for Name Info classes +class CLess_NI_Tag // : public less +{ +public: + inline bool operator()(const NI_Tag &x, const NI_Tag &y) const + { + return ( memcmp( &x.m_tag, &y.m_tag, sizeof( GUID ) ) < 0 ); + } +}; + + +class CLess_NI_ID_GUID // : public less +{ +public: + inline bool operator()(const NI_ID_GUID &x, const NI_ID_GUID &y) const + { + return ( memcmp( &x.m_id, &y.m_id, sizeof( GUID ) ) < 0 ); + } +}; + + +class CLess_NI_ID_Int // : public less +{ +public: + bool operator()(const NI_ID_Int &x, const NI_ID_Int &y) const + { + int iResult = memcmp( &x.m_tag, &y.m_tag, sizeof( GUID ) ); + if( iResult == 0 ) + { + if( x.m_id < y.m_id ) + iResult = -1; + } + return iResult < 0; + } +}; + + +// Local macros for adding entries +// ------------------------------- +#ifdef _PQDIF_ALIAS_TAG + #define ADD_TAG_ENTRY( _tag ) \ + extern const char _PQDIF_ALIAS_##_tag[]; \ + nameTag.m_tag = _tag; \ + nameTag.m_name = #_tag; \ + nameTag.m_alias = _PQDIF_ALIAS_##_tag; \ + m_listTags.push_back( nameTag ); +#else + #define ADD_TAG_ENTRY( _tag ) \ + nameTag.m_tag = _tag; \ + nameTag.m_name = #_tag; \ + m_listTags.push_back( nameTag ); +#endif + + +#ifdef _PQDIF_ALIAS_ID + + #define ADD_ID_GUID_ENTRY( _id, _tag ) \ + extern const char _PQDIF_ALIAS_##_id[]; \ + nameGuid.m_id = _id; \ + nameGuid.m_tag = _tag; \ + nameGuid.m_name = #_id; \ + nameGuid.m_alias = _PQDIF_ALIAS_##_id; \ + m_listGUIDs.push_back( nameGuid ); + + #define ADD_ID_UINT4_ENTRY( _id, _tag )\ + extern const char _PQDIF_ALIAS_##_id[]; \ + nameInt.m_id = _id; \ + nameInt.m_tag = _tag; \ + nameInt.m_name = #_id; \ + nameInt.m_alias = _PQDIF_ALIAS_##_id; \ + m_listInts.push_back( nameInt ); + +#else + + #define ADD_ID_GUID_ENTRY( _id, _tag ) \ + nameGuid.m_id = _id; \ + nameGuid.m_tag = _tag; \ + nameGuid.m_name = #_id; \ + m_listGUIDs.push_back( nameGuid ); + + #define ADD_ID_UINT4_ENTRY( _id, _tag )\ + nameInt.m_id = _id; \ + nameInt.m_tag = _tag; \ + nameInt.m_name = #_id; \ + m_listInts.push_back( nameInt ); + +#endif + + +#define ADD_TYPE_ENTRY( _type )\ + nameType.m_type = _type; \ + nameType.m_name = #_type; \ + m_listTypes.push_back( nameType ); + + + + +// Construction +// ============ + +BYTE CPQDIF_Info::m_sizeDataTable[] = +{ + 1, 1, 2, 4, 1, 1, 1, 1, 1, 1, + 1, 2, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 1, 2, 4, 1, 1, 1, 1, 1, 1, 1, + 4, 8, 8, 16, 1, 1, 1, 1, 1, 1, + 12, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 16, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + + +CPQDIF_Info::CPQDIF_Info() +{ + NI_Tag nameTag; + NI_ID_GUID nameGuid; + NI_ID_Int nameInt; + NI_Type nameType; + + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_BOOLEAN1 ) == sizeof( BOOL1 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_BOOLEAN2 ) == sizeof( BOOL2 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_BOOLEAN4 ) == sizeof( BOOL4 ) ); + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_CHAR1 ) == sizeof( CHAR1 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_CHAR2 ) == sizeof( CHAR2 ) ); + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_INTEGER1 ) == sizeof( INT1 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_INTEGER2 ) == sizeof( INT2 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_INTEGER4 ) == sizeof( INT4 ) ); + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_UNS_INTEGER1 ) == sizeof( UINT1 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_UNS_INTEGER2 ) == sizeof( UINT2 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_UNS_INTEGER4 ) == sizeof( UINT4 ) ); + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_REAL4 ) == sizeof( REAL4 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_REAL8 ) == sizeof( REAL8 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_COMPLEX8 ) == sizeof( COMPLEX8 ) ); + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_COMPLEX16 ) == sizeof( COMPLEX16 ) ); + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_TIMESTAMPPQDIF ) == sizeof( TIMESTAMPPQDIF ) ); + + //ASSERT( GetNumBytesOfType( ID_PHYS_TYPE_GUID ) == sizeof( GUID ) ); + + // Treat the 'blank' tag a little differently + nameTag.m_tag = tagBlank; + nameTag.m_name = "< Blank >"; + m_listTags.push_back( nameTag ); + + // Tag names + #include "name_tag.inc" + #ifdef _PQDIF_EXTENDED_TAGS + #include "name_tag_extended.inc" + #endif + + // ID names + #include "name_id.inc" + #ifdef _PQDIF_EXTENDED_TAGS + #include "name_id_extended.inc" + #endif + + // Physical type names + ADD_TYPE_ENTRY( ID_PHYS_TYPE_BOOLEAN1 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_BOOLEAN2 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_BOOLEAN4 ); + + ADD_TYPE_ENTRY( ID_PHYS_TYPE_CHAR1 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_CHAR2 ); + + ADD_TYPE_ENTRY( ID_PHYS_TYPE_INTEGER1 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_INTEGER2 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_INTEGER4 ); + + ADD_TYPE_ENTRY( ID_PHYS_TYPE_UNS_INTEGER1 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_UNS_INTEGER2 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_UNS_INTEGER4 ); + + ADD_TYPE_ENTRY( ID_PHYS_TYPE_REAL4 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_REAL8 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_COMPLEX8 ); + ADD_TYPE_ENTRY( ID_PHYS_TYPE_COMPLEX16 ); + + ADD_TYPE_ENTRY( ID_PHYS_TYPE_TIMESTAMPPQDIF ); + + ADD_TYPE_ENTRY( ID_PHYS_TYPE_GUID ); + + // Sort the lists. + sort( m_listTags.begin(), m_listTags.end(), CLess_NI_Tag() ); + sort( m_listGUIDs.begin(), m_listGUIDs.end(), CLess_NI_ID_GUID() ); + sort( m_listInts.begin(), m_listInts.end(), CLess_NI_ID_Int() ); + + + #ifdef TEST + + #ifndef TRACE + #define TRACE printf + #endif + + // Check out each tag. + int iCount = GetTagCount(); + int iTag; + for( iTag = 0; iTag < iCount; iTag++) + { + GUID tag, tag1; + GUID guidID, guidID1; + int iID, iID1; + string s; + + GetTagGUID( iTag, tag ); + GetTagName( iTag, s ); + //ASSERT( s == GetNameOfTag( tag ) ); + //ASSERT( s == GetNameTag( tag ) ); + //ASSERT( s == GetAliasTag( tag ) ); + //ASSERT( GetTagFromName( s.c_str(), tag1 ) && tag == tag1 ); + TRACE( "%s %s\n", GetNameTag( tag ), GetAliasTag( tag ) ); + + // Check out each integer value for this tag. + int iCountInt = GetIDCountInt( tag ); + int iInt; + for( iInt = 0; iInt < iCountInt; iInt++ ) + { + s = GetIDNameInt( tag, iInt, iID ); + //ASSERT( s == GetNameOfID( tag, iID ) ); + //ASSERT( s == GetNameID( tag, iID ) ); + //ASSERT( GetIDFromName( s.c_str(), tag1, iID1 ) + && tag == tag1 + && iID == iID1 ); + TRACE( " %s %s\n", GetNameID( tag, iID ), GetAliasID( tag, iID ) ); + } + + // Check out each GUID value for this tag. + int iCountGUID = GetIDCountGUID( tag ); + int iGUID; + for( iGUID = 0; iGUID < iCountGUID; iGUID++ ) + { + s = GetIDNameGUID( tag, iGUID, guidID ); + //ASSERT( s == GetNameOfID( guidID ) ); + //ASSERT( s == GetNameID( guidID ) ); + //ASSERT( GetIDFromName( s.c_str(), guidID1 ) + && guidID == guidID1 ); + TRACE( " %s %s\n", GetNameID( guidID ), GetAliasID( guidID ) ); + } + + } + + #endif + + return; +} + + +CPQDIF_Info::~CPQDIF_Info() +{ +} + + +const char * CPQDIF_Info::GetNameOfTag( const GUID& tag ) +{ + const char *szName = szUnrecognized; + + NI_Tag * pInfo = _FindTag( tag ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNameOfID( const GUID& id ) +{ + const char *szName = szUnrecognized; + + NI_ID_GUID * pInfo = _FindGUID( id ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNameOfID( const GUID& tag, int id ) +{ + const char *szName = szUnrecognized; + + NI_ID_Int * pInfo = _FindInt( tag, id ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNameOfPhysType( INT4 type ) +{ + const char *szName = szUnrecognized; + + NI_Type * pInfo = _FindType( type ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNameTag( const GUID& tag ) +{ + const char *szName = NULL; + + NI_Tag * pInfo = _FindTag( tag ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNameID + ( + const GUID& id + ) +{ + const char *szName = NULL; + + NI_ID_GUID * pInfo = _FindGUID( id ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNameID + ( + const GUID& tag, + int id + ) +{ + const char *szName = NULL; + + NI_ID_Int * pInfo = _FindInt( tag, id ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetNamePhysType( INT4 type ) +{ + const char *szName = NULL; + + NI_Type * pInfo = _FindType( type ); + if( pInfo ) + szName = pInfo->m_name; + + return szName; +} + + +const char * CPQDIF_Info::GetAliasTag( const GUID& tag ) +{ + const char *szName = szEmpty; + + NI_Tag * pInfo = _FindTag( tag ); + if( pInfo ) + { + szName = pInfo->m_alias; + if( szName == NULL ) + szName = pInfo->m_name; + } + + return szName; +} + + +const char * CPQDIF_Info::GetAliasID( const GUID& id ) +{ + const char *szName = szEmpty; + + NI_ID_GUID * pInfo = _FindGUID( id ); + if( pInfo ) + { + szName = pInfo->m_alias; + if( szName == NULL ) + szName = pInfo->m_name; + } + + return szName; +} + + +const char * CPQDIF_Info::GetAliasID( const GUID& tag, int id ) +{ + const char *szName = szEmpty; + + NI_ID_Int * pInfo = _FindInt( tag, id ); + if( pInfo ) + { + szName = pInfo->m_alias; + if( szName == NULL ) + szName = pInfo->m_name; + } + + return szName; +} + + +const char * CPQDIF_Info::GetAliasPhysType( INT4 type ) +{ + const char *szName = szEmpty; + + NI_Type * pInfo = _FindType( type ); + if( pInfo ) + szName = pInfo->m_alias; + + return szName; +} + +bool CPQDIF_Info::GetTagFromName( const char *szName, GUID& tag ) +{ + + bool bFound = false; + + CList_NI_Tag::iterator iter; + for( iter = m_listTags.begin(); + iter != m_listTags.end(); + ++iter ) + { +#ifdef WIN32 + if (_strcmpi(szName, iter->m_name) == 0) + +#else + if (strcmpi(szName, iter->m_name) == 0) +#endif // WIN32 + { + tag = iter->m_tag; + bFound = true; + break; + } + } + + return bFound; +} + + +bool CPQDIF_Info::GetIDFromName( const char *szName, GUID& valueID ) +{ + + bool bFound = false; + + CList_NI_ID_GUID::iterator iter; + for( iter = m_listGUIDs.begin(); + iter != m_listGUIDs.end(); + ++iter ) + { +#ifdef WIN32 + if (_strcmpi(szName, iter->m_name) == 0) + +#else + if (strcmpi(szName, iter->m_name) == 0) +#endif // WIN32 + { + valueID = iter->m_id; + bFound = true; + break; + } + } + + return bFound; +} + + +bool CPQDIF_Info::GetIDFromName( const char *szName, GUID& tagOwner, int &valueID ) +{ + + bool bFound = false; + + CList_NI_ID_Int::iterator iter; + for( iter = m_listInts.begin(); + iter != m_listInts.end(); + ++iter ) + { +#ifdef WIN32 + if (_strcmpi(szName, iter->m_name) == 0)//WW 20240520 stricmp + +#else + if (strcmpi(szName, iter->m_name) == 0)//WW 20240520 stricmp +#endif // WIN32 + { + tagOwner = iter->m_tag; + valueID = iter->m_id; + bFound = true; + break; + } + } + + return bFound; +} + + +SIZE4 CPQDIF_Info::GetNumBytesOfType( int idType ) +{ + SIZE4 rc = 1L; + if( idType >= 0 && idType < sizeof( m_sizeDataTable )/sizeof( m_sizeDataTable[0] ) ) + { + rc = (SIZE4)m_sizeDataTable[ idType ]; + } + return rc; +} + + +bool CPQDIF_Info::GetTagGUID( int index, GUID& guidTag ) + { + bool status = false; + NI_Tag * info; + + info = _LookupTag( index ); + if( info ) + { + guidTag = info->m_tag; + status = true; + } + + return status; + } + + +bool CPQDIF_Info::GetTagName( int index, string& nameTag ) + { + bool status = false; + NI_Tag * info; + + info = _LookupTag( index ); + if( info ) + { + nameTag = info->m_name; + status = true; + } + + return status; + } + + +int CPQDIF_Info::GetIDCountGUID + ( + const GUID& tagOwner + ) +{ + CList_NI_ID_GUID::iterator iter; + int countID = 0; + + for( iter = m_listGUIDs.begin(); + iter != m_listGUIDs.end(); + ++iter ) + { + // Matched class ID + if(PQDIF_IsEqualGUID(iter->m_tag , tagOwner) ) + { + countID++; + } + } + + return countID; +} + + +const char * CPQDIF_Info::GetIDNameGUID + ( + const GUID& tagOwner, + int idxID, + GUID& valueID + ) +{ + NI_ID_GUID * info; + const char * name = NULL; + + info = _LookupGUID( tagOwner, idxID ); + if( info ) + { + name = info->m_name; + valueID = info->m_id; + } + + return name; +} + + +int CPQDIF_Info::GetIDCountInt + ( + const GUID& tagOwner + ) +{ + CList_NI_ID_Int::iterator iter; + int countID = 0; + + for( iter = m_listInts.begin(); + iter != m_listInts.end(); + ++iter ) + { + // Matched class ID + if(PQDIF_IsEqualGUID(iter->m_tag , tagOwner) ) + { + countID++; + } + } + + return countID; +} + + +const char * CPQDIF_Info::GetIDNameInt + ( + const GUID& tagOwner, + int idxID, + int& valueID + ) +{ + NI_ID_Int * info; + const char * name = NULL; + + info = _LookupInt( tagOwner, idxID ); + if( info ) + { + name = info->m_name; + valueID = info->m_id; + } + + return name; +} + + + +// Lookup functions +// ---------------- + + +NI_Tag * CPQDIF_Info::_FindTag( const GUID &tag ) +{ + NI_Tag * pInfo = NULL; + + NI_Tag info; + info.m_tag = tag; + + CList_NI_Tag::iterator iter; + iter = lower_bound( m_listTags.begin(), m_listTags.end(), + info, CLess_NI_Tag() ); + if(PQDIF_IsEqualGUID(iter->m_tag , tag) ) + { + pInfo = &( *iter ); + } + + return pInfo; + +} + + +NI_ID_GUID * CPQDIF_Info::_FindGUID + ( + const GUID& id + ) +{ + + NI_ID_GUID * pInfo = NULL; + + NI_ID_GUID info; + info.m_id = id; + + CList_NI_ID_GUID::iterator iter; + iter = lower_bound( m_listGUIDs.begin(), m_listGUIDs.end(), + info, CLess_NI_ID_GUID() ); + if(PQDIF_IsEqualGUID(iter->m_id , id )) + { + pInfo = &( *iter ); + } + + return pInfo; +} + + +NI_ID_Int * CPQDIF_Info::_FindInt + ( + const GUID& tag, + int id + ) +{ + NI_ID_Int *pInfo = NULL; + + + NI_ID_Int info; + info.m_tag = tag; + info.m_id = id; + + CList_NI_ID_Int::iterator iter; + iter = lower_bound( m_listInts.begin(), m_listInts.end(), + info, CLess_NI_ID_Int() ); + if(PQDIF_IsEqualGUID(iter->m_tag , tag) + && PQDIF_IsEqualGUID(iter->m_id , id )) + { + pInfo = &( *iter ); + } + + return pInfo; +} + + +NI_Type * CPQDIF_Info::_FindType( INT4 type ) +{ + + NI_Type * pInfo = NULL; + + CList_NI_Type::iterator iter; + + for( iter = m_listTypes.begin(); + iter != m_listTypes.end(); + ++iter ) + { + // Matched tag? + if( iter->m_type == (int) type ) + { + pInfo = &( *iter ); + break; + } + } + + return pInfo; +} + + +NI_Tag * CPQDIF_Info::_LookupTag( int idxLook ) +{ + + NI_Tag * info = NULL; + + if( idxLook >= 0 && idxLook < m_listTags.size() ) + { + info = &m_listTags[ idxLook ]; + } + + return info; +} + + +NI_ID_GUID * CPQDIF_Info::_LookupGUID + ( + const GUID& tagOwner, + int idxLook + ) +{ + CList_NI_ID_GUID::iterator iter; + + int idxThis; + NI_ID_GUID * info = NULL; + + idxThis = 0; + for( iter = m_listGUIDs.begin(); + iter != m_listGUIDs.end(); + ++iter ) + { + if(PQDIF_IsEqualGUID(iter->m_tag , tagOwner )) + { + // Matched class ID + if( idxThis == idxLook ) + { + info = &(*iter); + break; + } + idxThis++; + } + } + + return info; +} + + +NI_ID_Int * CPQDIF_Info::_LookupInt + ( + const GUID& tagOwner, + int idxLook + ) +{ + CList_NI_ID_Int::iterator iter; + + int idxThis; + NI_ID_Int * info = NULL; + + idxThis = 0; + for( iter = m_listInts.begin(); + iter != m_listInts.end(); + ++iter ) + { + // Matched owner? + if(PQDIF_IsEqualGUID(iter->m_tag , tagOwner) ) + { + if( idxThis == idxLook ) + { + info = &(*iter); + break; + } + idxThis++; + } + } + + return info; +} diff --git a/LFtid1056/pqdif/include/pqdinfo.h b/LFtid1056/pqdif/include/pqdinfo.h new file mode 100644 index 0000000..eda7068 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdinfo.h @@ -0,0 +1,190 @@ +// File name: $Workfile: pqdinfo.h $ +// Last modified: $Modtime: 7/27/01 5:44p $ +// Last modified by: $Author: Jack $ +// +// VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/pqdinfo.h $ +// VCS revision: $Revision: 12 $ + + + + +// class CPQDIF_Info + +// Base info class +// --------------- +class NameInfo +{ +public: + inline NameInfo() + { + m_name = NULL; + m_alias = NULL; + } + const char * m_name; // Name of item in the list (tag, ID, etc.) + const char * m_alias; // Alias for the item +}; + +// Sub info classes +// ---------------- +class NI_Tag : public NameInfo +{ +public: + GUID m_tag; +}; + +class NI_ID_GUID : public NameInfo +{ +public: + GUID m_tag; // Owner + GUID m_id; // ID value +}; + +class NI_ID_Int : public NameInfo +{ +public: + GUID m_tag; // Owner + int m_id; // ID value +}; + +class NI_Type : public NameInfo +{ +public: + int m_type; // Physical type +}; + + +// List classes +// ------------ +typedef vector CList_NI_Tag; +typedef vector CList_NI_ID_GUID; +typedef vector CList_NI_ID_Int; +typedef vector CList_NI_Type; + + + +class CPQDIF_Info + { + public: + CPQDIF_Info(); + ~CPQDIF_Info(); + + // Attributes + public: + + // Operations + public: + + // Name encoding. These methods always return a + // valid string. "< Unrecognized >" is returned if + // the requested value is not found. + const char * GetNameOfTag( const GUID& tag ); + const char * GetNameOfID( const GUID& valueID ); + const char * GetNameOfID( const GUID& tagOwner, int valueID ); + const char * GetNameOfPhysType( INT4 type ); + + // Same as NameOf functions execept that NULL is + // returned for undefined requests. + const char * GetNameTag( const GUID& tag ); + const char * GetNameID( const GUID& valueID ); + const char * GetNameID( const GUID& tagOwner, int valueID ); + const char * GetNamePhysType( INT4 type ); + + // Alias encoding functions. "" is returned if the requested + // value is not found. + const char * GetAliasTag( const GUID& tag ); + const char * GetAliasID( const GUID& valueID ); + const char * GetAliasID( const GUID& tagOwner, int valueID ); + const char * GetAliasPhysType( INT4 type ); + + // Name decoding. These methods return true if + // the requested value is found. + bool GetTagFromName( const char *szName, GUID& tag ); + bool GetIDFromName( const char *szName, GUID& valueID ); + bool GetIDFromName( const char *szName, GUID& tagOwner, int &valueID ); + + // Data manipulation + static SIZE4 GetNumBytesOfType( int typePhysical ); + static inline SIZE4 padSizeTo4Bytes( SIZE4 sizeOrig ) + { + return ( ( sizeOrig + 3 ) & ~3 ); + } + + static inline BYTE * GetPtrToDataValue( int /*typePhysical*/, PQDIFValue& value ) + { + return (BYTE *)&value; + } + static inline const BYTE * GetPtrToDataValue( int /*typePhysical*/, const PQDIFValue& value ) + { + return (const BYTE *)&value; + } + + // Tag enumeration + int GetTagCount( void ) + { return m_listTags.size(); } + bool GetTagGUID( int index, GUID& guidTag ); + bool GetTagName( int index, string& nameTag ); + + // GUID ID enumeration + int GetIDCountGUID + ( + const GUID& tagOwner + ); + const char * GetIDNameGUID + ( + const GUID& tagOwner, + int idxID, + GUID& valueID + ); + + // Integer ID enumeration + int GetIDCountInt + ( + const GUID& tagOwner + ); + const char * GetIDNameInt + ( + const GUID& tagOwner, + int idxID, + int& valueID + ); + + // Implementation + protected: + BYTE * _GetPtrToDataValue( int typePhysical, const PQDIFValue& value ); + + NI_Tag * _FindTag( const GUID &tag ); + NI_ID_GUID * _FindGUID( const GUID& id ); + NI_ID_Int * _FindInt( const GUID& tag, int id ); + NI_Type * _FindType( INT4 type ); + + + NI_Tag * _LookupTag( int idxLook ); + NI_ID_GUID * _LookupGUID + ( + const GUID& tagOwner, + int idxLook + ); + NI_ID_Int * _LookupInt + ( + const GUID& tagOwner, + int idxLook + ); + + // Data + protected: + CList_NI_Tag m_listTags; + CList_NI_ID_GUID m_listGUIDs; + CList_NI_ID_Int m_listInts; + CList_NI_Type m_listTypes; + + + // Lookup table for finding the size of a data type. + protected: + static BYTE m_sizeDataTable[70]; + + }; + + +// The one and only information object (Singleton) +extern CPQDIF_Info theInfo; + diff --git a/LFtid1056/pqdif/include/pqdsupport.cpp b/LFtid1056/pqdif/include/pqdsupport.cpp new file mode 100644 index 0000000..bac1a0e --- /dev/null +++ b/LFtid1056/pqdif/include/pqdsupport.cpp @@ -0,0 +1,522 @@ +/* +** CPQDIF_COMSupport class. Implements support member functions so that +** make dealing with COM/OLE/ActiveX much easier. +** -------------------------------------------------------------------------- +** This class is a Singleton class; this means that only one instance of it +** should ever be created. This instance is made global, and is one of the +** only global objects in the entire system. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: pqdsupport.cpp $ +** Last modified: $Modtime: 4/15/02 3:19p $ +** Last modified by: $Author: Wadef $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/pqdsupport.cpp $ +** VCS revision: $Revision: 5 $ +*/ + +#ifdef PQDIF_USE_COM + +#include "PQDIF_classes.h" +#include "pqdsupport.h" + +const GUID ID_NULL = { 0, 0, 0, { 0, 0, 0, 0, 0, 0, 0, 0 } }; + +// The one and only support object (Singleton) +CPQDIF_COMSupport theSupport; + + + +// Construction +// ============ + +CPQDIF_COMSupport::CPQDIF_COMSupport() + { + } + +CPQDIF_COMSupport::~CPQDIF_COMSupport() + { + } + + +bool CPQDIF_COMSupport::NewVariantArrayFromGUID + ( + VARIANT& var, + const GUID& guid + ) + { + bool status = false; + const int countLongs = 4; + BYTE * pbData; + + // Set the variant to a 1-byte array + VariantInit( &var ); + var.vt = VT_ARRAY + VT_I4; + var.parray = SafeArrayCreateVector( VT_I4, 0, countLongs ); + + // If a safe array of doubles was passed then ... + if( var.parray != NULL) + { + if( !FAILED( SafeArrayAccessData( var.parray, (void **) &pbData ) ) ) + { + // Copy the contents of the GUID + memcpy( pbData, &guid, countLongs * sizeof( long ) ); + SafeArrayUnaccessData( var.parray ); + status = true; + } + } + + return status; + } + + +bool CPQDIF_COMSupport::SetGUIDFromVariantArray + ( + GUID& guid, + const VARIANT& var + ) const + { + bool status = false; + long lLower; + long lUpper; + long countItems; + BYTE * pbData; + + guid = ID_NULL; + + // Valid array of long [ 4 ]? + if( ( var.vt & VT_ARRAY ) /* && ( var.vt & VT_I4 )*/ && var.parray ) + { + // Validate the size of the array + SafeArrayGetUBound( var.parray, 1, &lUpper ); + SafeArrayGetLBound( var.parray, 1, &lLower ); + countItems = (lUpper - lLower + 1); + + if( countItems == 4 ) + { + VARIANT HUGEP *pvLongs; + + if (!FAILED(SafeArrayAccessData(var.parray, reinterpret_cast(&pvLongs)))) + { + if (var.vt & VT_VARIANT) + { + INT4 * pInt = (INT4 *)&guid; + + for (int count = 0; count < 4; count++, pInt++) + *pInt = pvLongs[count].lVal; + } + else + { + pbData = (BYTE *)pvLongs; + // Copy the GUID + memcpy( &guid, pbData, sizeof( guid ) ); + status = true; + } + + SafeArrayUnaccessData( var.parray ); + } + } // Got safe array data + } // Valid safe array + + return status; + } + + +bool CPQDIF_COMSupport::NewVariantArrayFromVector + ( + VARIANT& var, + CPQDIF_E_Vector& vect + ) + { + bool status = false; + VARTYPE vtSingle; + long typePhysical; + long sizePhysical; + long countItems; + BYTE * pbData; + INT1 * pdataSource; + + // Check the physical type for the size we need... + // (and how many items are in the array) + typePhysical = vect.GetPhysicalType(); + sizePhysical = theInfo.GetNumBytesOfType( typePhysical ); + vect.GetCount( countItems ); + + _variant_t varV; + // Grab the first item to see what variant type the array should be... + status = vect.GetValue( 0, varV ); + if( status ) + { + // Got the variant type + vtSingle = varV.vt; + status = false; + + // Set the variant to an array of this type + VariantInit( &var ); + + var.vt = VT_ARRAY | vtSingle; + var.parray = SafeArrayCreateVector( vtSingle, 0, countItems ); + + // If a safe array of doubles was passed then ... + if( var.parray != NULL) + { + if( !FAILED( SafeArrayAccessData( var.parray, (void **) &pbData ) ) ) + { + pdataSource = reinterpret_cast(vect.GetRawData()); + if( pdataSource ) + { + // Copy the entire block of data across by physical item size + memcpy( pbData, pdataSource, countItems * sizePhysical ); + status = true; + } + + SafeArrayUnaccessData( var.parray ); + } // Got safe array data + } // Valid safe array + } // Valid data type + + return status; + } + + +bool CPQDIF_COMSupport::NewVariantArrayFromDouble + ( + VARIANT& var, + double * arValues, + long countItems + ) + { + bool status = false; + VARTYPE vtSingle; + long sizePhysical; + BYTE * pbData; + + // Set the variant to an array of this type + sizePhysical = sizeof( double ); + vtSingle = VT_R8; + VariantInit( &var ); + var.vt = VT_ARRAY | vtSingle; + var.parray = SafeArrayCreateVector( vtSingle, 0, countItems ); + + // If a safe array of doubles was passed then ... + if( var.parray != NULL) + { + if( !FAILED( SafeArrayAccessData( var.parray, (void **) &pbData ) ) ) + { + if( arValues ) + { + // Copy the entire block across + memcpy( pbData, (BYTE *) arValues, sizePhysical * countItems ); + status = true; + } + + SafeArrayUnaccessData( var.parray ); + } // Got safe array data + } // Valid safe array + + return status; + } + +long GetPhysicalTypeFromVariant( const VARIANT& var, long typeElement ) + { + long typePhysical = 0; + BOOL isArray = FALSE; + int countDims = 0; + long lUpper; + long lLower; + long countItemsLastDim = 0; + + SAFEARRAY * psa = NULL; + + // Is this an array? + if( var.vt & VT_ARRAY ) + { + // Which safearray? + if( var.vt & VT_BYREF ) + { + if( var.pparray ) + psa = *var.pparray; + } + else + { + psa = var.parray; + } + + if( psa ) + { + isArray = TRUE; + countDims = SafeArrayGetDim( psa ); + + // Count the number of items in the last dimension... + SafeArrayGetUBound( var.parray, countDims, &lUpper ); + SafeArrayGetLBound( var.parray, countDims, &lLower ); + countItemsLastDim = (lUpper - lLower + 1); + } + } + + // Is this a vector? If so, we only consider it an "array" if there + // are two dimensions. + if( typeElement == ID_ELEMENT_TYPE_VECTOR && isArray ) + { + if( countDims < 2 ) + { + isArray = FALSE; + } + } + + switch( var.vt & VT_TYPEMASK ) + { + case VT_BOOL: + typePhysical = ID_PHYS_TYPE_BOOLEAN2 ; + break; + + case VT_I1: + typePhysical = ID_PHYS_TYPE_INTEGER1 ; + break; + + case VT_I2: + typePhysical = ID_PHYS_TYPE_INTEGER2 ; + break; + + case VT_I4: + typePhysical = ID_PHYS_TYPE_INTEGER4 ; + if( isArray && countItemsLastDim == 4 ) + { + typePhysical = ID_PHYS_TYPE_GUID; + } + break; + + // Real/complex + case VT_R4: + typePhysical = ID_PHYS_TYPE_REAL4 ; + if( isArray && countItemsLastDim == 2 ) + { + typePhysical = ID_PHYS_TYPE_COMPLEX8; + } + break; + + case VT_R8: + typePhysical = ID_PHYS_TYPE_REAL8; + if( isArray && countItemsLastDim == 2 ) + { + typePhysical = ID_PHYS_TYPE_COMPLEX16; + } + break; + + // Date/time + case VT_DATE: + typePhysical = ID_PHYS_TYPE_TIMESTAMPPQDIF ; + break; + } + + return typePhysical; + } + + +bool CPQDIF_COMSupport::SetVectorArrayFromVariant( CPQDIF_E_Vector& vect, VARIANT& values ) + { + bool status = false; + long typePhysical; + unsigned int sizeSingle; + long sizeType; + BYTE * pbData; + INT1 * pdataTarget; + + SAFEARRAY * psa = NULL; + + long lLower; + long lUpper; + long countItems; + long countDimensions; + long countItemsDim2 = 0; + + // Make sure it is an array + if( values.vt & VT_ARRAY ) + { + // Is valid physical type set? + //typePhysical = vect.GetPhysicalType(); + typePhysical = 0; + if( typePhysical == 0 ) + { + typePhysical = GetPhysicalTypeFromVariant( + values, vect.GetElementType() ); + + vect.SetPhysicalType( typePhysical ); + sizeType = theInfo.GetNumBytesOfType( typePhysical ); + } + + // Which safearray? + if( values.vt & VT_BYREF ) + { + if( values.pparray ) + psa = *values.pparray; + } + else + { + psa = values.parray; + } + + if( !FAILED( SafeArrayAccessData( psa, (void **)&pbData ) ) ) + { + // Get the physical size of each element + sizeSingle = SafeArrayGetElemsize( values.parray ); + + // Get the size of the new array. + SafeArrayGetUBound( values.parray, 1, &lUpper ); + SafeArrayGetLBound( values.parray, 1, &lLower ); + countItems = (lUpper - lLower + 1); + + // Is there a second dimension? + countDimensions = SafeArrayGetDim( values.parray ); + if( countDimensions > 1 ) + { + SafeArrayGetUBound( values.parray, 2, &lUpper ); + SafeArrayGetLBound( values.parray, 2, &lLower ); + countItemsDim2 = (lUpper - lLower + 1); + } + + // Configure vector + vect.SetCount( countItems ); + + pdataTarget = reinterpret_cast(vect.GetRawData()); + + if( pdataTarget && (int) sizeType == (int) sizeSingle ) + { + // Copy the caller's data into the array. + memcpy( pdataTarget, pbData, countItems * sizeSingle ); + status = true; + } + + SafeArrayUnaccessData( psa ); + } + } + + return status; + } + + +bool CPQDIF_COMSupport::NewArrayUINT4FromVariant + ( + UINT4 ** aidxChannelTriggerLocal, + long& countItems, + VARIANT& var + ) + { + bool status = false; + long lLower; + long lUpper; + BYTE * pbData; + long * pSource; + UINT4 * pTarget; + + // Init + *aidxChannelTriggerLocal = NULL; + countItems = 0; + + // Valid array of long? + if( ( var.vt & VT_ARRAY ) && ( var.vt & VT_I4 ) && var.parray ) + { + // Validate the size of the array + SafeArrayGetUBound( var.parray, 1, &lUpper ); + SafeArrayGetLBound( var.parray, 1, &lLower ); + countItems = (lUpper - lLower + 1); + + if( countItems > 0 ) + { + if( !FAILED( SafeArrayAccessData( var.parray, (void **) &pbData ) ) ) + { + // Allocate space + *aidxChannelTriggerLocal = new UINT4[ countItems ]; + + // Create temp pointers (to be incremented) and copy + pSource = (long *) pbData; + pTarget = *aidxChannelTriggerLocal; + for( long idx = 0; idx < countItems; idx++, pSource++, pTarget++ ) + { + *pTarget = (UINT4) *pSource; + } + + status = true; + SafeArrayUnaccessData( var.parray ); + } + } // Got safe array data + } // Valid safe array + + return status; + + } + + + +bool CPQDIF_COMSupport::NewComStringFromVector( CPQDIF_E_Vector& vect, BSTR * str ) + { + bool status = false; + long countItems; + string strOutput; + INT1 * pdataSource; + + // Init + strOutput = ""; + vect.GetCount( countItems ); + + switch( vect.GetPhysicalType() ) + { + case ID_PHYS_TYPE_CHAR1: + pdataSource = reinterpret_cast(vect.GetRawData()); + if( pdataSource ) + { + // Convert it to a string + USES_CONVERSION; + strOutput = (const char *) pdataSource; + *str = SysAllocString(_bstr_t(strOutput.c_str())); + status = true; + } + break; + + case ID_PHYS_TYPE_CHAR2: + // NOT SUPPORTED + break; + + default: + status = true; + break; + } + + return status; + } + + +bool CPQDIF_COMSupport::SetVectorArrayFromString( CPQDIF_E_Vector& vect, BSTR * str ) + { + bool status = false; + + USES_CONVERSION; + + // Init + vect.SetValues( W2A(*str) ); + + return status; + } + + +bool CPQDIF_COMSupport::SetDateFromTimeStamp( DATE& date, const TIMESTAMPPQDIF& ts ) + { + date = (double) ts.day + + ( (double) ts.sec / (double) SECONDS_PER_DAY ); + + return true; + } + + +bool CPQDIF_COMSupport::SetTimeStampFromDate( TIMESTAMPPQDIF& ts, const DATE& date ) + { + // Take integral portion for the day + ts.day = (UINT4) date; + + // Take the fractional portion for the seconds + ts.sec = ( (REAL8) SECONDS_PER_DAY ) * ( (REAL8) date - (REAL8) ts.day ); + + return true; + } + +#endif // PQDIF_USE_COM \ No newline at end of file diff --git a/LFtid1056/pqdif/include/pqdsupport.h b/LFtid1056/pqdif/include/pqdsupport.h new file mode 100644 index 0000000..8c63884 --- /dev/null +++ b/LFtid1056/pqdif/include/pqdsupport.h @@ -0,0 +1,64 @@ +#ifndef _CPQDIF_COMSupport_INC_ +#define _CPQDIF_COMSupport_INC_ +// class CPQDIF_COMSupport + +#ifdef PQDIF_USE_COM + +class CPQDIF_COMSupport + { + public: + CPQDIF_COMSupport(); + ~CPQDIF_COMSupport(); + + // Attributes + public: + + // Operations + public: + bool NewVariantArrayFromGUID + ( + VARIANT& var, + const GUID& guid + ); + bool SetGUIDFromVariantArray + ( + GUID& guid, + const VARIANT& var + ) const; + bool NewVariantArrayFromVector + ( + VARIANT& var, + CPQDIF_E_Vector& vect + ); + bool NewVariantArrayFromDouble + ( + VARIANT& var, + double * arValues, + long countValues + ); + bool NewArrayUINT4FromVariant + ( + UINT4 ** aidxChannelTrigger, + long& countTriggersLocal, + VARIANT& aidxChannelTriggerVar + ); + + bool SetVectorArrayFromVariant( CPQDIF_E_Vector& vect, VARIANT& var ); + + bool NewComStringFromVector( CPQDIF_E_Vector& vect, BSTR * str ); + bool SetVectorArrayFromString( CPQDIF_E_Vector& vect, BSTR * str ); + + bool SetDateFromTimeStamp( DATE& date, const TIMESTAMPPQDIF& ts ); + bool SetTimeStampFromDate( TIMESTAMPPQDIF& ts, const DATE& date ); + + // Implementation + protected: + }; + + +// The one and only support object (Singleton) +extern CPQDIF_COMSupport theSupport; + +#endif // PQDIF_USE_COM + +#endif // _CPQDIF_COMSupport_INC_ diff --git a/LFtid1056/pqdif/include/pqptrarray.cpp b/LFtid1056/pqdif/include/pqptrarray.cpp new file mode 100644 index 0000000..cc0b7ed --- /dev/null +++ b/LFtid1056/pqdif/include/pqptrarray.cpp @@ -0,0 +1,208 @@ +// File name: $Workfile: pqptrarray.cpp $ +// Last modified: $Modtime: 2/10/99 12:42 $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pqptrarray.cpp $ +// VCS revision: $Revision: 5 $ + +#include "PQDIF_classes.h" + +const int sizeElement = sizeof( void * ); + + +CPQPtrArray::CPQPtrArray() +{ + m_data = (void **) malloc( 16 * sizeElement ); + m_size = 0; + m_max = 16; + m_growBy = 16; +} + + +CPQPtrArray::~CPQPtrArray() +{ + if( m_data ) + { + free( m_data ); + } +} + + +int CPQPtrArray::GetSize( void ) const +{ + return m_size; +} + + +void CPQPtrArray::SetSize( int NewSize, int GrowBy ) +{ + m_size = NewSize; + if( GrowBy > 0 ) + m_growBy = GrowBy; + + // Grow? + if( NewSize > m_max ) + { + m_max = NewSize + m_growBy; + m_data = (void **) realloc( (void *) m_data, m_max * sizeElement ); + } +} + + +void * CPQPtrArray::GetAt( int idx ) const +{ + void * bogus = NULL; + + if( idx >=0 && idx < m_size ) + { + return m_data[ idx ]; + } + else + { + return bogus; + } +} + + +void CPQPtrArray::SetAt( int idx, void * value ) +{ + if( idx >= 0 && idx < m_size ) + { + m_data[ idx ] = value; + } +} + + +void CPQPtrArray::SetAtGrow(int nIndex, void* newElement) + { + //ASSERT_VALID(this); + //ASSERT(nIndex >= 0); + + if (nIndex >= m_size) + SetSize(nIndex+1); + m_data[nIndex] = newElement; + + } + +void CPQPtrArray::InsertAt( int nIndex, void * newElement, int nCount ) +{ + if (nIndex >= m_size) + { + // adding after the end of the array + SetSize(nIndex + nCount); // grow so indexToInsert is valid + } + else + { + // inserting in the middle of the array + int nOldSize = m_size; + SetSize(m_size + nCount); // grow it to new size + // shift old data up to fill gap + memmove(&m_data[nIndex+nCount], &m_data[nIndex], + (nOldSize-nIndex) * sizeof(void*)); + + // re-init slots we copied from + + memset(&m_data[nIndex], 0, nCount * sizeof(void*)); + + } + + // insert new value in the gap + //ASSERT(nIndex + nCount <= m_size); + while (nCount--) + m_data[nIndex++] = newElement; + +} + +void CPQPtrArray::RemoveAt( int indexToRemove ) +{ + if( indexToRemove >= 0 && indexToRemove < m_size ) + { + for( int idx = indexToRemove + 1; idx < m_size; idx++ ) + { + m_data[ idx - 1 ] = m_data[ idx ]; + } + + SetSize( GetSize() - 1 ); + } +} + + +int CPQPtrArray::Add( void * value ) +{ + int pos = m_size; + + SetSize( m_size + 1, m_growBy ); + if( m_data ) + { + m_data[ pos ] = value; + return pos; + } + else + { + return -1; + } +} + + +void * CPQPtrArray::operator[] ( int idx ) const +{ + return GetAt( idx ); +} + + +#ifdef _DEBUG +bool CPQPtrArray::Test( void ) +{ + bool failed = false; + void * ptr1 = (void *) 1; + void * ptr2 = (void *) 2; + void * ptr3 = (void *) 3; + void * ptr4 = (void *) 4; + void * ptr5 = (void *) 5; + + SetSize( 16, 4 ); + if( m_size != 16 || m_growBy != 4 ) + failed = true; + + SetSize( 0 ); + if( m_size != 0 || m_growBy != 4 ) + failed = true; + + Add( ptr1 ); + Add( ptr2 ); + if( m_size != 2 ) + failed = true; + if( m_data[0] != ptr1 || m_data[1] != ptr2 ) + failed = true; + + Add( ptr3 ); + InsertAt( 1, ptr4 ); + if( m_size != 4 ) + failed = true; + if( m_data[0] != ptr1 || m_data[1] != ptr4 || m_data[2] != ptr2 || m_data[3] != ptr3 ) + failed = true; + + SetSize( 2, 16 ); + if( m_size != 2 ) + failed = true; + if( m_growBy != 16 ) + failed = true; + if( m_data[0] != ptr1 || m_data[1] != ptr4 ) + failed = true; + + SetSize( 3 ); + if( m_size != 3 ) + failed = true; + if( m_growBy != 16 ) + failed = true; + + if( failed ) + { + //TRACE( "CPQPtrArray::Test - *FAILED*" ); + return false; + } + + return true; +} +#endif + diff --git a/LFtid1056/pqdif/include/pqptrarray.h b/LFtid1056/pqdif/include/pqptrarray.h new file mode 100644 index 0000000..ec9a26f --- /dev/null +++ b/LFtid1056/pqdif/include/pqptrarray.h @@ -0,0 +1,39 @@ +// File name: $Workfile: pqptrarray.h $ +// Last modified: $Modtime: 1/03/99 7:27p $ +// Last modified by: $Author: Erich $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/pqptrarray.h $ +// VCS revision: $Revision: 3 $ + + +class CPQPtrArray +{ +public: + CPQPtrArray(); + ~CPQPtrArray(); + +public: + int GetSize( void ) const; + void SetSize( int NewSize, int GrowBy = -1 ); + + void * GetAt( int idx ) const; + void SetAt( int idx, void * value ); + void SetAtGrow( int idx, void * value ); + + void InsertAt( int indexToInsert, void * prec, int nCount = 1 ); + void RemoveAt( int indexToInsert ); + + int Add( void * value ); + + void * operator[] ( int idx ) const; + +#ifdef _DEBUG + bool Test( void ); +#endif + +protected: + void ** m_data; + int m_size; + int m_max; + int m_growBy; +}; diff --git a/LFtid1056/pqdif/include/proc_bas.cpp b/LFtid1056/pqdif/include/proc_bas.cpp new file mode 100644 index 0000000..5e20e8c --- /dev/null +++ b/LFtid1056/pqdif/include/proc_bas.cpp @@ -0,0 +1,42 @@ +/* +** CPQDIF_StreamProcessor class. Base class for PQDIF stream processors -- +** generally for compression/decompression. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: proc_bas.cpp $ +** Last modified: $Modtime: 9/20/00 10:16a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/proc_bas.cpp $ +** VCS revision: $Revision: 6 $ +*/ +#include "PQDIF_classes.h" +#include "zlib.h" + + +// Construction +// ============ + +CPQDIF_StreamProcessor::CPQDIF_StreamProcessor() + { + m_pstrm = NULL; + m_checksum = adler32( 0L, Z_NULL, 0 ); + } + +CPQDIF_StreamProcessor::~CPQDIF_StreamProcessor() + { + } + +bool CPQDIF_StreamProcessor::ConnectStream( CPQDIF_StreamIO * pstrm ) + { + m_pstrm = pstrm; + return true; + } + + +void CPQDIF_StreamProcessor::ResetChecksum( void ) +{ + m_checksum = adler32( 0L, Z_NULL, 0 ); +} + + diff --git a/LFtid1056/pqdif/include/proc_bas.h b/LFtid1056/pqdif/include/proc_bas.h new file mode 100644 index 0000000..a00e8e5 --- /dev/null +++ b/LFtid1056/pqdif/include/proc_bas.h @@ -0,0 +1,37 @@ +// File name: $Workfile: proc_bas.h $ +// Last modified: $Modtime: 9/20/00 10:14a $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/proc_bas.h $ +// VCS revision: $Revision: 5 $ + +// Interface class CPQDIF_StreamProcessor + +class CPQDIF_StreamIO; + +class CPQDIF_StreamProcessor + { + public: + CPQDIF_StreamProcessor(); + virtual ~CPQDIF_StreamProcessor(); + + // Attributes + public: + virtual long GetChecksum( void ) { return m_checksum; } + + // Operations + public: + virtual bool ConnectStream( CPQDIF_StreamIO * pstrm ); + virtual bool StreamEncode( void ) = 0; + virtual bool StreamDecode( void ) = 0; + virtual void ResetChecksum( void ); + + // Implementation + protected: + + // Member data + protected: + CPQDIF_StreamIO * m_pstrm; + long m_checksum; + }; + diff --git a/LFtid1056/pqdif/include/proc_not.cpp b/LFtid1056/pqdif/include/proc_not.cpp new file mode 100644 index 0000000..a9883f8 --- /dev/null +++ b/LFtid1056/pqdif/include/proc_not.cpp @@ -0,0 +1,61 @@ +/* +** CPQDIF_SP_Nothing class. Implements a "do nothing" processor. +** Used when the PQDIF file is not compressed -- or for certain records +** which are never compressed. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: proc_not.cpp $ +** Last modified: $Modtime: 9/20/00 10:22a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/proc_not.cpp $ +** VCS revision: $Revision: 6 $ +*/ +#include "PQDIF_classes.h" +#include "zlib.h" + + +// Construction +// ============ + +CPQDIF_SP_Nothing::CPQDIF_SP_Nothing() + { + } + +CPQDIF_SP_Nothing::~CPQDIF_SP_Nothing() + { + } + +bool CPQDIF_SP_Nothing::StreamEncode( void ) + { + bool status = FALSE; + long sizeActual = 0; + const BYTE * bufferInput; + BYTE * bufferOutput; + + status = m_pstrm->ProcessRead( bufferInput, 0, sizeActual ); + if( status ) + { + status = m_pstrm->ProcessWriteReserve( bufferOutput, sizeActual ); + if( status ) + { + memcpy( bufferOutput, bufferInput, sizeActual ); + m_checksum = adler32( m_checksum, (const Bytef *)bufferInput, sizeActual ); + m_pstrm->ProcessWriteRelease( sizeActual ); + } + } + + return status; + } + +bool CPQDIF_SP_Nothing::StreamDecode( void ) + { + bool status = FALSE; + + // Since we're doing nothing, decoding is the same + // as encoding! + status = StreamEncode(); + + return status; + } + diff --git a/LFtid1056/pqdif/include/proc_not.h b/LFtid1056/pqdif/include/proc_not.h new file mode 100644 index 0000000..04009df --- /dev/null +++ b/LFtid1056/pqdif/include/proc_not.h @@ -0,0 +1,24 @@ +// File name: $Workfile: proc_not.h $ +// Last modified: $Modtime: 2/05/98 2:48p $ +// Last modified by: $Author: Rob $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/proc_not.h $ +// VCS revision: $Revision: 3 $ + +// class CPQDIF_SP_Nothing + +class CPQDIF_SP_Nothing : public CPQDIF_StreamProcessor + { + public: + CPQDIF_SP_Nothing(); + ~CPQDIF_SP_Nothing(); + + // Attributes + public: + + // Operations + public: + virtual bool StreamEncode( void ); + virtual bool StreamDecode( void ); + }; + diff --git a/LFtid1056/pqdif/include/proc_zlib.cpp b/LFtid1056/pqdif/include/proc_zlib.cpp new file mode 100644 index 0000000..d2693cf --- /dev/null +++ b/LFtid1056/pqdif/include/proc_zlib.cpp @@ -0,0 +1,168 @@ +/* +** CPQDIF_SP_ZLIB class. Implements a compression processor for the ZLIB +** compression library. See PQDIF documentation for details. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: proc_zlib.cpp $ +** Last modified: $Modtime: 10/11/01 12:43p $ +** Last modified by: $Author: Tomm $ +** +** VCS archive path: $Archive: /ElectrotekLibs/Borland/PQDIFlib/proc_zlib.cpp $ +** VCS revision: $Revision: 9 $ +*/ +#include "PQDIF_classes.h" + +// Public-domain ZLIB code +#include "zlib.h" + + + +// Construction +// ============ + +CPQDIF_SP_ZLIB::CPQDIF_SP_ZLIB() + { + } + + +CPQDIF_SP_ZLIB::~CPQDIF_SP_ZLIB() + { + } + + +bool CPQDIF_SP_ZLIB::StreamEncode( void ) + { + bool status = TRUE; + bool haveData = FALSE; + long sizeActual = 0; + + z_stream c_stream; /* compression stream */ + int err; + + // Init ZLIB for best compression ratio + memset( &c_stream, 0, sizeof( c_stream ) ); + c_stream.zalloc = (alloc_func)0; + c_stream.zfree = (free_func)0; + c_stream.opaque = (voidpf)0; + err = deflateInit( &c_stream, Z_BEST_COMPRESSION ); + if( err == Z_OK ) + { + + // Initialize the input buffer. + const BYTE * bufferInput; + long sizeInput; + + status = m_pstrm->ProcessRead( bufferInput, 0, sizeInput ); + + c_stream.next_in = (BYTE *)bufferInput; + c_stream.avail_in = sizeInput; + + if( status ) + { + + // Reserve space in the stream buffer for output. + // If successful then ... + BYTE * bufferOutput; + int sizeOutput = ( ( sizeInput * 11 )/10 ) + 12; + + status = m_pstrm->ProcessWriteReserve( bufferOutput, sizeOutput ); + + c_stream.next_out = bufferOutput; + c_stream.avail_out = sizeOutput; + c_stream.total_out = 0; + + if( status ) + { + + + // Compress! + err = deflate( &c_stream, Z_FINISH ); + if( err != Z_STREAM_END ) + status = false; + + // Release the output buffer. + if( status && c_stream.total_out > 0 ) + { + m_checksum = adler32( m_checksum, (const Bytef *)bufferOutput, c_stream.total_out ); + status = m_pstrm->ProcessWriteRelease( c_stream.total_out ); + } + } + } + } + + else + status = false; + + err = deflateEnd(&c_stream); + if( err != Z_OK ) + status = FALSE; + + return status; + } + + +bool CPQDIF_SP_ZLIB::StreamDecode( void ) + { + bool status = TRUE; + bool haveData = FALSE; + long sizeActual = 0; + + z_stream c_stream; /* decompression stream */ + int err; + + // Init + memset( &c_stream, 0, sizeof( c_stream ) ); + err = inflateInit(&c_stream); + if( err == Z_OK ) + { + + // Initialize the input buffer. + const BYTE * bufferInput; + long sizeInput; + + status = m_pstrm->ProcessRead( bufferInput, 0, sizeInput ); + + c_stream.next_in = (BYTE *)bufferInput; + c_stream.avail_in = sizeInput; + + // Determine the size of the output buffer to use for expanding + // the data. + BYTE * bufferOutput; + int sizeOutput = max( ( c_stream.avail_in * 4 ), (unsigned) 32*1024 ); + + while( status && err == Z_OK ) + { + + // Reserve space in the stream buffer for output. + // If successful then ... + + status = m_pstrm->ProcessWriteReserve( bufferOutput, sizeOutput ); + + c_stream.next_out = bufferOutput; + c_stream.avail_out = sizeOutput; + c_stream.total_out = 0; + + if( status ) + { + + // Compress! + err = inflate( &c_stream, Z_NO_FLUSH ); + + // Release the output buffer. + status = m_pstrm->ProcessWriteRelease( c_stream.total_out ); + + } + } + + } + else + status = FALSE; + + err = inflateEnd( &c_stream ); + if( err != Z_OK ) + status = FALSE; + + return status; + } + + diff --git a/LFtid1056/pqdif/include/proc_zlib.h b/LFtid1056/pqdif/include/proc_zlib.h new file mode 100644 index 0000000..994e939 --- /dev/null +++ b/LFtid1056/pqdif/include/proc_zlib.h @@ -0,0 +1,29 @@ +// File name: $Workfile: proc_zlib.h $ +// Last modified: $Modtime: 2/05/98 2:48p $ +// Last modified by: $Author: Rob $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/proc_zlib.h $ +// VCS revision: $Revision: 3 $ + +// class CPQDIF_SP_ZLIB + +class CPQDIF_SP_ZLIB : public CPQDIF_StreamProcessor + { + public: + CPQDIF_SP_ZLIB(); + ~CPQDIF_SP_ZLIB(); + + // Attributes + public: + + // Operations + public: + virtual bool StreamEncode( void ); + virtual bool StreamDecode( void ); + + // Member data + private: + BYTE * m_bufferOutput; + int m_sizeOutput; + }; + diff --git a/LFtid1056/pqdif/include/rec_base.cpp b/LFtid1056/pqdif/include/rec_base.cpp new file mode 100644 index 0000000..f1beb3b --- /dev/null +++ b/LFtid1056/pqdif/include/rec_base.cpp @@ -0,0 +1,147 @@ +/* +** CPQDIF_R_DataSource class. Implements a PQDIF record "wrapper" for the +** data source record. You can cast a standard record object to this class. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_base.cpp $ +** Last modified: $Modtime: 11/14/00 3:36p $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_base.cpp $ +** VCS revision: $Revision: 7 $ +*/ +#include "PQDIF_classes.h" + + +CPQDIF_E_Collection * CPQDIFRecord::FindCollectionInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag + ) + { + CPQDIF_E_Collection * pcolReturn = NULL; + + if( pcoll ) + { + pcolReturn = (CPQDIF_E_Collection *)pcoll->GetElement( tag, ID_ELEMENT_TYPE_COLLECTION ); + } + + return pcolReturn; + } + + +CPQDIF_E_Scalar * CPQDIFRecord::FindScalarInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag + ) + { + CPQDIF_E_Scalar * pscReturn = NULL; + + if( pcoll ) + { + pscReturn = (CPQDIF_E_Scalar *)pcoll->GetElement( tag, ID_ELEMENT_TYPE_SCALAR ); + } + + return pscReturn; + } + + +bool CPQDIFRecord::GetScalarValueInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag, + UINT4 typePhysical, + PQDIFValue& value + ) + { + bool status = FALSE; + long typePhysicalThisItem; + CPQDIF_E_Scalar * pscReturn = NULL; + + if( pcoll ) + { + pscReturn = (CPQDIF_E_Scalar *)pcoll->GetElement( tag, ID_ELEMENT_TYPE_SCALAR ); + if( pscReturn ) + { + status = pscReturn->GetValue( typePhysicalThisItem, value ) + && typePhysicalThisItem == (long)typePhysical; + } + } + + return status; + } + + +CPQDIF_E_Scalar * CPQDIFRecord::FindOrCreateScalarInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag, + UINT4 typePhysical + ) + { + CPQDIF_E_Scalar * pscReturn = NULL; + + if( pcoll ) + { + pscReturn = (CPQDIF_E_Scalar *)pcoll->GetElement( tag, ID_ELEMENT_TYPE_SCALAR ); + if( !pscReturn ) + { + // If it doesn't exist, create, initialize and add it + pscReturn = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( pscReturn ) + { + pscReturn->SetTag( tag ); + pscReturn->SetPhysicalType( typePhysical ); + pcoll->Add( pscReturn ); + } + } + } + return pscReturn; + } + + +CPQDIF_E_Vector * CPQDIFRecord::FindVectorInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag + ) + { + CPQDIF_E_Vector * pvectReturn = NULL; + + if( pcoll ) + { + pvectReturn = (CPQDIF_E_Vector *)pcoll->GetElement( tag, ID_ELEMENT_TYPE_VECTOR ); + } + + return pvectReturn; + } + + +CPQDIF_E_Vector * CPQDIFRecord::FindOrCreateVectorInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag, + UINT4 typePhysical + ) + { + CPQDIF_E_Vector * pvectReturn = NULL; + + if( pcoll ) + { + pvectReturn = (CPQDIF_E_Vector *)pcoll->GetElement( tag, ID_ELEMENT_TYPE_VECTOR ); + if( !pvectReturn ) + { + // If it doesn't exist, create, initialize and add it + pvectReturn = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); + if( pvectReturn ) + { + pvectReturn->SetTag( tag ); + pvectReturn->SetPhysicalType( typePhysical ); + pcoll->Add( pvectReturn ); + } + } + } + + return pvectReturn; + } diff --git a/LFtid1056/pqdif/include/rec_base.h b/LFtid1056/pqdif/include/rec_base.h new file mode 100644 index 0000000..5a79655 --- /dev/null +++ b/LFtid1056/pqdif/include/rec_base.h @@ -0,0 +1,99 @@ +/* +** Base class for PQDIF records; pure virtual. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_base.h $ +** Last modified: $Modtime: 2/05/98 1:53p $ +** Last modified by: $Author: Rob $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_base.h $ +** VCS revision: $Revision: 4 $ +*/ + +// Forward-declare these items +class CPQDIF_StreamIO; + +class CPQDIF_E_Collection; +class CPQDIF_E_Scalar; +class CPQDIF_E_Vector; + +union PQDIFValue; + +class CPQDIFRecord + { + public: + CPQDIFRecord() {} + virtual ~CPQDIFRecord() {} + + // Operations + public: + virtual bool ReadHeader( CPQDIF_StreamIO * pstream ) = 0; + virtual bool ReadBody( CPQDIF_StreamIO * pstream ) = 0; + + virtual bool WriteHeader( CPQDIF_StreamIO * pstream ) = 0; + virtual bool WriteBody( CPQDIF_StreamIO * pstream ) = 0; + + // Attributes + public: + virtual bool HeaderGetPos( LINKABS4& pos ) const = 0; + virtual bool HeaderSetPos( LINKABS4 pos ) = 0; + virtual bool HeaderGetTag( GUID& tagRecord ) const = 0; + virtual bool HeaderSetTag( GUID tagRecord ) = 0; + virtual bool HeaderGetSize( SIZE4& sizeHeader, SIZE4& sizeBody ) const = 0; + virtual bool HeaderSetSize( SIZE4 sizeHeader, SIZE4 sizeBody ) = 0; + virtual bool HeaderGetChecksum( UINT& checksum ) const = 0; + virtual bool HeaderSetChecksum( UINT checksum ) = 0; + virtual bool HeaderGetPosNextRecord( LINKABS4& pos ) const = 0; + virtual bool HeaderSetPosNextRecord( LINKABS4 pos ) = 0; + virtual CPQDIF_E_Collection * GetMainCollection( void ) const = 0; + virtual bool SetMainCollection( CPQDIF_E_Collection * collMain ) = 0; + virtual bool GetChanged( void ) = 0; + virtual void SetChanged( bool changed ) = 0; + + // Static functions (do not affect--or even require--an object) + public: + static CPQDIF_E_Collection * FindCollectionInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag + ); + static CPQDIF_E_Scalar * FindScalarInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag + ); + static bool GetScalarValueInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag, + UINT4 typePhysical, + PQDIFValue& value + ); + static CPQDIF_E_Vector * FindVectorInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag + ); + + static CPQDIF_E_Scalar * FindOrCreateScalarInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag, + UINT4 typePhysical + ); + static CPQDIF_E_Vector * FindOrCreateVectorInCollection + ( + CPQDIF_E_Collection * pcoll, + const GUID& tag, + UINT4 typePhysical + ); + + // Implementation + protected: + // None; pure virtual base class. + + // Member data + protected: + // None; pure virtual base class. + }; + diff --git a/LFtid1056/pqdif/include/rec_container.cpp b/LFtid1056/pqdif/include/rec_container.cpp new file mode 100644 index 0000000..06834ea --- /dev/null +++ b/LFtid1056/pqdif/include/rec_container.cpp @@ -0,0 +1,211 @@ +/* +** CPQDIF_R_Container class. Implements a PQDIF record "wrapper" for the +** data source record. You can cast a standard record object to this class. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_container.cpp $ +** Last modified: $Modtime: 7/07/99 8:11p $ +** Last modified by: $Author: Erich $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/rec_container.cpp $ +** VCS revision: $Revision: 2 $ +*/ +#include "PQDIF_classes.h" + + +// Operations + +bool CPQDIF_R_Container::GetCompressionInfo + ( + UINT4& styleComp, // Compression style (output) + UINT4& algComp // Compression algorithm (output) + ) +{ + bool status = false; + GUID tagRecord; + PQDIFValue value; + + // Verify that the record has the right header tag + status = HeaderGetTag( tagRecord ); + if( status && PQDIF_IsEqualGUID( tagRecord, tagContainer) && m_pcollMain ) + { + // It's the right type of record. + // + status = GetScalarValueInCollection( m_pcollMain, + tagCompressionStyleID, ID_PHYS_TYPE_UNS_INTEGER4, value ); + + if( status ) + { + // We got compression style. + styleComp = value.uint4; + + // Now try to get compression algorithm + status = GetScalarValueInCollection( m_pcollMain, + tagCompressionAlgorithmID, ID_PHYS_TYPE_UNS_INTEGER4, value ); + if( status ) + { + // We got compression algorithm. All done. + algComp = value.uint4; + } + } + } + + return status; +} + + +bool CPQDIF_R_Container::SetInfo + ( + const char * language, + const char * title, + const char * subject, + const char * author, + const char * keywords, + const char * comments, + const char * lastSavedBy, + const char * application, + const char * security, + const char * owner, + const char * copyright, + const char * trademarks, + const char * notes + ) + { + bool rc = false; + + if( m_pcollMain ) + { + // Add string entries + m_pcollMain->SetVectorString( tagLanguage, language ); + m_pcollMain->SetVectorString( tagTitle, title ); + m_pcollMain->SetVectorString( tagSubject, subject ); + m_pcollMain->SetVectorString( tagAuthor, author ); + m_pcollMain->SetVectorString( tagKeywords, keywords ); + m_pcollMain->SetVectorString( tagComments, comments ); + m_pcollMain->SetVectorString( tagLastSavedBy, lastSavedBy ); + m_pcollMain->SetVectorString( tagApplication, application ); + m_pcollMain->SetVectorString( tagSecurity, security ); + + m_pcollMain->SetVectorString( tagOwner, owner ); + m_pcollMain->SetVectorString( tagCopyright, copyright ); + m_pcollMain->SetVectorString( tagTrademarks, trademarks ); + + m_pcollMain->SetVectorString( tagNotes, notes ); + + + rc = true; + } + + return rc; + } + + +bool CPQDIF_R_Container::SetInfo1 + ( + const char * language, + const char * title, + const char * subject, + const char * author, + const char * keywords, + const char * comments, + const char * lastSavedBy, + const char * application, + const char * security, + const char * owner, + const char * copyright, + const char * trademarks, + const char * notes, + const char * ApplicationVersion, + const char * SystemName, + const char * SystemVersion + ) + { + bool rc = false; + + if( m_pcollMain ) + { + // Add string entries + m_pcollMain->SetVectorString( tagLanguage, language ); + m_pcollMain->SetVectorString( tagTitle, title ); + m_pcollMain->SetVectorString( tagSubject, subject ); + m_pcollMain->SetVectorString( tagAuthor, author ); + m_pcollMain->SetVectorString( tagKeywords, keywords ); + m_pcollMain->SetVectorString( tagComments, comments ); + m_pcollMain->SetVectorString( tagLastSavedBy, lastSavedBy ); + m_pcollMain->SetVectorString( tagApplication, application ); + m_pcollMain->SetVectorString( tagSecurity, security ); + + m_pcollMain->SetVectorString( tagOwner, owner ); + m_pcollMain->SetVectorString( tagCopyright, copyright ); + m_pcollMain->SetVectorString( tagTrademarks, trademarks ); + + m_pcollMain->SetVectorString( tagNotes, notes ); + + m_pcollMain->SetVectorString( tagApplicationVersion, ApplicationVersion ); + m_pcollMain->SetVectorString( tagSystemName, SystemName ); + m_pcollMain->SetVectorString( tagSystemVersion, SystemVersion ); + rc = true; + } + + return rc; + } + +bool CPQDIF_R_Container::GetTagFileName(string& strFileName) +{ + bool status = FALSE; + + CPQDIF_E_Collection * pcollMain = m_pcollMain; + CPQDIF_E_Vector * pvect; + + if( pcollMain ) + { + // Find strings + pvect = FindVectorInCollection( pcollMain, tagFileName ); + if( pvect ) pvect->GetValues( strFileName ); + + status = TRUE; + + } + + return status; +} + +bool CPQDIF_R_Container::SetTimeCreationAndTimeLastSaved +( + const TIMESTAMPPQDIF& timeCreation, + const TIMESTAMPPQDIF& timeLastSaved +) +{ + bool status = false; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + // Init + if (m_pcollMain == NULL) + return false; + + // First, find (or create) the trigger method + psc = FindOrCreateScalarInCollection(m_pcollMain, + tagCreation, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set its value + if (psc) + { + status = psc->SetValueTimeStamp(timeCreation); + } + + // Set the time it was triggered + if (status) + { + status = false; + psc = FindOrCreateScalarInCollection(m_pcollMain, + tagLastSaved, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set value + if (psc) + { + status = psc->SetValueTimeStamp(timeLastSaved); + } + } + + return status; +} \ No newline at end of file diff --git a/LFtid1056/pqdif/include/rec_container.h b/LFtid1056/pqdif/include/rec_container.h new file mode 100644 index 0000000..d5900ea --- /dev/null +++ b/LFtid1056/pqdif/include/rec_container.h @@ -0,0 +1,76 @@ +/* +** class CPQDIF_R_Container +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_container.h $ +** Last modified: $Modtime: 7/07/99 8:12p $ +** Last modified by: $Author: Erich $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/rec_container.h $ +** VCS revision: $Revision: 3 $ +*/ + +class CPQDIF_R_Container : public CPQDIF_R_General + { + public: + CPQDIF_R_Container(); + virtual ~CPQDIF_R_Container(); + + // Operations + public: + bool GetTagFileName(string& strFileName); + bool GetInfo(); + + bool SetInfo + ( + const char * language, + const char * title, + const char * subject, + const char * author, + const char * keywords, + const char * comments, + const char * lastSavedBy, + const char * application, + const char * security, + const char * owner, + const char * copyright, + const char * trademarks, + const char * notes + ); + + bool SetInfo1 + ( + const char * language, + const char * title, + const char * subject, + const char * author, + const char * keywords, + const char * comments, + const char * lastSavedBy, + const char * application, + const char * security, + const char * owner, + const char * copyright, + const char * trademarks, + const char * notes, + const char * ApplicationVersion, + const char * SystemName, + const char * SystemVersion + ); + + bool GetCompressionInfo + ( + UINT4& styleComp, // Compression style (output) + UINT4& algComp // Compression algorithm (output) + ); + + bool SetTimeCreationAndTimeLastSaved + ( + const TIMESTAMPPQDIF& timeCreation, + const TIMESTAMPPQDIF& timeLastSaved + ); + // Local data + private: + + }; + diff --git a/LFtid1056/pqdif/include/rec_datasource.cpp b/LFtid1056/pqdif/include/rec_datasource.cpp new file mode 100644 index 0000000..fa59d98 --- /dev/null +++ b/LFtid1056/pqdif/include/rec_datasource.cpp @@ -0,0 +1,887 @@ +/* +** CPQDIF_R_DataSource class. Implements a PQDIF record "wrapper" for the +** data source record. You can cast a standard record object to this class. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_datasource.cpp $ +** Last modified: $Modtime: 5/25/99 10:56a $ +** Last modified by: $Author: Jack $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_datasource.cpp $ +** VCS revision: $Revision: 14 $ +*/ +#include "PQDIF_classes.h" + + +// Operations + +bool CPQDIF_R_DataSource::GetInfo + ( + GUID& idDataSourceType, + GUID& idVendor, + GUID& idEquipment, + string& serialNumber, + string& version, + string& name, + string& owner, + string& location, + string& timeZone + ) +{ + bool status = FALSE; + + CPQDIF_E_Collection * pcollMain = m_pcollMain; + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + if( pcollMain ) + { + // Find GUIDs + psc = FindScalarInCollection( pcollMain, tagDataSourceTypeID ); + if( psc ) psc->GetValueGUID( idDataSourceType ); + psc = FindScalarInCollection( pcollMain, tagVendorID ); + if( psc ) psc->GetValueGUID( idVendor ); + psc = FindScalarInCollection( pcollMain, tagEquipmentID ); + if( psc ) psc->GetValueGUID( idEquipment ); + + // Find strings + pvect = FindVectorInCollection( pcollMain, tagSerialNumberDS ); + if( pvect ) pvect->GetValues( serialNumber ); + pvect = FindVectorInCollection( pcollMain, tagVersionDS ); + if( pvect ) pvect->GetValues( version ); + pvect = FindVectorInCollection( pcollMain, tagNameDS ); + if( pvect ) pvect->GetValues( name ); + pvect = FindVectorInCollection( pcollMain, tagOwnerDS ); + if( pvect ) pvect->GetValues( owner ); + pvect = FindVectorInCollection( pcollMain, tagLocationDS ); + if( pvect ) pvect->GetValues( location ); + pvect = FindVectorInCollection( pcollMain, tagTimeZoneDS ); + if( pvect ) pvect->GetValues( timeZone ); + + status = TRUE; + } + + return status; +} + + +long CPQDIF_R_DataSource::GetCountChannelDefns( void ) +{ + long count = 0; + CPQDIF_E_Collection * pcollDefns; + + pcollDefns = GetChannelDefns(); + if( pcollDefns ) + { + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcollDefns->GetTag() ); + + count = pcollDefns->GetCount(); + } + + return count; +} + +long CPQDIF_R_DataSource::GetCountSeriesDefns( int idxChannelDefn ) +{ + long count = 0; + CPQDIF_E_Collection * pcolOneChannelDefn; + CPQDIF_E_Collection * pcollSeriesDefns; + + // Find the one channel defn we're looking for + pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn ); + if( pcolOneChannelDefn ) + { + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcolOneChannelDefn->GetTag() ); + + // Find the series defns for this channel defn + pcollSeriesDefns = GetSeriesDefns( pcolOneChannelDefn ); + if( pcollSeriesDefns ) + { + // Get the count! + count = pcollSeriesDefns->GetCount(); + } + } + + return count; +} + + +bool CPQDIF_R_DataSource::GetChannelDefnInfo + ( + long idxChannelDefn, + string& name, + UINT4& idPhase, + GUID& idQuantityType, + UINT4& idQuantityMeasured + ) +{ + bool status = FALSE; + + CPQDIF_E_Collection * pcolOneChannelDefn; + + // Elements we need + CPQDIF_E_Vector * pvecName; + CPQDIF_E_Scalar * pscPhaseID; + CPQDIF_E_Scalar * pscQuantityID; + + // Init + name = ""; + idPhase = ID_PHASE_NONE; // default + idQuantityType = ID_QT_WAVEFORM; // default + idQuantityMeasured = ID_QM_NONE; // default + + // Find the one channel defn we're looking for + pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn ); + if( pcolOneChannelDefn ) + { + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcolOneChannelDefn->GetTag() ); + + pvecName = FindVectorInCollection( pcolOneChannelDefn, tagChannelName ); // optional + if( pvecName ) + { + pvecName->GetValues( name ); + } + pscPhaseID = FindScalarInCollection( pcolOneChannelDefn, tagPhaseID ); + if( pscPhaseID ) + { + // Required; check the return value + status = pscPhaseID->GetValueUINT4( idPhase ); + } + pscQuantityID = FindScalarInCollection( pcolOneChannelDefn, tagQuantityTypeID ); + if( status && pscQuantityID ) + { + // Required; check the return value + status = pscQuantityID->GetValueGUID( idQuantityType ); + } + pscQuantityID = FindScalarInCollection( pcolOneChannelDefn, tagQuantityMeasuredID ); + if( status && pscQuantityID ) + { + // Required; check the return value + status = pscQuantityID->GetValueUINT4( idQuantityMeasured ); + } + } + + return status; +} + + +bool CPQDIF_R_DataSource::GetChannelPrimarySeries + ( + long idxChannelDefn, + long& idxPrimarySeries + ) +{ + bool status = FALSE; + + CPQDIF_E_Collection * pcolOneChannelDefn; + + // Elements we need + CPQDIF_E_Scalar * psc; + UINT4 value; + + // Find the one channel defn we're looking for + pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn ); + if( pcolOneChannelDefn ) + { + psc = FindScalarInCollection( pcolOneChannelDefn, tagPrimarySeriesIdx ); + if( psc ) + { + // Required; check the return value + status = psc->GetValueUINT4( value ); + if( status ) + idxPrimarySeries = (long) value; + } + } + + return status; +} + + +bool CPQDIF_R_DataSource::GetSeriesDefnInfo + ( + long idxChannelDefn, + long idxSeriesDefn, + UINT4& idQuantityUnits, + GUID& idValueType, + GUID& idQuantityCharacteristic, + UINT4& idStorageMethod + ) +{ + bool status = FALSE; + + CPQDIF_E_Collection * pcolOneSeriesDefn; + CPQDIF_E_Scalar * pscalar; + + // Init + idQuantityUnits = ID_QU_NONE; + idValueType = ID_SERIES_VALUE_TYPE_VAL; + idStorageMethod = ID_SERIES_METHOD_VALUES; + + // Find the one channel defn we're looking for + pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcolOneSeriesDefn->GetTag() ); + + // These are all required; check the return values + status = TRUE; + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagQuantityUnitsID ); + if( status && pscalar ) + { + status = pscalar->GetValueUINT4( idQuantityUnits ); + } + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagValueTypeID ); + if( status && pscalar ) + { + status = pscalar->GetValueGUID( idValueType ); + } + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagQuantityCharacteristicID ); + if( status && pscalar ) + { + status = pscalar->GetValueGUID( idQuantityCharacteristic ); + } + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagStorageMethodID ); + if( status && pscalar ) + { + status = pscalar->GetValueUINT4( idStorageMethod ); + } + } + + return status; +} + + +// Protected stuff + +CPQDIF_E_Collection * CPQDIF_R_DataSource::GetChannelDefns( void ) +{ + CPQDIF_E_Collection * pcollDefns = NULL; + + // Create the collection if it does not yet exist. + if( m_pcollMain ) + { + pcollDefns = FindCollectionInCollection( m_pcollMain, tagChannelDefns ); + if( !pcollDefns ) + { + pcollDefns = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollDefns ) + { + pcollDefns->SetTag( tagChannelDefns ); + m_pcollMain->Add( pcollDefns ); + } + } + } + + return pcollDefns; +} + + +CPQDIF_E_Collection * CPQDIF_R_DataSource::GetOneChannelDefn + ( + long idxChannelDefn + ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolInstances = GetChannelDefns(); + CPQDIF_Element * pel; + + if( pcolInstances ) + { + pel = pcolInstances->GetElement( idxChannelDefn ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION + && PQDIF_IsEqualGUID( pel->GetTag(), tagOneChannelDefn ) ) + { + pcolReturn = (CPQDIF_E_Collection *) pel; + } + } + } + + return pcolReturn; +} + + +CPQDIF_E_Collection * CPQDIF_R_DataSource::GetSeriesDefns + ( + CPQDIF_E_Collection * pcolOneChannelDefn + ) +{ + return FindCollectionInCollection( pcolOneChannelDefn, tagSeriesDefns ); +} + + +CPQDIF_E_Collection * CPQDIF_R_DataSource::GetOneSeriesDefn + ( + CPQDIF_E_Collection * pcolOneChannelDefn, + long idxSeriesDefn + ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolSeriesDefns = NULL; + CPQDIF_Element * pel; + + if( pcolOneChannelDefn ) + { + // Grab the series defns collection for this channels defn. + pcolSeriesDefns = GetSeriesDefns( pcolOneChannelDefn ); + if( pcolSeriesDefns ) + { + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcolSeriesDefns->GetTag() ); + + // Find the specific series defn + pel = pcolSeriesDefns->GetElement( idxSeriesDefn ); + if( pel ) + { + pname = theInfo.GetNameOfTag( pel->GetTag() ); + if( pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION + && PQDIF_IsEqualGUID( pel->GetTag(), tagOneSeriesDefn ) ) + { + // Return it! + pcolReturn = (CPQDIF_E_Collection *) pel; + } + } + } + } + + return pcolReturn; +} + + +CPQDIF_E_Collection * CPQDIF_R_DataSource::GetOneSeriesDefn + ( + long idxChannelDefn, + long idxSeriesDefn + ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolOneChannel = NULL; + + pcolOneChannel = GetOneChannelDefn( idxChannelDefn ); + if( pcolOneChannel ) + { + pcolReturn = GetOneSeriesDefn( pcolOneChannel, idxSeriesDefn ); + } + + return pcolReturn; +} + + +long CPQDIF_R_DataSource::AddChannelDefn + ( + const char * name, + UINT4 idPhase, + const GUID& idQuantityType + ) +{ + long idxNew = -1; + + CPQDIF_E_Collection * pcollDefns; + CPQDIF_E_Collection * pcollOne; + CPQDIF_E_Collection * pcollSeriesDefns; + + pcollDefns = GetChannelDefns(); + if( pcollDefns ) + { + // Get the new index + idxNew = GetCountChannelDefns(); + + // Create the new channel def'n + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollOne ) + { + pcollOne->SetTag( tagOneChannelDefn ); + + // Stuff in the information... + pcollOne->SetVectorString( tagChannelName, name ); + pcollOne->SetScalarUINT4( tagPhaseID, idPhase ); + pcollOne->SetScalarGUID( tagQuantityTypeID, idQuantityType ); + + // Also add an empty collection for the series definitions + pcollSeriesDefns = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollSeriesDefns ) + { + pcollSeriesDefns->SetTag( tagSeriesDefns ); + pcollOne->Add( pcollSeriesDefns ); + } + } + + // Add it! + pcollDefns->Add( pcollOne ); + } + + return idxNew; +} + +long CPQDIF_R_DataSource::AddChannelDefn2 + ( + const char * name, + UINT4 idPhase, + UINT4 idQM, + const GUID& idQuantityType + ) +{ + long idxNew = -1; + + CPQDIF_E_Collection * pcollDefns; + CPQDIF_E_Collection * pcollOne; + CPQDIF_E_Collection * pcollSeriesDefns; + + pcollDefns = GetChannelDefns(); + if( pcollDefns ) + { + // Get the new index + idxNew = GetCountChannelDefns(); + + // Create the new channel def'n + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollOne ) + { + pcollOne->SetTag( tagOneChannelDefn ); + + // Stuff in the information... + pcollOne->SetVectorString( tagChannelName, name ); + pcollOne->SetScalarUINT4( tagPhaseID, idPhase ); + pcollOne->SetScalarUINT4( tagQuantityMeasuredID, idQM ); + pcollOne->SetScalarGUID( tagQuantityTypeID, idQuantityType ); + + // Also add an empty collection for the series definitions + pcollSeriesDefns = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollSeriesDefns ) + { + pcollSeriesDefns->SetTag( tagSeriesDefns ); + pcollOne->Add( pcollSeriesDefns ); + } + } + + // Add it! + pcollDefns->Add( pcollOne ); + } + + return idxNew; +} + +long CPQDIF_R_DataSource::AddSeriesDefn + ( + long idxChannelDefn, + UINT4 idQuantityUnits, + const GUID idValueType, + UINT4 idStorageMethod + ) +{ + long idxNew = -1; + + CPQDIF_E_Collection * pcolOneChannelDefn; + CPQDIF_E_Collection * pcollSeriesDefns; + CPQDIF_E_Collection * pcollOne; + + // Find the one channel defn we're looking for + pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn ); + if( pcolOneChannelDefn ) + { +#ifdef _DEBUG + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcolOneChannelDefn->GetTag() ); +#endif + + // Find the series defns for this channel defn + pcollSeriesDefns = GetSeriesDefns( pcolOneChannelDefn ); + if( pcollSeriesDefns ) + { + // Get the new index + idxNew = GetCountSeriesDefns( idxChannelDefn ); + + // Create the new series def'n + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollOne->SetTag( tagOneSeriesDefn ); + + // Stuff in the information... + pcollOne->SetScalarUINT4( tagQuantityUnitsID, idQuantityUnits ); + pcollOne->SetScalarGUID( tagValueTypeID, idValueType ); + pcollOne->SetScalarUINT4( tagStorageMethodID, idStorageMethod ); + + // Add it! + pcollSeriesDefns->Add( pcollOne ); + } + } + + return idxNew; +} + + +long CPQDIF_R_DataSource::AddSeriesDefn2 + ( + long idxChannelDefn, + UINT4 idQuantityUnits, + const GUID idValueType, + const GUID idCharacteristicType, + UINT4 idStorageMethod + ) +{ + long idxNew = -1; + + CPQDIF_E_Collection * pcolOneChannelDefn; + CPQDIF_E_Collection * pcollSeriesDefns; + CPQDIF_E_Collection * pcollOne; + + // Find the one channel defn we're looking for + pcolOneChannelDefn = GetOneChannelDefn( idxChannelDefn ); + if( pcolOneChannelDefn ) + { +#ifdef _DEBUG + // Is this the right tag? + const char * pname; + pname = theInfo.GetNameOfTag( pcolOneChannelDefn->GetTag() ); +#endif + + // Find the series defns for this channel defn + pcollSeriesDefns = GetSeriesDefns( pcolOneChannelDefn ); + if( pcollSeriesDefns ) + { + // Get the new index + idxNew = GetCountSeriesDefns( idxChannelDefn ); + + // Create the new series def'n + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollOne->SetTag( tagOneSeriesDefn ); + + // Stuff in the information... + pcollOne->SetScalarUINT4( tagQuantityUnitsID, idQuantityUnits ); + pcollOne->SetScalarGUID( tagQuantityCharacteristicID, idCharacteristicType ); + pcollOne->SetScalarGUID( tagValueTypeID, idValueType ); + pcollOne->SetScalarUINT4( tagStorageMethodID, idStorageMethod ); + + // Add it! + pcollSeriesDefns->Add( pcollOne ); + } + } + + return idxNew; +} + +bool CPQDIF_R_DataSource::GetSeriesDefnNominal + ( + long idxChannelDefn, + long idxSeriesDefn, + double & dNominal + ) + { + bool status = false; + + CPQDIF_E_Collection * pcolOneSeriesDefn; + CPQDIF_E_Scalar * pscalar; + + // Initialize + dNominal = -1.0; + + // Find the one channel defn we're looking for + pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + // Is this the right tag? + // + // Rob does this call over the place but does not + // do anything with the result. Why is it here? - EWG + // +// const char * pname; +// pname = theInfo.GetNameOfTag( pcolOneSeriesDefn->GetTag() ); + + // check the return values + status = true; + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagSeriesNominalQuantity ); + if( status && pscalar ) + { + status = pscalar->GetValueREAL8( dNominal ); + } + } + + return status; + } + + +bool CPQDIF_R_DataSource::GetSeriesDefnPrecisionAndResolution + ( + long idxChannel, + long idxSeries, + UINT4 & uPrecision, + double & dResolution + ) + +{ + CPQDIF_E_Collection * pcolOneSeriesDefn; + CPQDIF_E_Scalar * pscalar; + bool status = false; + + // Initialize + uPrecision = -1; + dResolution = 0.0; + + // Find the one channel defn we're looking for + pcolOneSeriesDefn = GetOneSeriesDefn( idxChannel, idxSeries ); + if( pcolOneSeriesDefn ) + { + + // check the return values + status = true; + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagQuantitySignificantDigitsID ); + if( status && pscalar ) + { + status = pscalar->GetValueUINT4( uPrecision ); + } + + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagQuantityResolutionID ); + if( pscalar ) + { + pscalar->GetValueREAL8( dResolution ); + } + } + + return status; + } + + + +bool CPQDIF_R_DataSource::SetSeriesDefnNominal + ( + long idxChannelDefn, + long idxSeriesDefn, + double dNominal + ) + { + bool status = false; + + CPQDIF_E_Collection * pcolOneSeriesDefn; + CPQDIF_E_Scalar * pscalar; + + // Find the one channel defn we're looking for + pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + // Is this the right tag? + // + // Rob does this call over the place but does not + // do anything with the result. Why is it here? - EWG + // +// const char * pname; +// pname = theInfo.GetNameOfTag( pcolOneSeriesDefn->GetTag() ); + + status = true; + // + // + // See if scalar already present + // + pscalar = FindScalarInCollection( pcolOneSeriesDefn, tagSeriesNominalQuantity ); + if( pscalar ) + { + // + // + // Is there so set new value + // + status = pscalar->SetValueREAL8( dNominal ); + } + else + { + // + // + // Is not there so add scalar + // + pscalar = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( pscalar ) + { + pscalar->SetTag( tagSeriesNominalQuantity ); + status = pscalar->SetValueREAL8( dNominal ); + pcolOneSeriesDefn->Add( pscalar ); + } + } +#ifdef zap + // + // + // The following line does the same thing as the several + // lines above but without error checking. + // + // The third parameter allows replacement of tag + // value if tag already present. If tag not present, + // it is added and the value set. + // The + // + pcolOneSeriesDefn->SetScalarREAL8( tagSeriesNominalQuantity, dNominal, true); +#endif + } + + return status; + } + +bool CPQDIF_R_DataSource::SetSeriesDefnPrefix + ( + long idxChannelDefn, + long idxSeriesDefn, + long idPrefix + ) + { + bool status = false; + + // Find the one channel defn we're looking for + CPQDIF_E_Collection * pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + status = true; + // + // + // The third parameter allows replacement of tag + // value if tag already present. If tag not present, + // it is added and the value set. + // The + // + pcolOneSeriesDefn->SetScalarUINT4( tagHintGreekPrefixID, idPrefix, true); + } + + return status; + } + +bool CPQDIF_R_DataSource::SetSeriesDefnUnits + ( + long idxChannelDefn, + long idxSeriesDefn, + long idUnits + ) + { + bool status = false; + + // Find the one channel defn we're looking for + CPQDIF_E_Collection * pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + status = true; + // + // + // The third parameter allows replacement of tag + // value if tag already present. If tag not present, + // it is added and the value set. + // The + // + pcolOneSeriesDefn->SetScalarUINT4( tagHintPreferredUnitsID, idUnits, true); + } + + return status; + } + +bool CPQDIF_R_DataSource::SetSeriesDefnDisplay + ( + long idxChannelDefn, + long idxSeriesDefn, + long idDisplay + ) + { + bool status = false; + + // Find the one channel defn we're looking for + CPQDIF_E_Collection * pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + status = true; + // + // + // The third parameter allows replacement of tag + // value if tag already present. If tag not present, + // it is added and the value set. + // The + // + pcolOneSeriesDefn->SetScalarUINT4( tagHintDefaultDisplayID, idDisplay, true); + } + + return status; + } + +bool CPQDIF_R_DataSource::SetSeriesDefnDigits + ( + long idxChannelDefn, + long idxSeriesDefn, + long idDigits + ) + { + bool status = false; + + // Find the one channel defn we're looking for + CPQDIF_E_Collection * pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + status = true; + // + // + // The third parameter allows replacement of tag + // value if tag already present. If tag not present, + // it is added and the value set. + // The + // + pcolOneSeriesDefn->SetScalarUINT4( tagQuantitySignificantDigitsID, idDigits, true); + } + + return status; + } + + +bool CPQDIF_R_DataSource::SetSeriesDefnResolution + ( + long idxChannelDefn, + long idxSeriesDefn, + double dRes + ) + { + bool status = false; + + // Find the one channel defn we're looking for + CPQDIF_E_Collection * pcolOneSeriesDefn = GetOneSeriesDefn( idxChannelDefn, idxSeriesDefn ); + if( pcolOneSeriesDefn ) + { + status = true; + // + // + // The third parameter allows replacement of tag + // value if tag already present. If tag not present, + // it is added and the value set. + // The + // + pcolOneSeriesDefn->SetScalarREAL8( tagQuantityResolutionID, dRes, true); + } + + return status; + } + +bool CPQDIF_R_DataSource::SettagEffective +( + const TIMESTAMPPQDIF& timeEffective +) +{ + + bool status = false; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + // Init + if (m_pcollMain == NULL) + return false; + // First, find (or create) the trigger method + psc = FindOrCreateScalarInCollection(m_pcollMain, + tagEffective, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set its value + if (psc) + { + status = psc->SetValueTimeStamp(timeEffective); + } + + + return status; +} + diff --git a/LFtid1056/pqdif/include/rec_datasource.h b/LFtid1056/pqdif/include/rec_datasource.h new file mode 100644 index 0000000..ed2ebc0 --- /dev/null +++ b/LFtid1056/pqdif/include/rec_datasource.h @@ -0,0 +1,146 @@ +// File name: $Workfile: rec_datasource.h $ +// Last modified: $Modtime: 5/25/99 10:52a $ +// Last modified by: $Author: Jack $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_datasource.h $ +// VCS revision: $Revision: 16 $ + +class CPQDIF_R_DataSource : public CPQDIF_R_General + { + public: + CPQDIF_R_DataSource(); + //CPQDIF_R_DataSource( CPQDIFRecord& record ); + virtual ~CPQDIF_R_DataSource(); + + // Operations + public: + + // Attributes + public: + // Read functions + bool GetInfo + ( + GUID& idDataSourceType, + GUID& idVendor, + GUID& idEquipment, + string& serialNumber, + string& version, + string& name, + string& owner, + string& location, + string& timeZone + ); + long GetCountChannelDefns( void ); + long GetCountSeriesDefns( int idxChannelDefn ); + bool GetChannelDefnInfo + ( + long idxChannelDefn, + string& name, + UINT4& idPhase, + GUID& idQuantityType, + UINT4& idQuantityMeasured + ); + bool GetChannelPrimarySeries + ( + long idxChannel, + long& idxPrimarySeries + ); + bool GetSeriesDefnInfo + ( + long idxChannelDefn, + long idxSeriesDefn, + UINT4& idQuantityUnits, + GUID& idValueType, + GUID& idQuantityCharacteristic, + UINT4& idStorageMethod + ); + + // Write functions + long AddChannelDefn + ( + const char * name, + UINT4 idPhase, + const GUID& idQuantityType + ); + long AddChannelDefn2 + ( + const char * name, + UINT4 idPhase, + UINT4 idQM, + const GUID& idQuantityType + ); + long AddSeriesDefn + ( + long idxChannelDefn, + UINT4 idQuantityUnits, + const GUID idValueType, + UINT4 idStorageMethod + ); + + long AddSeriesDefn2 + ( + long idxChannelDefn, + UINT4 idQuantityUnits, + const GUID idValueType, + const GUID idCharacteristicType, + UINT4 idStorageMethod + ); + + bool SetSeriesDefnNominal(long idxChannelDefn, long idxSeriesDefn, double dNominal); + bool GetSeriesDefnNominal(long idxChannelDefn, long idxSeriesDefn, double & dNominal); + bool GetSeriesDefnPrecisionAndResolution + ( + long idxChannel, + long idxSeries, + UINT4 & uPrecision, + double & dResolution + ); + + bool SetSeriesDefnPrefix(long idxChannelDefn, long idxSeriesDefn, long idPrefix); + bool SetSeriesDefnDisplay(long idxChannelDefn, long idxSeriesDefn, long idDisplay); + bool SetSeriesDefnUnits(long idxChannelDefn, long idxSeriesDefn, long idUnits); + bool SetSeriesDefnResolution(long idxChannelDefn, long idxSeriesDefn, double dRes); + bool SetSeriesDefnDigits(long idxChannelDefn, long idxSeriesDefn, long idDigits); + + bool SetEffective (const TIMESTAMPPQDIF& timeEffective) + { + return SetTimeInMainCollection(tagEffective, timeEffective); + } + bool GetEffective (TIMESTAMPPQDIF& timeEffective) + { + return GetTimeInMainCollection(tagEffective, timeEffective); + } + + bool SettagEffective + ( + const TIMESTAMPPQDIF& timeEffective + ); + + + // Internal functions + public: + CPQDIF_E_Collection * GetChannelDefns( void ); + CPQDIF_E_Collection * GetOneChannelDefn + ( + long idxChannelDefn + ); + CPQDIF_E_Collection * GetSeriesDefns + ( + CPQDIF_E_Collection * pcolChannelDefns + ); + CPQDIF_E_Collection * GetOneSeriesDefn + ( + CPQDIF_E_Collection * pcolChannelSeriesDefns, + long idxSeriesDefn + ); + CPQDIF_E_Collection * GetOneSeriesDefn + ( + long idxChannelDefn, + long idxSeriesDefn + ); + + // Local data + private: + + }; + diff --git a/LFtid1056/pqdif/include/rec_general.cpp b/LFtid1056/pqdif/include/rec_general.cpp new file mode 100644 index 0000000..6ffe953 --- /dev/null +++ b/LFtid1056/pqdif/include/rec_general.cpp @@ -0,0 +1,413 @@ +/* +** CPQDIF_R_General class. The base class for a PQDIF record. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_general.cpp $ +** Last modified: $Modtime: 11/14/00 8:41a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_general.cpp $ +** VCS revision: $Revision: 11 $ +*/ +#include "PQDIF_classes.h" + + + +// Construction +// ============ + +CPQDIF_R_General::CPQDIF_R_General() +{ + // Init header structure + memset( &m_headerRecord, 0, sizeof( m_headerRecord ) ); + m_headerRecord.guidRecordSignature = guidRecordSignaturePQDIF; + m_headerRecord.tagRecordType = tagBlank; + m_headerRecord.sizeHeader = sizeof( m_headerRecord ); + // sizeData; + // linkNextRecord; + // checksum; + // auiReserved[ 4 ]; + + m_posThisRecord = 0; + m_pcollMain = NULL; // Body not read + + m_changed = false; +} + + +CPQDIF_R_General::~CPQDIF_R_General() +{ + if( m_pcollMain ) + delete m_pcollMain; +} + + +bool CPQDIF_R_General::ReadHeader( CPQDIF_StreamIO * pstream ) + { + bool status = false; + BYTE * buffer = NULL; + int sizeActual; + int pos; + + // Init header structure + memset( &m_headerRecord, 0, sizeof( m_headerRecord ) ); + + status = pstream->GetPos( pos ); + if( status ) + { + m_posThisRecord = (LINKABS4) pos; + buffer = pstream->ReadBlock( sizeof( m_headerRecord ), sizeActual ); + //ASSERT( sizeActual == sizeof( m_headerRecord ) ); + } + + if( status && buffer) + { + m_headerRecord = *( (c_record_mainheader *) buffer ); + + // Validate the signature + if( !PQDIF_IsEqualGUID( m_headerRecord.guidRecordSignature, guidRecordSignaturePQDIF ) ) + { + status = FALSE; + } + } + return status; + } + + +bool CPQDIF_R_General::ReadBody( CPQDIF_StreamIO * pstream ) +{ + bool status = false; + PQController controller; + + // Have we already read it? + if( m_pcollMain ) + { + status = true; + } + else + { + // Nope -- create the top-level collection + m_pcollMain = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + //ASSERT( m_pcollMain ); + if( m_pcollMain ) + { + // Link the collection to the record. + m_pcollMain->SetRecord( this ); + + // Attach the record tag to the main collection + m_pcollMain->SetTag( m_headerRecord.tagRecordType ); + + // Position us to the right place + status = pstream->SeekPos( m_posThisRecord + m_headerRecord.sizeHeader ); + if( status ) + { + int sizeActual; + BYTE * buffer; + + buffer = pstream->ReadBlock( m_headerRecord.sizeData, sizeActual ); + if( buffer && sizeActual > 0 ) + { + // Do it! + controller.ParseRecord( buffer, sizeActual, m_pcollMain ); + status = TRUE; + } + } + } + } + + return status; +} + + +bool CPQDIF_R_General::WriteHeader( CPQDIF_StreamIO * pstream ) +{ + bool status = FALSE; + SIZE4 sizeActual; + + // Just write the dern block out! + // Position us to the right place + status = pstream->SeekPos( m_posThisRecord ); + status = pstream->BeginBlock(); + if( status ) + { + status = pstream->AppendBlock( + (BYTE *) &m_headerRecord, + sizeof( m_headerRecord ) ); + status = pstream->WriteBlock( sizeActual ); + } + + return status; +} + + +bool CPQDIF_R_General::WriteBody( CPQDIF_StreamIO * pstream ) +{ + bool status = FALSE; + PQAlloc allocPQ; + long sizeTotal; + c_collection_element * aem; + + // Use the allocPQ to write out the main collection + if( m_pcollMain ) + { + long idx; + SIZE4 size; + + // Prepare + pstream->ResetChecksum(); + + // Position us to the right place + status = pstream->SeekPos( m_posThisRecord + m_headerRecord.sizeHeader ); + + aem = allocPQ.addCollection( m_pcollMain->GetCount(), idx, size ); + if( aem ) + { + status = BufferUpCollection( pstream, allocPQ, m_pcollMain, aem ); + if( status ) + { + sizeTotal = allocPQ.WriteListToStream( pstream ); + if( sizeTotal == 0 ) + status = false; + else + { + // Update header with data + m_headerRecord.sizeData = sizeTotal; + m_headerRecord.linkNextRecord = m_posThisRecord + m_headerRecord.sizeHeader + m_headerRecord.sizeData; + m_headerRecord.checksum = pstream->GetChecksum(); + } + } + } + } + + return status; +} + + +bool CPQDIF_R_General::BufferUpCollection + ( + CPQDIF_StreamIO * pstream, + PQAlloc& allocPQ, + CPQDIF_E_Collection * pcoll, + c_collection_element * aem + ) +{ + bool status = TRUE; + long idxElement; + long countElements = pcoll->GetCount(); + CPQDIF_Element * pel; + + c_collection_element * aemNew; + long typePhysical; + PQDIFValue value; + + long idx; + SIZE4 size; + + for( idxElement = 0; idxElement < countElements; idxElement++ ) + { + pel = pcoll->GetElement( idxElement ); + if( pel ) + { + switch( pel->GetElementType() ) + { + case ID_ELEMENT_TYPE_COLLECTION: + { + CPQDIF_E_Collection * pcollNext = (CPQDIF_E_Collection *) pel; + + aemNew = allocPQ.addCollection( + pcollNext->GetCount(), + idx, size, + pel->GetTag(), + aem[ idxElement ] ); + if( aemNew ) + { + status = BufferUpCollection( + pstream, + allocPQ, + pcollNext, + aemNew ); + } + } + break; + + case ID_ELEMENT_TYPE_SCALAR : + { + CPQDIF_E_Scalar * pscalar = (CPQDIF_E_Scalar *) pel; + + pscalar->GetValue( typePhysical, value ); + status = allocPQ.addScalarValue( + typePhysical, + value, + idx, size, + pscalar->GetTag(), + aem[ idxElement ] ); + } + break; + + case ID_ELEMENT_TYPE_VECTOR : + { + CPQDIF_E_Vector * pvector = (CPQDIF_E_Vector *) pel; + long count; + + pvector->GetCount( count ); + typePhysical = pvector->GetPhysicalType(); + + status = allocPQ.addVectorValue( + typePhysical, + count, + pvector->GetRawData(), + idx, size, + pvector->GetTag(), + aem[ idxElement ] ); + } + break; + + default: + break; + } + } + } + + return status; +} + + +bool CPQDIF_R_General::SetMainCollection( CPQDIF_E_Collection * collMain ) +{ + bool status = true; + + // Clear out old collection? + if( m_pcollMain ) + { + delete m_pcollMain; + m_pcollMain = NULL; + } + + if( collMain ) + { + m_pcollMain = collMain; + collMain->SetRecord( this ); + } + + return status; +} + + +bool CPQDIF_R_General::GetTimeInMainCollection (const GUID &tag, TIMESTAMPPQDIF& timeTime) + { + // Initialize + bool foundItem = false; + + memset( &timeTime, 0, sizeof( timeTime ) ); + // + // + // See if we can find the item + // + CPQDIF_E_Scalar * psc = FindScalarInCollection( m_pcollMain, tag ); + if( psc ) + { + foundItem = psc->GetValueTimeStamp( timeTime ); + } + return foundItem; + } + +bool CPQDIF_R_General::GetREAL8InMainCollection (const GUID &tag, REAL8 & dVal) + { + // Initialize + bool foundItem = false; + + dVal = 0.0; + // + // + // See if we can find the item + // + CPQDIF_E_Scalar * psc = FindScalarInCollection( m_pcollMain, tag ); + if( psc ) + { + foundItem = psc->GetValueREAL8( dVal ); + } + return foundItem; + } + + +bool CPQDIF_R_General::GetBOOL4InMainCollection (const GUID &tag, BOOL4 & bVal) + { + // Initialize + bool foundItem = false; + + bVal = false; + // + // + // See if we can find the item + // + CPQDIF_E_Scalar * psc = FindScalarInCollection( m_pcollMain, tag ); + if( psc ) + { + bool val; + foundItem = psc->GetValueBOOL4( val ); + bVal = val; + } + return foundItem; + } + +bool CPQDIF_R_General::SetTimeInMainCollection (const GUID &tag, const TIMESTAMPPQDIF& timeTime) + { + bool status = false; + + CPQDIF_E_Scalar * psc = FindOrCreateScalarInCollection( m_pcollMain, + tag, ID_PHYS_TYPE_TIMESTAMPPQDIF ); + + // Set value + PQDIFValue value; + + if( psc ) + { + value.ts = timeTime; + status = psc->SetValue( ID_PHYS_TYPE_TIMESTAMPPQDIF, value ); + } + + return status; + } + +bool CPQDIF_R_General::SetREAL8InMainCollection (const GUID &tag, const REAL8 dVal) + { + bool status = false; + + CPQDIF_E_Scalar * psc = FindOrCreateScalarInCollection( m_pcollMain, + tag, ID_PHYS_TYPE_REAL8 ); + + // Set value + PQDIFValue value; + + if( psc ) + { + value.real8 = dVal; + status = psc->SetValue( ID_PHYS_TYPE_REAL8, value ); + } + + return status; + } + +bool CPQDIF_R_General::SetBOOL4InMainCollection (const GUID &tag, const BOOL4 bVal) + { + bool status = false; + + CPQDIF_E_Scalar * psc = FindOrCreateScalarInCollection( m_pcollMain, + tag, ID_PHYS_TYPE_BOOLEAN4 ); + + // Set value + PQDIFValue value; + + if( psc ) + { + value.bool4 = bVal; + status = psc->SetValue( ID_PHYS_TYPE_BOOLEAN4, value ); + } + + return status; + } + + + + + diff --git a/LFtid1056/pqdif/include/rec_general.h b/LFtid1056/pqdif/include/rec_general.h new file mode 100644 index 0000000..a4383ad --- /dev/null +++ b/LFtid1056/pqdif/include/rec_general.h @@ -0,0 +1,138 @@ +// File name: $Workfile: rec_general.h $ +// Last modified: $Modtime: 11/13/00 3:54p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_general.h $ +// VCS revision: $Revision: 7 $ + +// Forward-declare these classes +class CPQDIF_StreamIO; + +class CPQDIF_E_Collection; +class CPQDIF_E_Scalar; +class CPQDIF_E_Vector; + +class PQAlloc; + +union PQDIFValue; + + +class CPQDIF_R_General : public CPQDIFRecord + { + // Subclasses are friends - need to fix? + friend class CPQDIF_R_Observation; + friend class CPQDIF_R_DataSource; + + public: + CPQDIF_R_General(); + virtual ~CPQDIF_R_General(); + + // Operations + public: + virtual bool ReadHeader( CPQDIF_StreamIO * pstream ); + virtual bool ReadBody( CPQDIF_StreamIO * pstream ); + + virtual bool WriteHeader( CPQDIF_StreamIO * pstream ); + virtual bool WriteBody( CPQDIF_StreamIO * pstream ); + + // Attributes + public: + virtual bool HeaderGetPos( LINKABS4& pos ) const + { + pos = m_posThisRecord; + return true; + } + virtual bool HeaderSetPos( LINKABS4 pos ) + { + m_posThisRecord = pos; + return true; + } + virtual bool HeaderGetTag( GUID& tagRecord ) const + { + tagRecord = m_headerRecord.tagRecordType; + return true; + } + virtual bool HeaderSetTag( GUID tagRecord ) + { + m_headerRecord.tagRecordType = tagRecord; + return true; + } + virtual bool HeaderGetSize( SIZE4& sizeHeader, SIZE4& sizeBody ) const + { + sizeHeader = m_headerRecord.sizeHeader; + sizeBody = m_headerRecord.sizeData ; + return true; + } + virtual bool HeaderSetSize( SIZE4 sizeHeader, SIZE4 sizeBody ) + { + m_headerRecord.sizeHeader = sizeHeader; + m_headerRecord.sizeData = sizeBody ; + return true; + } + virtual bool HeaderGetChecksum( UINT& checksum ) const + { + checksum = m_headerRecord.checksum; + return true; + } + virtual bool HeaderSetChecksum( UINT checksum ) + { + m_headerRecord.checksum = checksum; + return true; + } + virtual bool HeaderGetPosNextRecord( LINKABS4& pos ) const + { + pos = m_headerRecord.linkNextRecord; + return true; + } + virtual bool HeaderSetPosNextRecord( LINKABS4 pos ) + { + m_headerRecord.linkNextRecord = pos; + return true; + } + virtual CPQDIF_E_Collection * GetMainCollection( void ) const + { + return m_pcollMain; + } + virtual bool SetMainCollection( CPQDIF_E_Collection * collMain ); + virtual bool GetChanged( void ) + { + return m_changed; + } + virtual void SetChanged( bool changed ) + { + m_changed = changed; + } + + bool SetTimeInMainCollection (const GUID &tag, const TIMESTAMPPQDIF & timeTime); + bool SetREAL8InMainCollection (const GUID &tag, const REAL8 dVal); + bool SetBOOL4InMainCollection (const GUID &tag, const BOOL4 bVal); + + bool GetTimeInMainCollection (const GUID &tag, TIMESTAMPPQDIF & timeTime); + bool GetREAL8InMainCollection (const GUID &tag, REAL8 & dVal); + bool GetBOOL4InMainCollection (const GUID &tag, BOOL4 & bVal); + + // Overrides + public: + + // Implementation + protected: + bool BufferUpCollection + ( + CPQDIF_StreamIO * pstream, + PQAlloc& allocator, + CPQDIF_E_Collection * pcoll, + c_collection_element * aem + ); + + // Member data + protected: + c_record_mainheader m_headerRecord; + LINKABS4 m_posThisRecord; + + CPQDIF_E_Collection * m_pcollMain; // Main collection element + // (if NULL, record has not been read yet) + + bool m_changed; // Record changed flag. + + }; + diff --git a/LFtid1056/pqdif/include/rec_observ.cpp b/LFtid1056/pqdif/include/rec_observ.cpp new file mode 100644 index 0000000..6092be7 --- /dev/null +++ b/LFtid1056/pqdif/include/rec_observ.cpp @@ -0,0 +1,1860 @@ +/* +** CPQDIF_R_Observation class. Implements a PQDIF record "wrapper" for the +** data source record. You can NOT cast a standard record object to this +** class, because it has its own member data. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_observ.cpp $ +** Last modified: $Modtime: 12/01/00 12:45p $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/rec_observ.cpp $ +** VCS revision: $Revision: 30 $ +*/ +#include "PQDIF_classes.h" + + +// Local functions +// =============== + +// Function to round second values to the nearest nanosecond. +inline double _FixSeconds(double dTime) +{ + return floor( dTime * 1000000000.0 + 0.5 )/ 1000000000.0; +} + +static void _AddSeconds( TIMESTAMPPQDIF &dt, double secondsToAdd ) +{ + + // Record the current day for an overflow check. + DWORD dwDay = dt.day; + + // Perform the requested operation. + dt.sec += secondsToAdd; + + // If the result is greater than the number of seconds in + // a day then ... + if( dt.sec > (double) SECONDS_PER_DAY ) + { + + // Carry resulting number of days. + long lDays = (long)( dt.sec / (double) SECONDS_PER_DAY ); + dt.day += lDays; + dt.sec -= ( lDays * (double) SECONDS_PER_DAY ); + + + // Check for an overflow. + if( dt.day < dwDay ) + { + dt.day = 0xffffffff; + dt.sec = 86399.999999; + } + + } + + // Else if the result is less than 0.0. + else if( dt.sec < 0.0 ) + { + + // Borrow the required number of days. + long lDays = 1 - (long)( dt.sec / (double) SECONDS_PER_DAY ); + dt.day -= lDays; + dt.sec += ( lDays * (double) SECONDS_PER_DAY ); + + // Check for an underflow. + if( dt.day > dwDay ) + { + dt.day = 0; + dt.sec = 0.0; + } + + } + + + // Adjust the result. + dt.sec = _FixSeconds( dt.sec ); + +} + + +// Construction +// ============ + +CPQDIF_R_Observation::CPQDIF_R_Observation() +{ + m_pds = NULL; + m_psett = NULL; + m_record = NULL; +} + +CPQDIF_R_Observation::CPQDIF_R_Observation( CPQDIFRecord& record ) +{ + m_pds = NULL; + m_psett = NULL; + m_record = (CPQDIF_R_General *) &record; +} + + +CPQDIF_R_Observation::~CPQDIF_R_Observation() +{ + // Don't destroy m_pds or m_record; these are only by reference, not by value. +} + + +bool CPQDIF_R_Observation::GetInfo + ( + TIMESTAMPPQDIF& timeStart, + TIMESTAMPPQDIF& timeCreate, + string& name + ) +{ + bool status; + long countEntries = 0; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + // Init + status = TRUE; + memset( &timeStart, 0, sizeof( timeStart ) ); + memset( &timeCreate, 0, sizeof( timeCreate ) ); + name = ""; + + // First, find the times + if( status ) + { + psc = FindScalarInCollection( m_record->m_pcollMain, tagTimeStart ); + if( psc ) + { + status = psc->GetValueTimeStamp( timeStart ); + } + } + + if( status ) + { + psc = FindScalarInCollection( m_record->m_pcollMain, tagTimeCreate ); + if( psc ) + { + status = psc->GetValueTimeStamp( timeCreate ); + } + } + + // Get name + if( status ) + { + pvect = FindVectorInCollection( m_record->m_pcollMain, tagObservationName ); + if( pvect ) + { + status = pvect->GetValues( name ); + } + } + + return status; +} + + +long CPQDIF_R_Observation::GetCountChannels( void ) +{ + long count = 0; + CPQDIF_E_Collection * pcolCI; + + pcolCI = GetChannelInstances(); + if( pcolCI ) + { + count = pcolCI->GetCount(); + } + + return count; +} + + +bool CPQDIF_R_Observation::GetTriggerInfo + ( + UINT4& idTriggerMethod, + CPQDIF_E_Vector ** pvectTriggerChanIdx, + TIMESTAMPPQDIF& timeTriggered + ) +{ + bool status = false; + long countEntries = 0; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + // Init + idTriggerMethod = ID_TRIGGER_METH_NONE; + //ASSERT( pvectTriggerChanIdx ); + *pvectTriggerChanIdx = NULL; + memset( &timeTriggered, 0, sizeof( timeTriggered ) ); + + // First, find the trigger method + psc = FindScalarInCollection( m_record->m_pcollMain, tagTriggerMethodID ); + if( psc ) + { + status = psc->GetValueUINT4( idTriggerMethod ); + } + else + { + // Default to channel? NAHHH + //status = TRUE; + //idTriggerMethod = ID_TRIGGER_METH_CHANNEL; + } + + // Get triggered channels? (NOT required; leave status alone) + if( status && idTriggerMethod == ID_TRIGGER_METH_CHANNEL ) + { + pvect = FindVectorInCollection( m_record->m_pcollMain, tagChannelTriggerIdx ); + if( pvect ) + { + // Validate physical type + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_UNS_INTEGER4 ) + { + // Return a pointer to the vector + *pvectTriggerChanIdx = pvect; + } + } + } + + // Get the time it was triggered + if( status ) + { + status = false; + psc = FindScalarInCollection( m_record->m_pcollMain, tagTimeTriggered ); + if( psc ) + { + status = psc->GetValueTimeStamp( timeTriggered ); + } + } + + return status; +} + + +long CPQDIF_R_Observation::GetCountSeries( int idxChannel ) +{ + long count = 0; + CPQDIF_E_Collection * pcolOneChannel; + CPQDIF_E_Collection * pcolSI; + + pcolOneChannel = GetOneChannel( idxChannel ); + if( pcolOneChannel ) + { + pcolSI = GetSeriesInstances( pcolOneChannel ); + if( pcolSI ) + { + count = pcolSI->GetCount(); + } + } + + return count; +} + + +bool CPQDIF_R_Observation::GetChannelInfo + ( + long idxChannel, + string& name, + UINT4& idPhase, + GUID& idQuantityType, + UINT4& idQuantityMeasured + ) +{ + bool status = true; + long idxChannelDefn; + + // Find the channel defn index + if( status ) + { + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + } + + // Gather information from the channel definitions + if( status && m_pds ) + { + status = m_pds->GetChannelDefnInfo( idxChannelDefn, name, idPhase, + idQuantityType, idQuantityMeasured ); + } + else + { + status = false; + } + + return status; +} + +bool CPQDIF_R_Observation::GetChannelPrimarySeries + ( + long idxChannel, + long& idxPrimarySeries + ) +{ + bool status = true; + long idxChannelDefn; + + // Find the channel defn index + if( status ) + { + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + } + + // Gather information from the channel definitions + if( status && m_pds ) + { + status = m_pds->GetChannelPrimarySeries( idxChannelDefn, idxPrimarySeries ); + } + else + { + status = false; + } + + return status; +} + +#ifdef zap +// +// +// Depricated function +// +bool CPQDIF_R_Observation::GetChannelThresholds + ( + long idxChannel, + UINT4& triggerTypeID, + REAL8& fullScale, + REAL8& noiseFloor, + REAL8& triggerLow, + REAL8& triggerHigh, + REAL8& triggerRate, + CPQDIF_E_Vector& triggerShapeParam // Array of [3] + ) +{ + bool status = false; + long idxChannelDefn; + + bool found; + long idxChannSett; + long countChannSett; + UINT4 idxChannelDefnSett; + + // DO we have settings? + if( m_psett ) + { + // Determine which channel def'n is used for this channel + // Find the channel defn index + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + + // Check all settings channels to see which matches the def'n + if( status ) + { + // Init + status = false; + + countChannSett = m_psett->GetCountChannels(); + for( idxChannSett = 0; idxChannSett < countChannSett; idxChannSett++ ) + { + found = m_psett->GetChannelInfo( idxChannSett, idxChannelDefnSett, + triggerTypeID, fullScale, noiseFloor, + triggerLow, triggerHigh, triggerRate, + triggerShapeParam ); + + // Is this the one that corresponds to the same def'n? + if( found && idxChannelDefn == (long) idxChannelDefnSett ) + { + status = TRUE; + break; + } + } // For( channel setting ) + + } // Found channel def'n + } // Have settings + + return status; +} +#endif + +bool CPQDIF_R_Observation::GetSeriesInfo + ( + long idxChannel, + long idxSeries, + UINT4& idQuantityUnits, + GUID& idQuantityCharacteristic, + GUID& idValueType + ) +{ + bool status = true; + long idxChannelDefn; + UINT4 idStorageMethod; + + // Find the channel defn index + if( status ) + { + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + } + + // Gather information from the series definition + if( status && m_pds ) + { + status = m_pds->GetSeriesDefnInfo( idxChannelDefn, idxSeries, + idQuantityUnits, idValueType, idQuantityCharacteristic, + idStorageMethod ); + } + else + { + status = false; + } + + return status; +} + + +long CPQDIF_R_Observation::AddChannel + ( + long idxChannelDefn + ) +{ + long idxNew = -1; + + CPQDIF_E_Collection * pcolInstances = GetChannelInstances(); + CPQDIF_E_Collection * pcollOne; + CPQDIF_E_Collection * pcollSeriesInstances; + + if( pcolInstances ) + { + // Get the new index + idxNew = GetCountChannels(); + + // Create the new channel instance + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollOne->SetTag( tagOneChannelInst ); + + // Stuff in the information... + pcollOne->SetScalarUINT4( tagChannelDefnIdx, idxChannelDefn ); + + // Also need a series instances collection + pcollSeriesInstances = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollSeriesInstances ) + { + pcollSeriesInstances->SetTag( tagSeriesInstances ); + pcollOne->Add( pcollSeriesInstances ); + } + + // Add it! + pcolInstances->Add( pcollOne ); + } + + return idxNew; +} + + +long CPQDIF_R_Observation::AddSeriesDouble + ( + long idxChannel, + long countValues, + double * arValues + ) +{ + long idxNew = -1; + + CPQDIF_E_Vector * pvectData; + + long idx; + double * pValue; + + // Create vector for the series data + pvectData = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); + if( pvectData ) + { + pvectData->SetTag( tagSeriesValues ); + pvectData->SetPhysicalType( ID_PHYS_TYPE_REAL8 ); + + // Copy over series data + pValue = arValues; + pvectData->SetCount( countValues ); + for( idx = 0; idx < countValues; idx++, pValue++ ) + { + pvectData->SetValue( idx, *pValue ); + } + + // Add it ... + idxNew = AddSeriesVector( idxChannel, pvectData ); + + // If it was not successful, delete the vector + if( idxNew < 0 ) + { + delete pvectData; + } + } + + return idxNew; +} + + +long CPQDIF_R_Observation::AddSeriesVector + ( + long idxChannel, + CPQDIF_E_Vector * pvectData + ) +{ + long idxNew = -1; + + CPQDIF_E_Collection * pcolOneChannel; + CPQDIF_E_Collection * pcolSI; + CPQDIF_E_Collection * pcollOne; + + pcolOneChannel = GetOneChannel( idxChannel ); + if( pcolOneChannel && pvectData ) + { + pcolSI = GetSeriesInstances( pcolOneChannel ); + if( pcolSI ) + { + // New channel index + idxNew = pcolSI->GetCount(); + + // Create the new channel def'n + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollOne ) + { + // Set the tag for this collection ... + pcollOne->SetTag( tagOneSeriesInstance ); + + // Make sure the vector has the right tag ... + pvectData->SetTag( tagSeriesValues ); + + // The vector is currently the only member of this collection. + pcollOne->Add( pvectData ); + } + + // Add it! + pcolSI->Add( pcollOne ); + } + } + + return idxNew; +} + +long CPQDIF_R_Observation::AddSeriesShared + ( + long idxChannel, + long idxChannelShared, + long idxSeriesShared + ) + { + long idxNew = -1; + + CPQDIF_E_Collection * pcolOneChannel; + CPQDIF_E_Collection * pcolSI; + CPQDIF_E_Collection * pcollOne; + + CPQDIF_E_Scalar * pscSharedChannel; + CPQDIF_E_Scalar * pscSharedSeries; + + pcolOneChannel = GetOneChannel( idxChannel ); + if( pcolOneChannel ) + { + pcolSI = GetSeriesInstances( pcolOneChannel ); + if( pcolSI ) + { + // New channel index + idxNew = pcolSI->GetCount(); + + // Create the new channel def'n + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollOne ) + { + + // Set the tag for this collection ... + pcollOne->SetTag( tagOneSeriesInstance ); + + // Create scalars which indicate which channel/series is to be shared + pscSharedChannel = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + pscSharedSeries = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( pscSharedChannel && pscSharedSeries ) + { + // Tags & values + pscSharedChannel->SetTag( tagSeriesShareChannelIdx ); + pscSharedChannel->SetPhysicalType( ID_PHYS_TYPE_UNS_INTEGER4 ); + pscSharedChannel->SetValueUINT4( idxChannelShared ); + pscSharedSeries->SetTag( tagSeriesShareSeriesIdx ); + pscSharedSeries->SetPhysicalType( ID_PHYS_TYPE_UNS_INTEGER4 ); + pscSharedSeries->SetValueUINT4( idxSeriesShared ); + + // Stuff 'em + pcollOne->Add( pscSharedChannel ); + pcollOne->Add( pscSharedSeries ); + } + } + + // Add it! + pcolSI->Add( pcollOne ); + } + } + + return idxNew; + } + +bool CPQDIF_R_Observation::SetSeriesBaseQuantity + ( + long idxChannel, + long idxSeries, + double value + ) +{ + bool status = false; + + CPQDIF_E_Collection * pcol; + CPQDIF_E_Scalar * psc; + + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + psc = FindScalarInCollection( pcol, tagSeriesBaseQuantity ); + if( !psc ) + { + // Create it ! + psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( psc ) + { + pcol->Add( psc ); + } + } + + // Init the scalar + if( psc ) + { + psc->SetTag( tagSeriesBaseQuantity ); + psc->SetValueREAL8( value ); + status = TRUE; + } + } + + return status; +} + +bool CPQDIF_R_Observation::SetSeriesScale + ( + long idxChannel, + long idxSeries, + double scale, + double offset + ) + { + bool status = false; + + CPQDIF_E_Collection * pcol; + CPQDIF_E_Scalar * psc; +#ifdef zap + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + psc = FindOrCreateScalarInCollection( pcol, tagSeriesScale, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + status = psc->SetValueREAL8( scale ); + } + psc = FindOrCreateScalarInCollection( pcol, tagSeriesOffset, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + status = psc->SetValueREAL8( offset ); + } + } +#endif + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + psc = FindScalarInCollection( pcol, tagSeriesScale ); + if( !psc ) + { + // Create it ! + psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( psc ) + { + pcol->Add( psc ); + } + } + + // Init the scalar + if( psc ) + { + psc->SetTag( tagSeriesScale ); + psc->SetValueREAL8( scale ); + status = TRUE; + } + + + psc = FindScalarInCollection( pcol, tagSeriesOffset ); + if( !psc ) + { + // Create it ! + psc = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + if( psc ) + { + pcol->Add( psc ); + } + } + + // Init the scalar + if( psc ) + { + psc->SetTag( tagSeriesOffset ); + psc->SetValueREAL8( offset ); + status = TRUE; + } + } + + return status; + } + +bool CPQDIF_R_Observation::GetSeriesBaseQuantity + ( + long idxChannel, + long idxSeries, + double& value + ) +{ + bool status = false; + + CPQDIF_E_Collection * pcol; + CPQDIF_E_Scalar * psc; + + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + psc = FindScalarInCollection( pcol, tagSeriesBaseQuantity ); + if( psc ) + { + status = psc->GetValueREAL8( value ); + } + } + + return status; +} + +#ifdef PQDIF_USE_COM + +bool CPQDIF_R_Observation::GetObservationExtendedData + ( + GUID& gidTag, + VARIANT& value + ) +{ + bool status = false; + + CPQDIF_E_Scalar * psc; + + psc = FindScalarInCollection( m_record->m_pcollMain, gidTag ); + if( psc ) + { + status = psc->GetValue( value ); + } + + return status; +} + +bool CPQDIF_R_Observation::GetSeriesExtendedData + ( + long idxChannel, + long idxSeries, + GUID& gidTag, + VARIANT& value + ) +{ + bool status = false; + + CPQDIF_E_Collection * pcollOneChannel; + CPQDIF_E_Scalar * psc; + + pcollOneChannel = GetOneSeries( idxChannel, idxSeries ); + + if (pcollOneChannel) + { + psc = FindScalarInCollection( pcollOneChannel, gidTag ); + if( psc ) + { + status = psc->GetValue( value ); + } + } + return status; +} + +bool CPQDIF_R_Observation::GetChannelExtendedData + ( + long idxChannel, + GUID& gidTag, + VARIANT& value + ) +{ + bool status = false; + + CPQDIF_E_Collection * pcollOneChannel; + CPQDIF_E_Scalar * psc; + + pcollOneChannel = GetOneChannel( idxChannel ); + + if (pcollOneChannel) + { + psc = FindScalarInCollection( pcollOneChannel, gidTag ); + if( psc ) + { + status = psc->GetValue( value ); + } + } + return status; +} + +#endif + +bool CPQDIF_R_Observation::GetSeriesDefnNominal + ( + long idxChannel, + long idxSeries, + double & dNominal + ) + { + bool status = false; + long idxChannelDefn; + + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + + if (m_pds) + { + status = m_pds->GetSeriesDefnNominal(idxChannelDefn, idxSeries, dNominal); + } + + return status; + } + +bool CPQDIF_R_Observation::GetSeriesDefnPrecisionAndResolution + ( + long idxChannel, + long idxSeries, + UINT4 & uPrecision, + double & dResolution + ) + { + bool status = false; + long idxChannelDefn; + + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + + if (m_pds) + { + status = m_pds->GetSeriesDefnPrecisionAndResolution(idxChannelDefn, idxSeries, uPrecision, dResolution); + } + + return status; + } + +bool CPQDIF_R_Observation::GetSeriesScale + ( + long idxChannel, + long idxSeries, + double& scale, + double& offset + ) + { + bool status = false; + + CPQDIF_E_Collection * pcol; + CPQDIF_E_Scalar * psc; + + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + psc = FindScalarInCollection( pcol, tagSeriesScale ); + if( psc ) + { + status = psc->GetValueREAL8( scale ); + } + psc = FindScalarInCollection( pcol, tagSeriesOffset ); + if( psc ) + { + status = psc->GetValueREAL8( offset ); + } + } + + return status; + } + +CPQDIF_E_Vector * CPQDIF_R_Observation::GetSeriesValueVector + ( + long idxChannel, + long idxSeries + ) + { + CPQDIF_E_Vector * pvectReturn = NULL; + + CPQDIF_E_Collection * pcolOneSeries; + + pcolOneSeries = GetOneSeries( idxChannel, idxSeries ); + if( pcolOneSeries ) + { + pvectReturn = FindVectorInCollection( pcolOneSeries, tagSeriesValues ); + } + + return pvectReturn; + } + +bool CPQDIF_R_Observation::SetTimeCreateAndTimeStart +( + const TIMESTAMPPQDIF& timeCreate, + const TIMESTAMPPQDIF& timeStart +) +{ + bool status = false; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + // Init + //ASSERT(aidxTriggerChan); + + // First, find (or create) the trigger method + psc = FindOrCreateScalarInCollection(m_record->m_pcollMain, + tagTimeCreate, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set its value + if (psc) + { + status = psc->SetValueTimeStamp(timeCreate); + } + + // Set the time it was triggered + if (status) + { + status = false; + psc = FindOrCreateScalarInCollection(m_record->m_pcollMain, + tagTimeStart, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set value + if (psc) + { + status = psc->SetValueTimeStamp(timeStart); + } + } + + return status; +} + +bool CPQDIF_R_Observation::SetTriggerInfo + ( + UINT4 idTriggerMethod, + long countTriggers, + const UINT4 * aidxTriggerChan, + const TIMESTAMPPQDIF& timeTriggered + ) +{ + bool status = false; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + // Init + //ASSERT( aidxTriggerChan ); + + // First, find (or create) the trigger method + psc = FindOrCreateScalarInCollection( m_record->m_pcollMain, + tagTriggerMethodID, ID_PHYS_TYPE_UNS_INTEGER4 ); + // Set its value + if( psc ) + { + status = psc->SetValueUINT4( idTriggerMethod ); + } + + // Get triggered channels? + if( status && idTriggerMethod == ID_TRIGGER_METH_CHANNEL ) + { + status = false; + pvect = FindOrCreateVectorInCollection( m_record->m_pcollMain, + tagChannelTriggerIdx, ID_PHYS_TYPE_UNS_INTEGER4 ); + // Set its value(s) + if( pvect ) + { + // Validate physical type + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_UNS_INTEGER4 ) + { + pvect->SetCount( countTriggers ); + for( long idx = 0; idx < countTriggers; idx++ ) + { + pvect->SetValueUINT4( idx, aidxTriggerChan[ idx ] ); + } + status = TRUE; + } + } + } + + // Set the time it was triggered + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_record->m_pcollMain, + tagTimeTriggered, ID_PHYS_TYPE_TIMESTAMPPQDIF ); + // Set value + if( psc ) + { + status = psc->SetValueTimeStamp( timeTriggered ); + } + } + + return status; +} + + +long CPQDIF_R_Observation::GetCountResolvedSeries + ( + long idxChannel, + long idxSeries, + bool noShare + ) +{ + int idx; + bool status = false; + long countPoints = 0; + long idxChannelDefn; + UINT4 idQuantityUnits; + GUID idQuantityCharacteristic; + GUID idValueType; + UINT4 idStorageMethod; + + bool gotShareChannel = false; + bool gotShareSeries = false; + UINT4 idxShareChannelIdx = 0; + UINT4 idxShareSeriesIdx = 0; + + CPQDIF_Element * pel = NULL; + CPQDIF_E_Collection * pcol = NULL; + CPQDIF_E_Vector * pvectSeriesArray = NULL; + + // Verify that we're in an observation record + // Requires a data source record + if( m_record && m_pds && idxChannel >= 0 && idxSeries >= 0) + { + // Find the channel defn index + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + + // Fail if we got a bogus index + if( status && idxChannelDefn < 0 ) + status = false; + } + + // Get the storage method + if( status ) + { + status = m_pds->GetSeriesDefnInfo( idxChannelDefn, idxSeries, + idQuantityUnits, idValueType, idQuantityCharacteristic, idStorageMethod ); + } + + // Look for shared channel and series indices, or a vector of values + if( status ) + { + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + status = true; + + for( idx = 0; idx < pcol->GetCount(); idx++ ) + { + pel = pcol->GetElement( idx ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + CPQDIF_E_Scalar *psc = (CPQDIF_E_Scalar *) pel; + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesShareChannelIdx ) ) + { + gotShareChannel = TRUE; + psc->GetValueUINT4( idxShareChannelIdx ); + if( gotShareSeries ) + break; + } + + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesShareSeriesIdx ) ) + { + gotShareSeries = TRUE; + psc->GetValueUINT4( idxShareSeriesIdx ); + if( gotShareChannel ) + break; + } + } + else if( pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR + && PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesValues ) ) + { + pvectSeriesArray = (CPQDIF_E_Vector *) pel; + break; + } + + } + } + } + } + + // Now count the values + if( status ) + { + if( gotShareChannel && gotShareSeries ) + { + // We're sharing the series from somwhere else -- + // generate it from the shared indices + if( !noShare ) + { + countPoints = GetCountResolvedSeries( + (long) idxShareChannelIdx, + (long) idxShareSeriesIdx, + true ); // recurse only once + } + } + else if( pvectSeriesArray ) + { + // Generate the new series array + countPoints = _GenerateSeriesCount( idStorageMethod, pvectSeriesArray); + } + } + + return countPoints; +} + +BOOL CPQDIF_R_Observation::GetSeriesBaseType +( + long idxChannel, + long idxSeries, + long& nSeriesBaseType + ) +{ + BOOL status = FALSE; + int idx; + + CPQDIF_Element * pel; + CPQDIF_E_Collection * pcol; + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvectSeriesArray; + + long typePhysical; + PQDIFValue value; + double valueReal; + + double rBaseValue = 1.0; + double rScale = 1.0; + double rOffset = 0.0; + + bool gotShareChannel = false; + bool gotShareSeries = false; + bool isShared = false; + UINT4 idxShareChannelIdx = 0; + UINT4 idxShareSeriesIdx = 0; + + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + status = TRUE; + + // Loop through all elements in the series collection + for( idx = 0; idx < pcol->GetCount(); idx++ ) + { + pel = pcol->GetElement( idx ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + psc = (CPQDIF_E_Scalar *) pel; + + // If it's REAL4 or REAL8, go ahead and pull it out + valueReal = 0.0; + psc->GetValue( typePhysical, value ); + nSeriesBaseType = typePhysical; + } + + if( pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR + && PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesValues ) ) + { + pvectSeriesArray = (CPQDIF_E_Vector *) pel; + nSeriesBaseType = pvectSeriesArray->GetPhysicalType(); + } + } // if( pel ) + } + } + return status; +} + +double * CPQDIF_R_Observation::NewResolvedSeries + ( + long idxChannel, + long idxSeries, + long& countPoints, + bool noShare + ) +{ + bool status = false; + int idx; + double * arValues = NULL; + + CPQDIF_Element * pel = NULL; + CPQDIF_E_Collection * pcol = NULL; + CPQDIF_E_Scalar * psc = NULL; + CPQDIF_E_Vector * pvectSeriesArray = NULL; + + long typePhysical; + PQDIFValue value; + double valueReal; + + double rBaseValue = 1.0; + double rScale = 1.0; + double rOffset = 0.0; + + long idxChannelDefn = 0; + + string name; + UINT4 idPhase; + GUID idQuantityType; + UINT4 idQuantityMeasured; + UINT4 idQuantityUnits; + GUID idQuantityCharacteristic; + GUID idValueType; + UINT4 idStorageMethod; + + bool gotShareChannel = false; + bool gotShareSeries = false; + bool isShared = false; + UINT4 idxShareChannelIdx = 0; + UINT4 idxShareSeriesIdx = 0; + + // Verify that we're in an observation record + // Requires a data source record + if( m_record && m_pds && idxChannel >= 0 && idxSeries >= 0) + { + // Find the channel defn index + status = GetChannelDefnIdx( idxChannel, idxChannelDefn ); + + // Fail if we got a bogus index + if( status && idxChannelDefn < 0 ) + status = false; + } + + // Gather information from the channel & series definitions + if( status ) + { + status = m_pds->GetChannelDefnInfo( idxChannelDefn, name, idPhase, idQuantityType, idQuantityMeasured ); + } + if( status ) + { + status = m_pds->GetSeriesDefnInfo( idxChannelDefn, idxSeries, + idQuantityUnits, idValueType, idQuantityCharacteristic, idStorageMethod ); + } + + if( status ) + { + status = false; + + // Find the series + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + status = true; + + // Loop through all elements in the series collection + for( idx = 0; idx < pcol->GetCount(); idx++ ) + { + pel = pcol->GetElement( idx ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + psc = (CPQDIF_E_Scalar *) pel; + + // If it's REAL4 or REAL8, go ahead and pull it out + valueReal = 0.0; + psc->GetValue( typePhysical, value ); + if (typePhysical == ID_PHYS_TYPE_INTEGER4) + { + valueReal = value.int4; + } + if( typePhysical == ID_PHYS_TYPE_REAL4 ) + { + valueReal = value.real4; + } + if( typePhysical == ID_PHYS_TYPE_REAL8 ) + { + valueReal = value.real8; + } + + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesBaseQuantity ) ) + { + rBaseValue = valueReal; + } + + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesScale ) ) + { + rScale = valueReal; + } + + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesOffset ) ) + { + rOffset = valueReal; + } + + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesShareChannelIdx ) ) + { + gotShareChannel = TRUE; + psc->GetValueUINT4( idxShareChannelIdx ); + } + + if( PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesShareSeriesIdx ) ) + { + gotShareSeries = TRUE; + psc->GetValueUINT4( idxShareSeriesIdx ); + } + } + + if( pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR + && PQDIF_IsEqualGUID( pel->GetTag(), tagSeriesValues ) ) + { + pvectSeriesArray = (CPQDIF_E_Vector *) pel; + } + + } // if( pel ) + } + } + } + + // Generate the series data + if( status ) + { + if( gotShareChannel && gotShareSeries ) + { + // We're sharing the series from somwhere else -- + // generate it from the shared indices + if( !noShare ) + { + arValues = NewResolvedSeries( + (long) idxShareChannelIdx, + (long) idxShareSeriesIdx, + countPoints, true ); + } + else + { + // Can't generate! The file is trying to share a series + // from another shared series. This is not legal. + arValues = NULL; + } + } + else if( pvectSeriesArray ) + { + // Generate the new series array + arValues = _GenerateSeriesData( idxChannelDefn, idStorageMethod, + rBaseValue, rScale, rOffset, pvectSeriesArray, countPoints ); + } + else + { + // Can't generate! + arValues = NULL; + } + } + + return arValues; +} + + +TIMESTAMPPQDIF * CPQDIF_R_Observation::NewResolvedSeriesTimeStamp + ( + long idxChannel, + long idxSeries, + long& countPoints, + bool noShare + ) +{ + TIMESTAMPPQDIF * result = NULL; + + CPQDIF_E_Collection * pcol; + CPQDIF_Element * pel; + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvectSeriesArray; + + // Shared? + BOOL gotShareChannel = FALSE; + BOOL gotShareSeries = FALSE; + UINT4 idxShareChannelIdx = 0; + UINT4 idxShareSeriesIdx = 0; + + pcol = GetOneSeries( idxChannel, idxSeries ); + if( pcol ) + { + // Is this sucker shared? + pel = pcol->GetElement( tagSeriesShareChannelIdx ); + if( pel && pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + gotShareChannel = TRUE; + psc = static_cast( pel ); + psc->GetValueUINT4( idxShareChannelIdx ); + } + + pel = pcol->GetElement( tagSeriesShareSeriesIdx ); + if( pel && pel->GetElementType() == ID_ELEMENT_TYPE_SCALAR ) + { + gotShareSeries = TRUE; + psc = static_cast( pel ); + psc->GetValueUINT4( idxShareSeriesIdx ); + } + + + if( gotShareSeries && gotShareSeries && !noShare ) + { + // SHARED. + // Allow ONE level of recursion -- no more. + result = NewResolvedSeriesTimeStamp( idxShareChannelIdx, + idxShareSeriesIdx, countPoints, true ); + } + else + { + // NOT SHARED. + // Try to decode it the normal way. + pel = pcol->GetElement( tagSeriesValues ); + if( pel->GetElementType() == ID_ELEMENT_TYPE_VECTOR ) + { + pvectSeriesArray = static_cast( pel ); + + + // Determine size/allocate space for the timestamp array + if( pvectSeriesArray->GetCount( countPoints ) ) + { + result = new TIMESTAMPPQDIF[ countPoints ]; + if( result ) + { + // Is it already in timestamp form? + if( pvectSeriesArray->GetPhysicalType() == ID_PHYS_TYPE_TIMESTAMPPQDIF ) + { + // We're done! + countPoints = pvectSeriesArray->GetValuesTimeStamp ( result, countPoints ); + } + else + { + // Fabricate it from starting time stamp and second offsets + double * seconds = NewResolvedSeries( idxChannel, idxSeries, countPoints, true ); + if( seconds ) + { + _GenerateTimeStampArray( result, seconds, countPoints ); + delete [] seconds; + } + } + } + } + } + } + } + + return result; +} + + +bool CPQDIF_R_Observation::GetChannelDefnIdx + ( + long idxChannel, + long& idxChannelDefn + ) +{ + bool status = false; + CPQDIF_E_Collection * pcollOneChannel; + CPQDIF_E_Scalar * psc; + UINT4 idx; + + // Init + status = false; + idxChannelDefn = 0; + + // Find the channel + pcollOneChannel = GetOneChannel( idxChannel ); + if( pcollOneChannel ) + { + // This is where the index should be + psc = m_record->FindScalarInCollection( pcollOneChannel, tagChannelDefnIdx ); + if( psc ) + { + status = psc->GetValueUINT4( idx ); + idxChannelDefn = (long) idx; + status = TRUE; + } + } + + return status; +} + + +CPQDIF_E_Collection * CPQDIF_R_Observation::GetChannelInstances( void ) +{ + CPQDIF_E_Collection * pcollChannels; + + // Create the collection if it does not yet exist. + pcollChannels = m_record->FindCollectionInCollection( m_record->m_pcollMain, tagChannelInstances ); + if( !pcollChannels ) + { + pcollChannels = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollChannels ) + { + pcollChannels->SetTag( tagChannelInstances ); + m_record->m_pcollMain->Add( pcollChannels ); + } + } + + return pcollChannels; +} + + +CPQDIF_E_Collection * CPQDIF_R_Observation::GetOneChannel( long idxChannel ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolInstances = GetChannelInstances(); + CPQDIF_Element * pel; + + if( pcolInstances ) + { + pel = pcolInstances->GetElement( idxChannel ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION + && PQDIF_IsEqualGUID( pel->GetTag(), tagOneChannelInst ) ) + { + pcolReturn = (CPQDIF_E_Collection *) pel; + } + } + } + + return pcolReturn; +} + + +CPQDIF_E_Collection * CPQDIF_R_Observation::GetSeriesInstances + ( + CPQDIF_E_Collection * pcolChannel + ) +{ + return m_record->FindCollectionInCollection( pcolChannel, tagSeriesInstances ); +} + + +CPQDIF_E_Collection * CPQDIF_R_Observation::GetOneSeries + ( + CPQDIF_E_Collection * pcolChannel, + long idxSeries + ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolSeriesInstances = NULL; + CPQDIF_Element * pel; + + if( pcolChannel ) + { + // Get the series instances for this channel instance + pcolSeriesInstances = GetSeriesInstances( pcolChannel ); + if( pcolSeriesInstances ) + { + // Find the specific series instance + pel = pcolSeriesInstances->GetElement( idxSeries ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION + && PQDIF_IsEqualGUID( pel->GetTag(), tagOneSeriesInstance ) ) + { + // Return it! + pcolReturn = (CPQDIF_E_Collection *) pel; + } + } + } + } + + return pcolReturn; +} + + +CPQDIF_E_Collection * CPQDIF_R_Observation::GetOneSeries + ( + long idxChannel, + long idxSeries + ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolOneChannel = NULL; + + pcolOneChannel = GetOneChannel( idxChannel ); + pcolReturn = GetOneSeries( pcolOneChannel, idxSeries ); + + return pcolReturn; +} + + +long CPQDIF_R_Observation::_GenerateSeriesCount + ( + UINT4 idStorageMethod, + CPQDIF_E_Vector * pvectSeriesArray + ) +{ + long countPoints = 0; + + if( idStorageMethod & ID_SERIES_METHOD_VALUES ) + { + // Straight vector. + pvectSeriesArray->GetCount( countPoints ); + } + else if( idStorageMethod & ID_SERIES_METHOD_INCREMENT ) + { + // Incremental storage method ... some assembly required. + long countValues; + long idxValue; + double rCount; + + // Read in the rate change list + pvectSeriesArray->GetCount( countValues ); + if( countValues > 0 ) + { + // Grab only the point counts at indices 1, 3, 5, ... + for( idxValue = 1; idxValue < countValues; idxValue += 2 ) + { + pvectSeriesArray->GetValue( idxValue, rCount ); + countPoints += (long) rCount; + } + } + } + else + { + // No third option! + } + + return countPoints; +} + + +double * CPQDIF_R_Observation::_GenerateSeriesData + ( + int idxChannelDefn, + UINT4 idStorageMethod, + double rBaseValue, + double rScale, + double rOffset, + CPQDIF_E_Vector * pvectSeriesArray, + long& countPoints + ) +{ + double * arValues = NULL; + double * prTempValues; + long idxPoint; + long countValues; + long idxValue; + bool useScale = false; + bool useCal = false; + + // Unused parameter + rBaseValue = rBaseValue; + + // Get raw number of values in the vector. This may be the actual + // number of points. + pvectSeriesArray->GetCount( countValues ); + + // Determine how many total points + countPoints = _GenerateSeriesCount( idStorageMethod, pvectSeriesArray ); + + if( idStorageMethod & ID_SERIES_METHOD_VALUES ) + { + // Straight vector. No assembly necessary. + // The two counts must be identical. + if( countPoints > 0 && countPoints == countValues ) + { + // We already have the number of points... + arValues = new double[ countPoints ]; + prTempValues = arValues; + + for( idxPoint = 0; idxPoint < countPoints; idxPoint++, prTempValues++ ) + { + pvectSeriesArray->GetValue( idxPoint, *prTempValues ); + } + } + } + else if( idStorageMethod & ID_SERIES_METHOD_INCREMENT ) + { + // Incremental storage method ... some assembly required. + double valueNext; + double rCount; + double rRate ; + long countChanges; + long idxChange; + long countPointsThisChange; + + // Go through the rate change list and generate the array. + if( countPoints > 0 ) + { + arValues = new double[ countPoints ]; + if( arValues ) + { + // Init -- get ready for loops + prTempValues = arValues; + valueNext = 0.0; // First item will be zero + + // Determine total number of rate changes [0] + pvectSeriesArray->GetValue( 0, rCount ); + countChanges = (long) rCount; + + // Get counts and rate changes ... + for( idxChange = 0; idxChange < countChanges; idxChange++ ) + { + // Calculate index into value array ... + idxValue = ( idxChange * 2 ) + 1; + + // Get data ... + pvectSeriesArray->GetValue( idxValue + 0, rCount ); // Count @ rate + pvectSeriesArray->GetValue( idxValue + 1, rRate ); // Rate + countPointsThisChange = (long) rCount; + + // Generate points from the data ... + for( idxPoint = 0; idxPoint < countPointsThisChange; idxPoint++, prTempValues++ ) + { + // Store current point. + *prTempValues = valueNext; + + // Calculate next point. + valueNext += rRate; + } // for( points ); + } // for( changes ) + + } + } + } + else + { + // No third option! + arValues = NULL; + } + + // Scale & offset? + if( idStorageMethod & ID_SERIES_METHOD_SCALED ) + { + // Scale/offset should already be set. + useScale = true; + } + else + { + // Default values for scale/offset + rScale = 1.0; + rOffset = 0.0; + useScale = false; + } + + // CT/PT ratios? + useCal = _GetCalibrationRatio( idxChannelDefn, rScale ); + if( useCal ) + { + // The scale has now been adjusted to apply + // the calibration ratio. + useScale = true; + } + + // Adjust, if necessary. + if( useScale ) + { + if( arValues && countPoints > 0 ) + { + prTempValues = arValues; + for( idxPoint = 0; idxPoint < countPoints; idxPoint++, prTempValues++ ) + { + // Apply scale first, then offset + *prTempValues *= rScale; + *prTempValues += rOffset; + } // for( points ); + } + } + + return arValues; +} + + +bool CPQDIF_R_Observation::_GenerateTimeStampArray + ( + TIMESTAMPPQDIF * result, + double * seconds, + long countPoints + ) +{ + bool status = false; + TIMESTAMPPQDIF tsStart; + TIMESTAMPPQDIF tsTemp; + string name; + TIMESTAMPPQDIF * resTemp = result; + double * secTemp = seconds; + + + // Get start time for the entire observation. If successful then ... + status = GetInfo( tsStart, tsTemp, name ); + if (tsStart.day > 0) status = 1; + if( status ) + { + + // For each value do ... + for( int idx = 0; idx < countPoints; idx++, resTemp++, secTemp++ ) + { + + // Get starting time + *resTemp = tsStart; + + // Add seconds to it + _AddSeconds( *resTemp, *secTemp ); + + } // for( stamps ) + + } + + return status; +} + + +bool CPQDIF_R_Observation::_GetCalibrationRatio + ( + int idxChannelDefn, + double& rScale + ) +{ + bool status = false; + + if( m_psett ) + { + TIMESTAMPPQDIF tsTemp; + bool useCal = false; + bool useTrans = false; // Not used + + bool gotInfo = m_psett->GetInfo( tsTemp, tsTemp, tsTemp, useCal, useTrans ); + if( gotInfo && useCal ) + { + long countChannels; + countChannels = m_psett->GetCountChannels(); + for( long idxChannel = 0; idxChannel < countChannels; idxChannel++ ) + { + UINT4 idxChannelDefnCurrent; + gotInfo = m_psett->GetChannelInfo( idxChannel, idxChannelDefnCurrent); + + if( gotInfo ) + { + // Is this the information for the correct channel defn? + if( idxChannelDefn == (int) idxChannelDefnCurrent ) + { + UINT4 xdTransformerTypeID; + REAL8 xdSystemSideRatio; + REAL8 xdMonitorSideRatio; + CPQDIF_E_Vector xdFrequencyResponse; + + gotInfo = m_psett->GetChanTrans( idxChannel, + xdTransformerTypeID, + xdSystemSideRatio, xdMonitorSideRatio, + xdFrequencyResponse ); + if( gotInfo ) + { + // Looks like we got it... + rScale *= xdMonitorSideRatio; + rScale /= xdSystemSideRatio; + status = true; + break; + } + } + } + } + } + } + + return status; +} + diff --git a/LFtid1056/pqdif/include/rec_observ.h b/LFtid1056/pqdif/include/rec_observ.h new file mode 100644 index 0000000..837ae2d --- /dev/null +++ b/LFtid1056/pqdif/include/rec_observ.h @@ -0,0 +1,339 @@ +// File name: $Workfile: rec_observ.h $ +// Last modified: $Modtime: 2/22/00 11:01p $ +// Last modified by: $Author: Jack $ +// +// VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/rec_observ.h $ +// VCS revision: $Revision: 17 $ + +class CPQDIF_R_Settings; + +class CPQDIF_R_Observation : public CPQDIF_R_General + { + public: + CPQDIF_R_Observation(); + CPQDIF_R_Observation( CPQDIFRecord& record ); + virtual ~CPQDIF_R_Observation(); + + // Operations + public: + void SetDataSource + ( + CPQDIF_R_DataSource * pds + ) + { m_pds = pds; } + void SetMonitorSettings + ( + CPQDIF_R_Settings * psett + ) + { m_psett = psett; } + CPQDIF_R_Settings * GetMonitorSettings() + { + return m_psett; + } + + long GetCountResolvedSeries + ( + long idxChannel, + long idxSeries, + bool noShare = false + ); + double * NewResolvedSeries + ( + long idxChannel, + long idxSeries, + long& countPoints, + bool noShare = false // Set to true to prevent another level of shared series. + // (This could prevent infinitely recursive calls.) + ); + BOOL GetSeriesBaseType + ( + long idxChannel, + long idxSeries, + long& nSeriesBaseType + ); + TIMESTAMPPQDIF * NewResolvedSeriesTimeStamp + ( + long idxChannel, + long idxSeries, + long& countPoints, + bool noShare = false + ); + + // Attributes + public: + // Read functions + bool GetInfo + ( + TIMESTAMPPQDIF& timeStart, + TIMESTAMPPQDIF& timeCreate, + string& name + ); + long GetCountChannels( void ); + long GetCountSeries( int idxChannel ); + bool GetChannelInfo + ( + long idxChannel, + string& name, + UINT4& idPhase, + GUID& idQuantityType, + UINT4& idQuantityMeasured + ); + bool GetChannelPrimarySeries + ( + long idxChannel, + long& idxPrimarySeries + ); +#ifdef zap + bool GetChannelThresholds + ( + long idxChannel, + UINT4& triggerTypeID, + REAL8& fullScale, + REAL8& noiseFloor, + REAL8& triggerLow, + REAL8& triggerHigh, + REAL8& triggerRate, + CPQDIF_E_Vector& triggerShapeParam // Array of [3] + ); +#endif + bool GetSeriesInfo + ( + long idxChannel, + long idxSeries, + UINT4& idQuantityUnits, + GUID& idQuantityCharacteristic, + GUID& idValueType + ); + bool GetTriggerInfo + ( + UINT4& idTriggerMethod, + CPQDIF_E_Vector ** pvectTriggerChanIdx, + TIMESTAMPPQDIF& timeTriggered + ); + bool GetPqdsInfo + ( + GUID& idDataSourceType, // GUID + GUID& idInstrumentType, // GUID + UINT4& codeLocation, + CPQDIF_E_Vector ** pvectCodesDisturbanceType // Array[ 3 ] of UINT4 + ); + bool GetSeriesBaseQuantity + ( + long idxChannel, + long idxSeries, + double& value + ); + bool GetSeriesScale + ( + long idxChannel, + long idxSeries, + double& scale, + double& offset + ); + + bool GetSeriesDefnNominal + ( + long idxChannel, + long idxSeries, + double & dNominal + ); + + bool GetSeriesDefnPrecisionAndResolution + ( + long idxChannel, + long idxSeries, + UINT4 & uPrecision, + double & dResolution + ); + + CPQDIF_E_Vector * GetSeriesValueVector + ( + long idxChannel, + long idxSeries + ); + + // Write functions + long AddChannel + ( + long idxChannelDefn + ); + long AddSeriesDouble + ( + long idxChannel, + long countValues, + double * arValues + ); + bool SetSeriesBaseQuantity + ( + long idxChannel, + long idxSeries, + double value + ); + bool SetSeriesScale + ( + long idxChannel, + long idxSeries, + double scale, + double offset + ); + long AddSeriesVector + ( + long idxChannel, + CPQDIF_E_Vector * pvect + ); + long AddSeriesShared + ( + long idxChannel, + long idxChannelShared, + long idxSeriesShared + ); + bool SetTriggerInfo + ( + UINT4 idTriggerMethod, + long countTriggers, + const UINT4 * aidxTriggerChan, + const TIMESTAMPPQDIF& timeTriggered + ); + bool SetTimeCreateAndTimeStart + ( + const TIMESTAMPPQDIF& timeCreate, + const TIMESTAMPPQDIF& timeStart + ); + +#ifdef PQDIF_USE_COM + + bool GetObservationExtendedData + ( + GUID& gidTag, + VARIANT& value + ); + + bool GetChannelExtendedData + ( + long idxChannel, + GUID& gidTag, + VARIANT& value + ); + + bool GetSeriesExtendedData + ( + long idxChannel, + long idxSeries, + GUID& gidTag, + VARIANT& value + ); +#endif + + // Internal functions + public: + bool GetChannelDefnIdx + ( + long idxChannel, + long& idxChannelDefn + ); + CPQDIF_E_Collection * GetChannelInstances( void ); + CPQDIF_E_Collection * GetOneChannel + ( + long idxChannel + ); + CPQDIF_E_Collection * GetSeriesInstances + ( + CPQDIF_E_Collection * pcolChannel + ); + CPQDIF_E_Collection * GetOneSeries + ( + CPQDIF_E_Collection * pcolChannel, + long idxSeries + ); + CPQDIF_E_Collection * GetOneSeries + ( + long idxChannel, + long idxSeries + ); + + // OVERRIDES + // Operations + public: + virtual bool ReadHeader( CPQDIF_StreamIO * pstream ) + { return m_record->ReadHeader( pstream ); } + virtual bool ReadBody( CPQDIF_StreamIO * pstream ) + { return m_record->ReadBody( pstream ); } + + virtual bool WriteHeader( CPQDIF_StreamIO * pstream ) + { return m_record->WriteHeader( pstream ); } + virtual bool WriteBody( CPQDIF_StreamIO * pstream ) + { return m_record->WriteBody( pstream ); } + + // OVERRIDES + // Attributes + public: + virtual bool HeaderGetPos( LINKABS4& pos ) const + { return m_record->HeaderGetPos( pos ); } + virtual bool HeaderSetPos( LINKABS4 pos ) + { return m_record->HeaderSetPos( pos ); } + virtual bool HeaderGetTag( GUID& tagRecord ) const + { return m_record->HeaderGetTag( tagRecord ); } + virtual bool HeaderSetTag( GUID tagRecord ) + { return m_record->HeaderSetTag( tagRecord ); } + virtual bool HeaderGetSize( SIZE4& sizeHeader, SIZE4& sizeBody ) const + { return m_record->HeaderGetSize( sizeHeader, sizeBody ); } + virtual bool HeaderSetSize( SIZE4 sizeHeader, SIZE4 sizeBody ) + { return m_record->HeaderSetSize( sizeHeader, sizeBody ); } + virtual bool HeaderGetChecksum( UINT& checksum ) const + { return m_record->HeaderGetChecksum( checksum ); } + virtual bool HeaderSetChecksum( UINT checksum ) + { return m_record->HeaderSetChecksum( checksum ); } + virtual bool HeaderGetPosNextRecord( LINKABS4& pos ) const + { return m_record->HeaderGetPosNextRecord( pos ); } + virtual bool HeaderSetPosNextRecord( LINKABS4 pos ) + { return m_record->HeaderSetPosNextRecord( pos ); } + virtual CPQDIF_E_Collection * GetMainCollection( void ) const + { return m_record->GetMainCollection(); } + virtual bool SetMainCollection( CPQDIF_E_Collection * collMain ) + { return m_record->SetMainCollection( collMain ); } + virtual bool GetChanged( void ) + { return m_record->GetChanged(); } + virtual void SetChanged( bool changed ) + { m_record->SetChanged( changed ); } + + // Private functions + private: + long _GenerateSeriesCount + ( + UINT4 idStorageMethod, + CPQDIF_E_Vector * pvectSeriesArray + ); + double * _GenerateSeriesData + ( + int idxChannelDefn, + UINT4 idStorageMethod, + double rBaseValue, + double rScale, + double rOffset, + CPQDIF_E_Vector * pvectSeriesArray, + long& countPoints + ); + bool _GenerateTimeStampArray + ( + TIMESTAMPPQDIF * result, + double * seconds, + long countPoints + ); + bool _GetCalibrationRatio + ( + int idxChannelDefn, + double& rScale + ); + + // Local data + private: + // Reference to the data source which owns this observation. + CPQDIF_R_DataSource * m_pds; + + // Reference to the monitor settings record (can be NULL) + CPQDIF_R_Settings * m_psett; + + // Reference to the record which contains the observation data. + CPQDIF_R_General * m_record; // need to fix + }; + diff --git a/LFtid1056/pqdif/include/rec_settings.cpp b/LFtid1056/pqdif/include/rec_settings.cpp new file mode 100644 index 0000000..a96c66a --- /dev/null +++ b/LFtid1056/pqdif/include/rec_settings.cpp @@ -0,0 +1,1195 @@ +/* +** CPQDIF_R_Settings class. Implements a PQDIF record "wrapper" for the +** settings record. You can cast a standard record object to this class. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: rec_settings.cpp $ +** Last modified: $Modtime: 2/22/00 5:28p $ +** Last modified by: $Author: Jack $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/rec_settings.cpp $ +** VCS revision: $Revision: 15 $ +*/ +#include "PQDIF_classes.h" + +CPQDIF_R_Settings::~CPQDIF_R_Settings() +{ + + return; + +} + +long CPQDIF_R_Settings::GetCountChannels( void ) +{ + long count = 0; + CPQDIF_E_Collection * pcolCI; + + pcolCI = GetChannelSettings(); + if( pcolCI ) + { + count = pcolCI->GetCount(); + } + + return count; +} + + +bool CPQDIF_R_Settings::GetConnectionInfo + ( + UINT4& connectionType + ) +{ + bool status = false; + + CPQDIF_E_Scalar * psc; + + // Init + connectionType = 0; + + psc = FindScalarInCollection( m_pcollMain, tagSettingPhysicalConnection ); + if( psc ) + status = psc->GetValueUINT4( connectionType ); + + return status; +} + + +bool CPQDIF_R_Settings::GetInfo + ( + TIMESTAMPPQDIF& timeEffective, + TIMESTAMPPQDIF& timeInstalled, + TIMESTAMPPQDIF& timeRemoved, + bool& useCal, + bool& useTrans + ) +{ + bool status = false; + bool foundItem = false; + + CPQDIF_E_Scalar * psc; + + // Init + memset( &timeEffective, 0, sizeof( timeEffective ) ); + memset( &timeInstalled, 0, sizeof( timeEffective ) ); + memset( &timeRemoved, 0, sizeof( timeEffective ) ); + useCal = false; + useTrans = false; + + // Find effective time (required) + status = true; + if( status ) + { + status = false; + psc = FindScalarInCollection( m_pcollMain, tagEffective ); + if( psc ) + { + foundItem = psc->GetValueTimeStamp( timeEffective ); + if( foundItem ) + { + status = true; + } + } + } + + // Find installed time (optional) + if( status ) + { + psc = FindScalarInCollection( m_pcollMain, tagTimeInstalled ); + if( psc ) + { + foundItem = psc->GetValueTimeStamp( timeInstalled ); + } + } + + // Find removed time (optional) + if( status ) + { + psc = FindScalarInCollection( m_pcollMain, tagTimeRemoved ); + if( psc ) + { + foundItem = psc->GetValueTimeStamp( timeRemoved ); + } + } + + // Find useCal (required) + if( status ) + { + status = false; + psc = FindScalarInCollection( m_pcollMain, tagUseCalibration ); + if( psc ) + { + foundItem = psc->GetValueBOOL4( useCal ); + if( foundItem ) + { + status = true; + } + } + } + + // Find useTrans (required) + if( status ) + { + status = false; + psc = FindScalarInCollection( m_pcollMain, tagUseTransducer ); + if( psc ) + { + foundItem = psc->GetValueBOOL4( useTrans ); + if( foundItem ) + { + status = true; + } + } + } + + return status; +} + +bool CPQDIF_R_Settings::GetChannelInfo (long idxChannel, UINT4 & idxChannelDefn) + { + // + // + // Initialize + // + bool foundItem = false; + + idxChannelDefn = 999999999; + + // Find the appropriate channel collection + CPQDIF_E_Collection * pcollMain = GetOneChannelSetting( idxChannel ); + if( pcollMain ) + { + PQDIFValue value; + // Find channel defn (required) + foundItem = GetScalarValueInCollection( pcollMain, tagChannelDefnIdx, ID_PHYS_TYPE_UNS_INTEGER4, value ); + if( foundItem ) + { + idxChannelDefn = value.uint4; + } + } + + return foundItem; + } + +#ifdef zap +// +// +// Most of the returned items are optional. This function +// returns 0 for those that it can't find. It returns all of +// the values it can find. It should probably return false +// if it can't find the channel definition index. I didn't +// change that for fear of side effects. +// +// This function should probably not be used. Instead, +// individual queries on each element would be more appropriate +// so that proper action can be taken when one is not available. +// Using a value of 0 to indicate non-use has many potential +// problems - EWG. +// +bool CPQDIF_R_Settings::GetChannelInfo + ( + long idxChannel, + UINT4& idxChannelDefn, + UINT4& triggerTypeID, + REAL8& fullScale, + REAL8& noiseFloor, + REAL8& triggerLow, + REAL8& triggerHigh, + REAL8& triggerRate, + CPQDIF_E_Vector& triggerShapeParam // Array of [3] ... or NULL + //REAL8 * triggerShapeParam // Array of [3] ... or NULL + ) +{ + bool status = false; + bool foundItem; + + CPQDIF_E_Collection * pcollMain; + CPQDIF_E_Collection * pcollChannel = NULL; + CPQDIF_E_Vector * pvect; + PQDIFValue value; + + long count; + long idx; + double valueREAL8; + const long countParams = 3; + + // Find the appropriate channel collection + pcollMain = GetOneChannelSetting( idxChannel ); + if( pcollMain ) + { + status = true; + } + + // Find channel defn (required) + if( status ) + { + foundItem = GetScalarValueInCollection( pcollMain, tagChannelDefnIdx, ID_PHYS_TYPE_UNS_INTEGER4, value ); + if( foundItem ) + { + idxChannelDefn = value.uint4; + status = true; + } + } + + // Find trigger type (optional) + if( status ) + { + foundItem = GetScalarValueInCollection( pcollMain, tagTriggerTypeID, ID_PHYS_TYPE_UNS_INTEGER4, value ); + if( foundItem ) + { + triggerTypeID = value.uint4; + status = true; + } + } + + // Find full scale (optional) + if( status ) + { +// status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagFullScale, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + fullScale = value.real8; + status = true; + } + } + + // Find noise floor (optional) + if( status ) + { +// status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagNoiseFloor, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + noiseFloor = value.real8; + status = true; + } + } + + // Find trigger low (optional) + if( status ) + { +// status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagTriggerLow, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + triggerLow = value.real8; + status = true; + } + } + + // Find trigger high (optional) + if( status ) + { +// status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagTriggerHigh, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + triggerHigh = value.real8; + status = true; + } + } + + + // Find trigger rate (optional) + if( status ) + { +// status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagTriggerRate, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + triggerRate = value.real8; + status = true; + } + } + + // Find trigger shape (optional) + if( status ) + { + //status = false; + + pvect = FindVectorInCollection( pcollMain, tagTriggerShapeParam ); + if( pvect ) + { + // Check size of vector + pvect->GetCount( count ); + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8 + && count == countParams ) + { + // Copy them over (pvect --> triggerShapeParam) + triggerShapeParam.SetCount( count ); + for( idx = 0; idx < count; idx++ ) + { + pvect->GetValueREAL8( idx, valueREAL8 ); + triggerShapeParam.SetValueREAL8( idx, valueREAL8 ); + } + status = true; + + } // Got the right physical type and array size + } // Found vector + } + + return status; +} +#endif + + +bool CPQDIF_R_Settings::GetChanTrans + ( + long idxChannel, + UINT4& xdTransformerTypeID, + REAL8& xdSystemSideRatio, + REAL8& xdMonitorSideRatio, + CPQDIF_E_Vector& xdFrequencyResponse // Array [n]... or NULL + ) +{ + bool status = false; + bool foundItem; + + CPQDIF_E_Collection * pcollMain; + CPQDIF_E_Collection * pcollChannel = NULL; + CPQDIF_E_Vector * pvect; + PQDIFValue value; + + long count; + long idx; + double valueREAL8; + + // Find the appropriate channel collection + pcollMain = GetOneChannelSetting( idxChannel ); + if( pcollMain ) + { + status = true; + } + + // Find xdTransformerTypeID (required) + if( status ) + { + foundItem = GetScalarValueInCollection( pcollMain, tagXDTransformerTypeID, ID_PHYS_TYPE_UNS_INTEGER4, value ); + if( foundItem ) + { + xdTransformerTypeID = value.uint4; + status = true; + } + } + + // Find xdSystemSideRatio (required) + if( status ) + { + status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagXDSystemSideRatio, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + xdSystemSideRatio = value.real8; + status = true; + } + } + + // Find xdMonitorSideRatio (required) + if( status ) + { + status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagXDMonitorSideRatio, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + xdMonitorSideRatio = value.real8; + status = true; + } + } + + // Find xdFrequencyResponse (required) + if( status ) + { + status = false; + + pvect = FindVectorInCollection( pcollMain, tagXDFrequencyResponse ); + if( pvect ) + { + // Check size of vector + pvect->GetCount( count ); + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8 ) + { + // Copy them over (pvect --> triggerShapeParam) + xdFrequencyResponse.SetCount( count ); + for( idx = 0; idx < count; idx++ ) + { + pvect->GetValueREAL8( idx, valueREAL8 ); + xdFrequencyResponse.SetValueREAL8( idx, valueREAL8 ); + } + status = true; + + } // Got the right physical type and array size + } // Found vector + } + + return status; +} + + +bool CPQDIF_R_Settings::GetChanCal + ( + long idxChannel, + REAL8& calTimeSkew, + REAL8& calOffset, + REAL8& calRatio, + bool& calMustUseARCal, + CPQDIF_E_Vector& calApplied, // Array [n] + CPQDIF_E_Vector& calRecorded // Array [n] + ) +{ + bool status = false; + bool foundItem; + + CPQDIF_E_Collection * pcollMain; + CPQDIF_E_Collection * pcollChannel = NULL; + CPQDIF_E_Vector * pvect; + PQDIFValue value; + + long count; + long idx; + double valueREAL8; + + // Find the appropriate channel collection + pcollMain = GetOneChannelSetting( idxChannel ); + if( pcollMain ) + { + status = true; + } + + // Find calTimeSkew (required) + if( status ) + { + status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagCalTimeSkew, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + calTimeSkew = value.real8; + status = true; + } + } + + // Find calOffset (required) + if( status ) + { + status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagCalOffset, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + calOffset = value.real8; + status = true; + } + } + + // Find calRatio (required) + if( status ) + { + status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagCalRatio, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + calRatio = value.real8; + status = true; + } + } + + // Find calMustUseARCal (required) + if( status ) + { + status = false; + foundItem = GetScalarValueInCollection( pcollMain, tagCalMustUseARCal, ID_PHYS_TYPE_BOOLEAN4, value ); + if( foundItem ) + { + calMustUseARCal = value.bool4 ? true : false; + status = true; + } + } + + // Find calApplied (required) + if( status ) + { + status = false; + + pvect = FindVectorInCollection( pcollMain, tagCalApplied ); + if( pvect ) + { + // Check size of vector + pvect->GetCount( count ); + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8 ) + { + // Copy them over (pvect --> triggerShapeParam) + calApplied.SetCount( count ); + for( idx = 0; idx < count; idx++ ) + { + pvect->GetValueREAL8( idx, valueREAL8 ); + calApplied.SetValueREAL8( idx, valueREAL8 ); + } + status = true; + + } // Got the right physical type and array size + } // Found vector + } + + // Find calRecorded (required) + if( status ) + { + status = false; + + pvect = FindVectorInCollection( pcollMain, tagCalRecorded ); + if( pvect ) + { + // Check size of vector + pvect->GetCount( count ); + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8 ) + { + // Copy them over (pvect --> triggerShapeParam) + calRecorded.SetCount( count ); + for( idx = 0; idx < count; idx++ ) + { + pvect->GetValueREAL8( idx, valueREAL8 ); + calRecorded.SetValueREAL8( idx, valueREAL8 ); + } + status = true; + + } // Got the right physical type and array size + } // Found vector + } + + return status; +} + + +// Set functions +// ------------- +bool CPQDIF_R_Settings::SetConnectionInfo + ( + const UINT4 connectionType + ) +{ + bool status = true; + + CPQDIF_E_Scalar * psc; + PQDIFValue value; + + // Set the connection type + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_pcollMain, + tagSettingPhysicalConnection, ID_PHYS_TYPE_UNS_INTEGER4 ); + // Set value + if( psc ) + { + value.uint4 = connectionType; + status = psc->SetValue( ID_PHYS_TYPE_UNS_INTEGER4, value ); + } + } + return status; +} + + +bool CPQDIF_R_Settings::SetInfo + ( + const TIMESTAMPPQDIF& timeEffective, + const TIMESTAMPPQDIF& timeInstalled, + const TIMESTAMPPQDIF& timeRemoved, + bool useCal, + bool useTrans + ) +{ + bool status = true; + + CPQDIF_E_Scalar * psc; + PQDIFValue value; + CPQDIF_E_Collection * pcolInstances; + + // Set times ... effective + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_pcollMain, + tagEffective, ID_PHYS_TYPE_TIMESTAMPPQDIF ); + // Set value + if( psc ) + { + value.ts = timeEffective; + status = psc->SetValue( ID_PHYS_TYPE_TIMESTAMPPQDIF, value ); + } + } + // ... installed + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_pcollMain, + tagTimeInstalled, ID_PHYS_TYPE_TIMESTAMPPQDIF ); + // Set value + if( psc ) + { + value.ts = timeInstalled; + status = psc->SetValue( ID_PHYS_TYPE_TIMESTAMPPQDIF, value ); + } + } + // ... removed + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_pcollMain, + tagTimeRemoved, ID_PHYS_TYPE_TIMESTAMPPQDIF ); + // Set value + if( psc ) + { + value.ts = timeRemoved; + status = psc->SetValue( ID_PHYS_TYPE_TIMESTAMPPQDIF, value ); + } + } + + // Flags ... useCal + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_pcollMain, + tagUseCalibration, ID_PHYS_TYPE_BOOLEAN4 ); + // Set value + if( psc ) + { + value.bool4 = useCal; + status = psc->SetValue( ID_PHYS_TYPE_BOOLEAN4, value ); + } + } + // ... useTrans + if( status ) + { + status = false; + psc = FindOrCreateScalarInCollection( m_pcollMain, + tagUseTransducer, ID_PHYS_TYPE_BOOLEAN4 ); + // Set value + if( psc ) + { + value.bool4 = useTrans; + status = psc->SetValue( ID_PHYS_TYPE_BOOLEAN4, value ); + } + } + + // Is there a collection? + pcolInstances = GetChannelSettings(); + if( !pcolInstances ) + { + // Nope, insert an empty collection ... + pcolInstances = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcolInstances->SetTag( tagChannelSettingsArray ); + m_pcollMain->Add( pcolInstances ); + } + + return status; +} + +long CPQDIF_R_Settings::AddChannel + ( + UINT4 idxChannelDefn + ) + { + long idxNew = -1; + // + // + // Is there a collection? + // + CPQDIF_E_Collection * pcolInstances = GetChannelSettings(); + if( !pcolInstances ) + { + // Nope, insert an empty collection ... + pcolInstances = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcolInstances->SetTag( tagChannelSettingsArray ); + m_pcollMain->Add( pcolInstances ); + } + + + if( pcolInstances ) + { + // Get the new index + idxNew = GetCountChannels(); + + // Create the new channel instance + CPQDIF_E_Collection * pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollOne->SetTag( tagOneChannelSetting ); + + // Stuff in the information... + pcollOne->SetScalarUINT4( tagChannelDefnIdx, idxChannelDefn ); + + // We're done filling the collection ... add it! + pcolInstances->Add( pcollOne ); + } + + return idxNew; + } + +long CPQDIF_R_Settings::AddChannel + ( + UINT4 idxChannelDefn, + UINT4 idTriggerType + ) + { + long idxNew = -1; + // + // + // Is there a collection? + // + CPQDIF_E_Collection * pcolInstances = GetChannelSettings(); + if( !pcolInstances ) + { + // Nope, insert an empty collection ... + pcolInstances = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcolInstances->SetTag( tagChannelSettingsArray ); + m_pcollMain->Add( pcolInstances ); + } + + + if( pcolInstances ) + { + // Get the new index + idxNew = GetCountChannels(); + + // Create the new channel instance + CPQDIF_E_Collection * pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollOne->SetTag( tagOneChannelSetting ); + + // Stuff in the information... + pcollOne->SetScalarUINT4( tagChannelDefnIdx, idxChannelDefn ); + pcollOne->SetScalarUINT4( tagTriggerTypeID, idTriggerType ); + + // We're done filling the collection ... add it! + pcolInstances->Add( pcollOne ); + } + + return idxNew; + } + + + +#ifdef zap +// +// +// This should only be used if all passed in parameters are used +// +long CPQDIF_R_Settings::AddChannel + ( + UINT4 idxChannelDefn, + UINT4 triggerTypeID, + REAL8 fullScale, + REAL8 noiseFloor, + REAL8 triggerLow, + REAL8 triggerHigh, + REAL8 triggerRate, + //REAL8 * triggerShapeParam // Array of [3] ... or NULL + const CPQDIF_E_Vector * triggerShapeParam // Array of [3] ... or NULL + ) + { + long idxNew = -1; + // + // + // Is there a collection? + // + CPQDIF_E_Collection * pcolInstances = GetChannelSettings(); + if( !pcolInstances ) + { + // Nope, insert an empty collection ... + pcolInstances = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcolInstances->SetTag( tagChannelSettingsArray ); + m_pcollMain->Add( pcolInstances ); + } + + CPQDIF_E_Collection * pcollOne; + + CPQDIF_E_Vector * pvect; + + long idx; + long count; + double valueParam; + const long countParams = 3; + + if( pcolInstances ) + { + // Get the new index + idxNew = GetCountChannels(); + + // Create the new channel instance + pcollOne = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + pcollOne->SetTag( tagOneChannelSetting ); + + // Stuff in the information... + pcollOne->SetScalarUINT4( tagChannelDefnIdx, idxChannelDefn ); + pcollOne->SetScalarUINT4( tagTriggerTypeID, triggerTypeID ); + + // Thresholds + pcollOne->SetScalarREAL8( tagFullScale, fullScale ); + pcollOne->SetScalarREAL8( tagNoiseFloor, noiseFloor ); + pcollOne->SetScalarREAL8( tagTriggerLow, triggerLow ); + pcollOne->SetScalarREAL8( tagTriggerHigh, triggerHigh ); + pcollOne->SetScalarREAL8( tagTriggerRate, triggerRate ); + + // Shape param + pvect = FindOrCreateVectorInCollection( pcollOne, + tagTriggerShapeParam, ID_PHYS_TYPE_REAL8 ); + // Set its value(s) + if( pvect && triggerShapeParam ) + { + // Validate physical type & size + pvect->GetCount( count ); + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8 + && count == countParams ) + { + pvect->SetCount( countParams ); + for( idx = 0; idx < countParams; idx++ ) + { + triggerShapeParam->GetValueREAL8( idx, valueParam ); + pvect->SetValueREAL8( idx, valueParam ); + } + } + } + + // We're done filling the collection ... add it! + pcolInstances->Add( pcollOne ); + } + + return idxNew; + } +#endif + +bool CPQDIF_R_Settings::SetTriggerShapeParam + ( + UINT4 idxChannel, + const CPQDIF_E_Vector * triggerShapeParam // Array of [3] ... or NULL + ) + { + bool status = false; + + CPQDIF_E_Collection * pcollOne = GetOneChannelSetting( idxChannel ); + + if( pcollOne ) + { + CPQDIF_E_Vector * pvect = FindOrCreateVectorInCollection( pcollOne, + tagTriggerShapeParam, ID_PHYS_TYPE_REAL8 ); + // + // Set its value(s) + // + if( pvect && triggerShapeParam ) + { + const long countParams = 3; + long count; + // + // + // Validate physical type & size + // + pvect->GetCount( count ); + if( pvect->GetPhysicalType() == ID_PHYS_TYPE_REAL8 + && count == countParams ) + { + double valueParam; + + pvect->SetCount( countParams ); + + for(long idx = 0; idx < countParams; idx++ ) + { + triggerShapeParam->GetValueREAL8( idx, valueParam ); + pvect->SetValueREAL8( idx, valueParam ); + } + status = true; + } + } + } + return status; + } + + +bool CPQDIF_R_Settings::GetChannelReal8(UINT4 idxChannel, GUID tag, REAL8 &dVal) + { + bool foundItem = false; + + CPQDIF_E_Collection * pcollOne = GetOneChannelSetting( idxChannel ); + + if( pcollOne ) + { + PQDIFValue value; + + foundItem = GetScalarValueInCollection( pcollOne, tag, ID_PHYS_TYPE_REAL8, value ); + if( foundItem ) + { + dVal = value.real8; + } + } + return foundItem; + } + +bool CPQDIF_R_Settings::SetChannelReal8(UINT4 idxChannel, GUID tag, REAL8 dVal) + { + bool status = false; + + CPQDIF_E_Collection * pcollOne = GetOneChannelSetting( idxChannel ); + + if( pcollOne ) + { + CPQDIF_E_Scalar * psc = FindOrCreateScalarInCollection( pcollOne, + tag, ID_PHYS_TYPE_REAL8 ); + + if( psc ) + { + psc->SetValueREAL8(dVal); + + status = true; + } + } + return status; + } + + +bool CPQDIF_R_Settings::SetChanTrans + ( + UINT4 idxChannel, + UINT4 xdTransformerTypeID, + REAL8 xdSystemSideRatio, + REAL8 xdMonitorSideRatio, + const CPQDIF_E_Vector * xdFrequencyResponse // Array [n]... or NULL + ) +{ + bool status = false; + + CPQDIF_E_Collection * pcollOne = GetOneChannelSetting( idxChannel ); + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + long idx; + long count; + double value; + + if( pcollOne ) + { + // Scalars + psc = FindOrCreateScalarInCollection( pcollOne, + tagXDTransformerTypeID, ID_PHYS_TYPE_UNS_INTEGER4 ); + if( psc ) + { + psc->SetValueUINT4( xdTransformerTypeID ); + } + psc = FindOrCreateScalarInCollection( pcollOne, + tagXDSystemSideRatio, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + psc->SetValueREAL8( xdSystemSideRatio ); + } + psc = FindOrCreateScalarInCollection( pcollOne, + tagXDMonitorSideRatio, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + psc->SetValueREAL8( xdMonitorSideRatio ); + } + + // Vector + if( xdFrequencyResponse ) + { + pvect = FindOrCreateVectorInCollection( pcollOne, + tagXDFrequencyResponse, ID_PHYS_TYPE_REAL8 ); + if( pvect && xdFrequencyResponse->GetPhysicalType() == ID_PHYS_TYPE_REAL8 ) + { + // Transfer the data over + xdFrequencyResponse->GetCount( count ); + pvect->SetCount( count ); + for( idx = 0; idx < count; idx++) + { + xdFrequencyResponse->GetValueREAL8( idx, value ); + pvect->SetValueREAL8( idx, value ); + } + } + } + + status = true; + } + + return status; +} + + +bool CPQDIF_R_Settings::SetChanCal + ( + UINT4 idxChannel, + REAL8 calTimeSkew, + REAL8 calOffset, + REAL8 calRatio, + bool calMustUseARCal, + const CPQDIF_E_Vector * calApplied, // Array [n]... or NULL + const CPQDIF_E_Vector * calRecorded // Array [n]... or NULL + ) +{ + bool status = false; + + CPQDIF_E_Collection * pcollOne = GetOneChannelSetting( idxChannel ); + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + long idx; + long count; + double value; + + if( pcollOne ) + { + // Scalars + psc = FindOrCreateScalarInCollection( pcollOne, + tagCalTimeSkew, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + psc->SetValueREAL8( calTimeSkew ); + } + psc = FindOrCreateScalarInCollection( pcollOne, + tagCalOffset, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + psc->SetValueREAL8( calOffset ); + } + psc = FindOrCreateScalarInCollection( pcollOne, + tagCalRatio, ID_PHYS_TYPE_REAL8 ); + if( psc ) + { + psc->SetValueREAL8( calRatio ); + } + psc = FindOrCreateScalarInCollection( pcollOne, + tagCalMustUseARCal, ID_PHYS_TYPE_BOOLEAN4 ); + if( psc ) + { + psc->SetValueBOOL4( (BOOL4) calMustUseARCal ); + } + + // Vectors + if( calApplied && calRecorded ) + { + // Applied + pvect = FindOrCreateVectorInCollection( pcollOne, + tagCalApplied, ID_PHYS_TYPE_REAL8 ); + if( pvect && calApplied->GetPhysicalType() == ID_PHYS_TYPE_REAL8 ) + { + // Transfer the data over + calApplied->GetCount( count ); + pvect->SetCount( count ); + for( idx = 0; idx < count; idx++) + { + calApplied->GetValueREAL8( idx, value ); + pvect->SetValueREAL8( idx, value ); + } + } + + // Recorded + pvect = FindOrCreateVectorInCollection( pcollOne, + tagCalRecorded, ID_PHYS_TYPE_REAL8 ); + if( pvect && calRecorded->GetPhysicalType() == ID_PHYS_TYPE_REAL8 ) + { + // Transfer the data over + calRecorded->GetCount( count ); + pvect->SetCount( count ); + for( idx = 0; idx < count; idx++) + { + calRecorded->GetValueREAL8( idx, value ); + pvect->SetValueREAL8( idx, value ); + } + } + } + + status = true; + } + + return status; +} + + +// Protected stuff + +CPQDIF_E_Collection * CPQDIF_R_Settings::GetChannelSettings( void ) +{ + CPQDIF_E_Collection * pcollSettings; + + // Create the collection if it does not yet exist. + pcollSettings = FindCollectionInCollection( m_pcollMain, tagChannelSettingsArray ); + if( !pcollSettings ) + { + pcollSettings = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollSettings ) + { + pcollSettings->SetTag( tagChannelSettingsArray ); + m_pcollMain->Add( pcollSettings ); + } + } + + return pcollSettings; +} + + +CPQDIF_E_Collection * CPQDIF_R_Settings::GetOneChannelSetting + ( + long idxChannel + ) +{ + CPQDIF_E_Collection * pcolReturn = NULL; + CPQDIF_E_Collection * pcolInstances = GetChannelSettings(); + CPQDIF_Element * pel; + + if( pcolInstances ) + { + pel = pcolInstances->GetElement( idxChannel ); + if( pel ) + { + if( pel->GetElementType() == ID_ELEMENT_TYPE_COLLECTION + && PQDIF_IsEqualGUID( pel->GetTag(), tagOneChannelSetting ) ) + { + pcolReturn = (CPQDIF_E_Collection *) pel; + } + } + } + + return pcolReturn; +} + +bool CPQDIF_R_Settings::SettagEffectiveAndtagTimeInstalledAndtagTimeRemoved +( + const TIMESTAMPPQDIF& timeEffective, + const TIMESTAMPPQDIF& TimeInstalled, + const TIMESTAMPPQDIF& TimeRemoved +) +{ + bool status = false; + + CPQDIF_E_Scalar * psc; + CPQDIF_E_Vector * pvect; + + if (m_pcollMain == NULL) + return false; + // First, find (or create) the trigger method + psc = FindOrCreateScalarInCollection(m_pcollMain, + tagEffective, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set its value + if (psc) + { + status = psc->SetValueTimeStamp(timeEffective); + } + + // Set the time it was triggered + if (status) + { + status = false; + psc = FindOrCreateScalarInCollection(m_pcollMain, + tagTimeInstalled, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set value + if (psc) + { + status = psc->SetValueTimeStamp(TimeInstalled); + } + } + + // Set the time it was triggered + if (status) + { + status = false; + psc = FindOrCreateScalarInCollection(m_pcollMain, + tagTimeRemoved, ID_PHYS_TYPE_TIMESTAMPPQDIF); + // Set value + if (psc) + { + status = psc->SetValueTimeStamp(TimeRemoved); + } + } + return status; + +} \ No newline at end of file diff --git a/LFtid1056/pqdif/include/rec_settings.h b/LFtid1056/pqdif/include/rec_settings.h new file mode 100644 index 0000000..a4a5134 --- /dev/null +++ b/LFtid1056/pqdif/include/rec_settings.h @@ -0,0 +1,291 @@ +// File name: $Workfile: rec_settings.h $ +// Last modified: $Modtime: 2/22/00 7:35p $ +// Last modified by: $Author: Jack $ +// +// VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/rec_settings.h $ +// VCS revision: $Revision: 13 $ + +class CPQDIF_R_Settings : public CPQDIF_R_General + { + public: + CPQDIF_R_Settings() {} + virtual ~CPQDIF_R_Settings() ; + + // Operations + public: + + // Attributes + public: + + // Read functions + bool GetInfo + ( + TIMESTAMPPQDIF& timeEffective, + TIMESTAMPPQDIF& timeInstalled, + TIMESTAMPPQDIF& timeRemoved, + bool& useCal, + bool& useTrans + ); + + bool GetConnectionInfo + ( + UINT4& connectionType + ); + + long GetCountChannels( void ); + + bool GetChannelInfo (long idxChannel, UINT4 & idxChannelDefn); + +#ifdef zap + // + // + // Depricated function + // + bool GetChannelInfo + ( + long idxChannel, + UINT4& idxChannelDefn, + UINT4& triggerTypeID, + REAL8& fullScale, + REAL8& noiseFloor, + REAL8& triggerLow, + REAL8& triggerHigh, + REAL8& triggerRate, + CPQDIF_E_Vector& triggerShapeParam // Array of [3] + ); +#endif + + bool GetChanTrans + ( + long idxChannel, + UINT4& xdTransformerTypeID, + REAL8& xdSystemSideRatio, + REAL8& xdMonitorSideRatio, + CPQDIF_E_Vector& xdFrequencyResponse // Array [n] + ); + bool GetChanCal + ( + long idxChannel, + REAL8& calTimeSkew, + REAL8& calOffset, + REAL8& calRatio, + bool& calMustUseARCal, + CPQDIF_E_Vector& calApplied, // Array [n] + CPQDIF_E_Vector& calRecorded // Array [n] + ); + + // Write functions + bool SetInfo + ( + const TIMESTAMPPQDIF& timeEffective, + const TIMESTAMPPQDIF& timeInstalled, + const TIMESTAMPPQDIF& timeRemoved, + bool useCal, + bool useTrans + ); + + + bool SetConnectionInfo + ( + const UINT4 connectionType + ); + +#ifdef zap + // + // + // Depricated function + // + long AddChannel + ( + UINT4 idxChannelDefn, + UINT4 triggerTypeID, + REAL8 fullScale, + REAL8 noiseFloor, + REAL8 triggerLow, + REAL8 triggerHigh, + REAL8 triggerRate, + const CPQDIF_E_Vector * triggerShapeParam // Array of [3] ... or NULL + ); +#endif + long AddChannel + ( + UINT4 idxChannel + ); + long AddChannel + ( + UINT4 idxChannel, + UINT4 idTriggerType + ); + + + + bool SetChanTrans + ( + UINT4 idxChannel, + UINT4 xdTransformerTypeID, + REAL8 xdSystemSideRatio, + REAL8 xdMonitorSideRatio, + const CPQDIF_E_Vector * xdFrequencyResponse // Array [n]... or NULL + ); + bool SetChanCal + ( + UINT4 idxChannel, + REAL8 calTimeSkew, + REAL8 calOffset, + REAL8 calRatio, + bool calMustUseARCal, + const CPQDIF_E_Vector * calApplied, // Array [n]... or NULL + const CPQDIF_E_Vector * calRecorded // Array [n]... or NULL + ); + + bool SetTriggerShapeParam + ( + UINT4 idxChannelDefn, + const CPQDIF_E_Vector * triggerShapeParam // Array of [3] ... or NULL + ); + + + bool SetChannelReal8(UINT4 idxChannel, GUID tag, REAL8 dVal); + + bool SetTriggerLow(const UINT4 idxChannel, const REAL8 dVal) + { + return SetChannelReal8(idxChannel, tagTriggerLow, dVal); + } + + bool SetTriggerHigh(const UINT4 idxChannel, const REAL8 dVal) + { + return SetChannelReal8(idxChannel, tagTriggerHigh, dVal); + } + + bool SetTriggerRate(const UINT4 idxChannel, const REAL8 dVal) + { + return SetChannelReal8(idxChannel, tagTriggerRate, dVal); + } + + bool SetFullScale(const UINT4 idxChannel, const REAL8 dVal) + { + return SetChannelReal8(idxChannel, tagFullScale, dVal); + } + + bool SetNoiseFloor(const UINT4 idxChannel, const REAL8 dVal) + { + return SetChannelReal8(idxChannel, tagNoiseFloor, dVal); + } + + bool SetEffective (const TIMESTAMPPQDIF& timeEffective) + { + return SetTimeInMainCollection(tagEffective, timeEffective); + } + + bool SetInstalled (const TIMESTAMPPQDIF& timeInstalled) + { + return SetTimeInMainCollection(tagTimeInstalled, timeInstalled); + } + + bool SetRemoved (const TIMESTAMPPQDIF& timeRemoved) + { + return SetTimeInMainCollection(tagTimeRemoved, timeRemoved); + } + + bool SetNominalFrequency(const REAL8 dVal) + { + return SetREAL8InMainCollection(tagNominalFrequency, dVal); + } + + bool SetUseCalibration(const BOOL4 bVal) + { + return SetBOOL4InMainCollection(tagUseCalibration, bVal); + } + + bool SetUseTransducer(const BOOL4 bVal) + { + return SetBOOL4InMainCollection(tagUseTransducer, bVal); + } + + bool SettagIsPCC(const BOOL4 bVal) + { + return SetBOOL4InMainCollection(tagIsPCC, bVal); + } + + bool SetNominalVoltage(const UINT4 bVal) + { + return SetREAL8InMainCollection(tagNominalVoltage, bVal); + } + + bool GetChannelReal8(UINT4 idxChannel, GUID tag, REAL8 &dVal); + + bool GetTriggerLow(const UINT4 idxChannel, REAL8 &dVal) + { + return GetChannelReal8(idxChannel, tagTriggerLow, dVal); + } + + bool GetTriggerHigh(const UINT4 idxChannel, REAL8 &dVal) + { + return GetChannelReal8(idxChannel, tagTriggerHigh, dVal); + } + + bool GetTriggerRate(const UINT4 idxChannel, REAL8 &dVal) + { + return GetChannelReal8(idxChannel, tagTriggerRate, dVal); + } + + bool GetFullScale(const UINT4 idxChannel, REAL8 &dVal) + { + return GetChannelReal8(idxChannel, tagFullScale, dVal); + } + + bool GetNoiseFloor(const UINT4 idxChannel, REAL8 &dVal) + { + return GetChannelReal8(idxChannel, tagNoiseFloor, dVal); + } + + bool GetEffective (TIMESTAMPPQDIF& timeEffective) + { + return GetTimeInMainCollection(tagEffective, timeEffective); + } + + bool GetInstalled (TIMESTAMPPQDIF& timeInstalled) + { + return GetTimeInMainCollection(tagTimeInstalled, timeInstalled); + } + + bool GetRemoved (TIMESTAMPPQDIF& timeRemoved) + { + return GetTimeInMainCollection(tagTimeRemoved, timeRemoved); + } + + bool GetNominalFrequency(REAL8 &dVal) + { + return GetREAL8InMainCollection(tagNominalFrequency, dVal); + } + + bool GetUseCalibration(BOOL4 &bVal) + { + return GetBOOL4InMainCollection(tagUseCalibration, bVal); + } + + bool GetUseTransducer(BOOL4 &bVal) + { + return GetBOOL4InMainCollection(tagUseTransducer, bVal); + } + + bool SettagEffectiveAndtagTimeInstalledAndtagTimeRemoved + ( + const TIMESTAMPPQDIF& timeEffective, + const TIMESTAMPPQDIF& TimeInstalled, + const TIMESTAMPPQDIF& TimeRemoved + ); + + // Internal functions + public: + CPQDIF_E_Collection * GetChannelSettings( void ); + CPQDIF_E_Collection * GetOneChannelSetting + ( + long idxChannelDefn + ); + + // Local data + private: + // None + }; + diff --git a/LFtid1056/pqdif/include/ser_alloc.cpp b/LFtid1056/pqdif/include/ser_alloc.cpp new file mode 100644 index 0000000..3c1cef7 --- /dev/null +++ b/LFtid1056/pqdif/include/ser_alloc.cpp @@ -0,0 +1,589 @@ +/* +** PQAlloc class. A simple allocator class that understands all of the +** fundamental PQDIF physical types. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: ser_alloc.cpp $ +** Last modified: $Modtime: 9/03/98 9:52a $ +** Last modified by: $Author: Rob $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/ser_alloc.cpp $ +** VCS revision: $Revision: 5 $ +*/ +#include "PQDIF_classes.h" + + + +/* +** +** Private node structure +*/ +struct MemNode + { + void * obj; + size_t siz; + + MemNode * pPrev; + MemNode * pNext; + }; + + +// Memory debug +const int sizeGuardBand = 8; +const DWORD dataGuardBand = 121458711L; + + + +void PQAlloc::Reinitialize(long offset) + { + DestroyList(); + Initialize(); + idxOffset = offset; + } + +void PQAlloc::Initialize() + { +// DebugPrint("Initialize PQAlloc\n"); + bShowMessage = 0; + lMemTotal = 0; + idxOffset = 0; + pmemFirst = 0; + pmemLast = 0; + } + +PQAlloc::PQAlloc() + { +// DebugPrint("Create PQAlloc\n"); + Initialize(); + } + +PQAlloc::~PQAlloc() + { + DestroyList(); +// DebugPrint("Destroy PQAlloc\n"); + } + +//static char szBuffer[80]; + +void *PQAlloc::allocate(size_t siz) + { + size_t siz_obj; + void *obj; + + siz_obj = siz; + obj = calloc( 1, siz + sizeGuardBand ); + + // Fill guard band with special p + // + if( sizeGuardBand > 0 ) + { + DWORD *pdw = (DWORD *)((char *)obj+siz); + *pdw = dataGuardBand; + } + + // Link memory object into list + // + LinkIn( obj, siz_obj ); + + return obj; + } + +void *PQAlloc::allocate(size_t siz, long &idx) + { + /* + ** + ** Return offset into file for this object + */ + idx = lMemTotal + idxOffset; + + return allocate(siz); + } + + +c_collection_element * PQAlloc::addCollection + ( + UINT4 count, + long & idx, + SIZE4& size + ) + { + struct c_collection * pcoll = NULL; + struct c_collection_element * parrayElement = NULL; + + size = sizeof( c_collection ) + ( count * sizeof( c_collection_element ) ); + size = theInfo.padSizeTo4Bytes( size ); + + pcoll = (c_collection *) allocate( size, idx ); + if( pcoll ) + { + // Init the collection header + pcoll->count = count; + + // Find the beginning of the array + parrayElement = ( c_collection_element * ) ( ( (char *) pcoll ) + sizeof ( *pcoll ) ); + } + + return parrayElement; + } + + +c_collection_element * PQAlloc::addCollection + ( + UINT4 count, + long & idx, + SIZE4& size, + const GUID& tag, + c_collection_element& ce + ) + { + struct c_collection_element * parrayElement = NULL; + + parrayElement = addCollection( count, idx, size ); + if( parrayElement ) + { + // Set up the collection element properly + ce.tagElement = tag; + ce.typeElement = ID_ELEMENT_TYPE_COLLECTION; + ce.typePhysical = 0; // ??? + ce.isEmbedded = FALSE; + ce.reserved = 0; + ce.link.linkElement = idx; + ce.link.sizeElement = size; + } + + return parrayElement; + } + + +bool PQAlloc::addScalarValue + ( + long typePhysical, + PQDIFValue value, + long & idx, + SIZE4& size, + const GUID& tag, + c_collection_element& ce + ) + { + bool status = FALSE; + SIZE4 sizeValue; + BYTE * pdata; + + // Init the element header + ce.tagElement = tag; + ce.typeElement = ID_ELEMENT_TYPE_SCALAR; + ce.typePhysical = (INT1) typePhysical; + ce.isEmbedded = FALSE; + ce.reserved = 0; + + // Init + pdata = NULL; + + sizeValue = theInfo.GetNumBytesOfType( typePhysical ); + if( sizeValue <= sizeof( ce.valueEmbedded ) ) + { + // This is less than 8 bytes -- no allocation necessary + // Thereforem, it IS embedded + ce.isEmbedded = TRUE; + size = 0; // No add'l space allocated + + // Set up the collection element properly + pdata = (BYTE *)( ce.valueEmbedded ); + } + else + { + // Not embedded; gotta allocate memory (be sure to pad it + // to 4 bytes). + size = theInfo.padSizeTo4Bytes( sizeValue ); + pdata = (BYTE *) allocate( size, idx ); + if( pdata ) + { + // Set up the collection element properly + ce.link.linkElement = idx; + ce.link.sizeElement = size; + } + } + + // If we have the pointer, convert the value itself + if( pdata ) + { + convertValue( typePhysical, value, pdata ); + status = TRUE; + } + + return status; + } + + +bool PQAlloc::addVectorValue + ( + long typePhysical, + long count, + //PQDIFValue ** values, + BYTE * values, + long & idx, + SIZE4& size, + const GUID & tag, + c_collection_element& ce + ) + { + bool status = FALSE; + SIZE4 sizeValue; + //long idxValue; + + struct c_vector * pvector = NULL; + BYTE * pdata = NULL; + + // Init the element header + ce.tagElement = tag; + ce.typeElement = ID_ELEMENT_TYPE_VECTOR; + ce.typePhysical = (INT1) typePhysical; + ce.isEmbedded = FALSE; + ce.reserved = 0; + + // Determine the size of the vector + sizeValue = theInfo.GetNumBytesOfType( typePhysical ); + size = sizeof( c_vector ) + ( count * sizeValue ); + size = theInfo.padSizeTo4Bytes( size ); + + // Allocate the vector + pvector = (c_vector *) allocate( size, idx ); + if( pvector ) + { + // Init the vector header + pvector->count = count; + + // Copy over the string portion + pdata = (BYTE *) ( ( (BYTE *) pvector ) + sizeof( c_vector ) ); + if( pdata ) + { + // Convert all the values in the array... + memcpy( pdata, values, count * sizeValue ); + //for( idxValue = 0; idxValue < count; idxValue++ ) + //{ + //convertValue( typePhysical, *( values[ idxValue ] ), pdata ); + //pdata += sizeValue; + //} + + // All values in array have been transferred... + ce.link.linkElement = idx; + ce.link.sizeElement = size; + status = TRUE; + } + + } // if( pvector ) + + return status; + } + + +bool PQAlloc::convertValue + ( + long typePhysical, + PQDIFValue value, + BYTE * pdata + ) + { + bool status = TRUE; + + switch( typePhysical ) + { + case ID_PHYS_TYPE_BOOLEAN1: + *( (BOOL1 *) pdata ) = value.bool1; + break; + + case ID_PHYS_TYPE_CHAR1: + *( (CHAR1 *) pdata ) = value.char1; + break; + + case ID_PHYS_TYPE_INTEGER1: + *( (INT1 *) pdata ) = value.int1; + break; + + case ID_PHYS_TYPE_UNS_INTEGER1: + *( (UINT1 *) pdata ) = value.uint1; + break; + + case ID_PHYS_TYPE_BOOLEAN2: + *( (BOOL2 *) pdata ) = value.bool2; + break; + + case ID_PHYS_TYPE_CHAR2: + *( (CHAR2 *) pdata ) = value.char2; + break; + + case ID_PHYS_TYPE_INTEGER2: + *( (INT2 *) pdata ) = value.int2; + break; + + case ID_PHYS_TYPE_UNS_INTEGER2: + *( (UINT2 *) pdata ) = value.uint2; + break; + + case ID_PHYS_TYPE_BOOLEAN4: + *( (BOOL4 *) pdata ) = value.bool4; + break; + + case ID_PHYS_TYPE_INTEGER4: + *( (INT4 *) pdata ) = value.int4; + break; + + case ID_PHYS_TYPE_UNS_INTEGER4: + *( (UINT4 *) pdata ) = value.uint4; + break; + + case ID_PHYS_TYPE_REAL4: + *( (REAL4 *) pdata ) = value.real4; + break; + + case ID_PHYS_TYPE_REAL8: + *( (REAL8 *) pdata ) = value.real8; + break; + + case ID_PHYS_TYPE_COMPLEX8: + *( (COMPLEX8 *) pdata ) = value.complex8; + break; + + case ID_PHYS_TYPE_COMPLEX16: + *( (COMPLEX16 *) pdata ) = value.complex16; + break; + + case ID_PHYS_TYPE_TIMESTAMPPQDIF: + *( (ts *) pdata ) = value.ts; + break; + + case ID_PHYS_TYPE_GUID: + *( (GUID *) pdata ) = value.guid ; + break; + + default: + status = FALSE; + break; + } + + return status; + } + + +void PQAlloc::deallocate( void *obj ) + { + LinkOut( obj ); + free( obj ); + } + + +void PQAlloc::LinkIn(void *obj, size_t siz) + { + MemNode *pNode; + /* + ** + ** Allocate a new node + */ + pNode = (MemNode *) calloc( 1, sizeof( MemNode ) ); + pNode->obj = obj; + pNode->siz = siz; + pNode->pNext = 0; + /* + ** + ** Save position suitable for use as the file offset + */ + lMemTotal += siz; + idxFilePosition = lMemTotal + idxOffset; + /* + ** + ** Put in chain + */ + if ( pmemLast ) + pmemLast->pNext = pNode; + else + pmemFirst = pNode; + pNode->pPrev = pmemLast; + pmemLast = pNode; + } + +int PQAlloc::LinkOut( void *obj ) + { + MemNode *pNode; + int rc = 0; + + pNode = pmemFirst; + while (pNode) + { + if (obj == pNode->obj) + { + if (pNode->pPrev) + pNode->pPrev->pNext = pNode->pNext; + else + pmemFirst = pNode->pNext; + + if (pNode->pNext) + pNode->pNext->pPrev = pNode->pPrev; + else + pmemLast = pNode->pPrev; + + lMemTotal -= pNode->siz; + + if( sizeGuardBand ) + { + DWORD *pdw = (DWORD *)( (char *) obj+pNode->siz ); + if( *pdw != dataGuardBand ) + { + if (bShowMessage) + { + //DebugPrint("Corrupted memory guard - %lu\n", *pdw); + // if (pNode->pszText) + // DebugPrint("obj= %p, size= %u, sz= %s\n", + // pNode->obj, pNode->siz, pNode->pszText); + // else + // DebugPrint("obj= %p, size= %u, Unknown location\n", + // pNode->obj, pNode->siz); + } + } + } + +// if (pNode->pszText) +// free(pNode->pszText); + free( pNode ); + rc = TRUE; + break; + } + pNode = pNode->pNext; + } + + return rc; + } + +void PQAlloc::WalkList() + { + MemNode *pNode; + + if (!bShowMessage) + return; + + pNode = pmemFirst; + //if (pNode == NULL) + // DebugPrint("The memory list is empty.\n"); + while (pNode) + { +// if (pNode->pszText) +// DebugPrint("obj= %p, size= %u, sz= %s\n", +// pNode->obj, pNode->siz, pNode->pszText); +// else +// DebugPrint("obj= %p, size= %u, Unknown location\n", +// pNode->obj, pNode->siz); + + pNode = pNode->pNext; + } + } + +long PQAlloc::WriteListToFile(FILE *pf) + { + MemNode *pNode; + + pNode = pmemFirst; + //if (pNode == NULL) + // DebugPrint("The memory list is empty.\n"); + while (pNode) + { + fwrite(pNode->obj, 1, pNode->siz, pf); + +// if (pNode->pszText) +// DebugPrint("obj= %p, size= %u, sz= %s\n", +// pNode->obj, pNode->siz, pNode->pszText); +// else +// DebugPrint("obj= %p, size= %u, Unknown location\n", +// pNode->obj, pNode->siz); + + pNode = pNode->pNext; + } + return idxFilePosition; + } + + +long PQAlloc::WriteListToStream( CPQDIF_StreamIO *pstrm ) + { + MemNode * pNode; + int sizeActualTotal; + + sizeActualTotal = 0; + + pstrm->BeginBlock(); + + pNode = pmemFirst; + //if (pNode == NULL) + // DebugPrint("The memory list is empty.\n"); + while (pNode) + { + pstrm->AppendBlock( (BYTE *) pNode->obj, pNode->siz ); + +// if (pNode->pszText) +// DebugPrint("obj= %p, size= %u, sz= %s\n", +// pNode->obj, pNode->siz, pNode->pszText); +// else +// DebugPrint("obj= %p, size= %u, Unknown location\n", +// pNode->obj, pNode->siz); + + pNode = pNode->pNext; + } + + pstrm->WriteBlock( sizeActualTotal ); + + return sizeActualTotal; + } + + +void PQAlloc::DestroyList() + { + MemNode *pNode; + MemNode *pNext; + + pNode = pmemFirst; + while (pNode) + { + pNext = pNode->pNext; + + if (pNode->obj) + free(pNode->obj); + free(pNode); + + pNode = pNext; + } + } + +//int cdecl DebugPrint (char *szFormat,...) +// { +// char szBuffer [255]; +// va_list arg_ptr; +// +// va_start (arg_ptr, szFormat); +// +// vsprintf (szBuffer, szFormat, arg_ptr); +// +// //printf(szBuffer); +// +//#ifdef _DEBUG +// //DebugOutput( DBF_TRACE, szBuffer ); +//#endif +// +// return (0); +// } + +#ifndef NOAUXPRINT + +//int cdecl AuxPrint (char *szFormat,...) +// { +// char szBuffer [255]; +// va_list arg_ptr; +// +// va_start (arg_ptr, szFormat); +// +// vsprintf (szBuffer, szFormat, arg_ptr); +// +//// OutputDebugString(szBuffer); +// +// return (0); +// } + +#endif + + diff --git a/LFtid1056/pqdif/include/ser_alloc.h b/LFtid1056/pqdif/include/ser_alloc.h new file mode 100644 index 0000000..32d4e95 --- /dev/null +++ b/LFtid1056/pqdif/include/ser_alloc.h @@ -0,0 +1,101 @@ +// File name: $Workfile: ser_alloc.h $ +// Last modified: $Modtime: 2/09/98 12:08p $ +// Last modified by: $Author: Rob $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/ser_alloc.h $ +// VCS revision: $Revision: 3 $ + +#ifndef PQALLOC_INC +#define PQALLOC_INC + +//#define bool short +//#define DWORD unsigned long +//#define TRUE 1 +//#define FALSE 0 + +struct MemNode; +class PQAlloc + { + private: + void LinkIn (void * obj, size_t siz); + int LinkOut(void * obj); + + MemNode * pmemFirst; + MemNode * pmemLast; + + protected: + public: + PQAlloc(); + ~PQAlloc(); + + void Initialize(); + void Reinitialize(long offset = 0L); + + bool bShowMessage; + long lMemTotal; // Total size of objects managed in allocator + + long idxFilePosition; // next available position in pseudo file + long idxOffset; // Offset to be added to the idx + // parameter returned by allocate + // Used to allow resetting allocators + // but return correct file offset + + void *allocate(size_t siz); + void *allocate(size_t siz, long &idx); + + // Routines to add specific PQDIF elements + c_collection_element * addCollection + ( + UINT4 count, + long & idx, + SIZE4& size + ); + c_collection_element * addCollection + ( + UINT4 count, + long & idx, + SIZE4& size, + const GUID& tag, + c_collection_element& ce + ); + bool addScalarValue + ( + long typePhysical, + PQDIFValue value, + long & idx, + SIZE4& size, + const GUID& tag, + c_collection_element& ce + ); + bool addVectorValue + ( + long typePhysical, + long count, + BYTE * values, + long & idx, + SIZE4& size, + const GUID & tag, + c_collection_element& ce + ); + + static bool convertValue + ( + long typePhysical, + PQDIFValue value, + BYTE * pdata + ); + + void deallocate(void * obj); + + long WriteListToFile(FILE *pf); + long WriteListToStream( CPQDIF_StreamIO *pf ); + + void WalkList(); + void DestroyList(); + + }; + +//extern int cdecl AuxPrint (char *szFormat,...); +//extern int cdecl DebugPrint (char *szFormat,...); + +#endif diff --git a/LFtid1056/pqdif/include/ser_cont_el.cpp b/LFtid1056/pqdif/include/ser_cont_el.cpp new file mode 100644 index 0000000..de7f600 --- /dev/null +++ b/LFtid1056/pqdif/include/ser_cont_el.cpp @@ -0,0 +1,178 @@ +/* +** PQController class. This class is used to control the reconstitution +** of PQDIF element objects from a buffer where they have been archived. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: ser_cont_el.cpp $ +** Last modified: $Modtime: 10/07/02 7:41a $ +** Last modified by: $Author: Jack $ +** +** VCS archive path: $Archive: /PQDIF/PQDcom/PQDcom4/pqdiflib/ser_cont_el.cpp $ +** VCS revision: $Revision: 11 $ +*/ +#include "PQDIF_classes.h" + + + +// Construction +// ============ + +PQController::PQController( void ) + { + } + +PQController::~PQController( void ) + { + } + + +void PQController::ParseRecord + ( + BYTE * buffer, + SIZE4 size, + CPQDIF_E_Collection * pcollMain + ) + { + + PQDIFIterator piter( this, buffer, size, 0, pcollMain ); + piter.ParseCollection(); + + return; + } + + +CPQDIF_E_Collection * PQController::acceptCollection + ( + CPQDIF_E_Collection * pcoll, + int /*index*/, + const GUID& tag + ) + { + CPQDIF_E_Collection * pcollNew; + + // Create the new collection object + pcollNew = (CPQDIF_E_Collection *) theFactory.NewElement( ID_ELEMENT_TYPE_COLLECTION ); + if( pcollNew ) + { + + // Add it to the previous collection + pcollNew->SetTag( tag ); + pcoll->Add( pcollNew ); + + } + + return pcollNew; + } + + +CPQDIF_E_Scalar * PQController::acceptScalar + ( + CPQDIF_E_Collection * pcoll, + int /*index*/, + const GUID& tag, + long typePhysical, + void * pdata + ) + { + CPQDIF_E_Scalar * pel; + + //ASSERT( pdata ); + + // Create new element + pel = (CPQDIF_E_Scalar *) theFactory.NewElement( ID_ELEMENT_TYPE_SCALAR ); + //ASSERT( pel ); + if( pel ) + { + // Initialize it. If successful then ... + pel->SetTag( tag ); + if( pel->SetValue( typePhysical, *(PQDIFValue *)pdata ) ) + { + + // Add it to the current collection + //ASSERT( pcoll ); + pcoll->Add( pel ); + + } + else + { + delete pel; + pel = NULL; + } + + } + + return pel; + } + + +CPQDIF_E_Vector * PQController::acceptVector + ( + CPQDIF_E_Collection * pcoll, + int index, + const GUID& tag, + long typePhysical, + c_vector * pvector, + void * pdata + ) + { + SIZE4 sizeValue; + CPQDIF_E_Vector * pel = NULL; + + // Validate parameters + //ASSERT( pvector ); + //ASSERT( pdata ); + + // Init + sizeValue = theInfo.GetNumBytesOfType( typePhysical ); + SIZE4 TotalSize = sizeValue * pvector->count; + if ((TotalSize > 0) && (TotalSize < 1000000)) + { + + // Create new element + pel = (CPQDIF_E_Vector *) theFactory.NewElement( ID_ELEMENT_TYPE_VECTOR ); + //ASSERT( pel ); + if( pel ) + { + + // Initialize it + pel->SetTag( tag ); + pel->SetPhysicalType( typePhysical ); + if( pel->SetCount( pvector->count ) ) + { + memcpy( pel->GetRawData(), pdata, pvector->count * sizeValue ); + + // Add the element to the current collection + //ASSERT( pcoll ); + pcoll->Add( pel ); + + } + else + { + delete pel; + pel = NULL; + } + + } + } + + return pel; + } + + +bool PQController::decodeValue + ( + long typePhysical, + void * pdata, + PQDIFValue& value + ) + { + bool status = false; + int iSize = theInfo.GetNumBytesOfType( typePhysical ); + if( iSize > 0 ) + { + memcpy( (void *)&value, pdata, iSize ); + status = true; + } + return status; + } + diff --git a/LFtid1056/pqdif/include/ser_cont_el.h b/LFtid1056/pqdif/include/ser_cont_el.h new file mode 100644 index 0000000..0a6a8d7 --- /dev/null +++ b/LFtid1056/pqdif/include/ser_cont_el.h @@ -0,0 +1,62 @@ +// File name: $Workfile: ser_cont_el.h $ +// Last modified: $Modtime: 11/21/00 5:20p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/ser_cont_el.h $ +// VCS revision: $Revision: 5 $ + +class CPQDIF_E_Collection; + +class PQController + { + public: + PQController(); + virtual ~PQController(); + + virtual void ParseRecord + ( + BYTE * buffer, + SIZE4 size, + CPQDIF_E_Collection * pcollMain + ); + + // Routines to add specific PQDIF elements + + // If return value is TRUE, the Iterator object + // will continue iterating through the elements + // in the collection. If FALSE, the collection + // will be skipped. + virtual CPQDIF_E_Collection * acceptCollection + ( + CPQDIF_E_Collection * pcoll, + int index, + const GUID& tag + ); + virtual CPQDIF_E_Scalar * acceptScalar + ( + CPQDIF_E_Collection * pcoll, + int index, + const GUID& tag, + long typePhysical, + void * pdata + ); + virtual CPQDIF_E_Vector * acceptVector + ( + CPQDIF_E_Collection * pcoll, + int index, + const GUID& tag, + long typePhysical, + c_vector * pvector, + void * pdata + ); + + static bool decodeValue + ( + long typePhysical, + void * pdata, + PQDIFValue& value + ); + + protected: + + }; diff --git a/LFtid1056/pqdif/include/ser_iter_el.cpp b/LFtid1056/pqdif/include/ser_iter_el.cpp new file mode 100644 index 0000000..3c0b0dd --- /dev/null +++ b/LFtid1056/pqdif/include/ser_iter_el.cpp @@ -0,0 +1,177 @@ +/* +** PQDIFIterator class. Implements iteration through a set of PQDIF elements +** (stored in a collection) in order to reconstitute them from a buffer. +** Used in conjunction with the PQController class. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: ser_iter_el.cpp $ +** Last modified: $Modtime: 11/21/00 5:31p $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/ser_iter_el.cpp $ +** VCS revision: $Revision: 8 $ +*/ +#include "PQDIF_classes.h" + + +// Construction +// ============ + +PQDIFIterator::PQDIFIterator + ( + PQController * pcont, + BYTE * buffer, + SIZE4 size, + long pos, + CPQDIF_E_Collection * pcoll + ) + { + m_pcont = pcont; + + m_buffer = buffer; + m_size = size; + m_pos = pos; + + m_pcoll = pcoll; + } + + +PQDIFIterator::~PQDIFIterator() + { + } + + +bool PQDIFIterator::ParseCollection( void ) + { + INT4 idx; + bool accepted = false; + c_collection collection; + c_collection_element * pelement; + + + // Get collection header + collection = *( (c_collection*) ( m_buffer + m_pos ) ); + m_pos += sizeof( collection ); + //ASSERT( m_pos < m_size || ( m_pos == m_size && collection.count == 0 ) ); + //ASSERT( m_pos >= 0 ); + + // For each element in the collection do ... + pelement = (c_collection_element *) ( m_buffer + m_pos ); + for( idx = 0; idx < collection.count; idx++, pelement++ ) + { + // See what type it is, and see if it can be accepted + switch( pelement->typeElement ) + { + case ID_ELEMENT_TYPE_COLLECTION: + { + CPQDIF_E_Collection * pcoll = m_pcont->acceptCollection( + m_pcoll, + idx, + pelement->tagElement ); + accepted = pcoll != NULL; + if( accepted ) + { + // Seek to the link (to the container header) + m_pos = pelement->link.linkElement; + //ASSERT( m_pos < m_size ); + //ASSERT( m_pos > 0 ); + + if( m_pos >= m_size || m_pos <= 0 ) + { + goto PQITPC_Abort; + } + + // Should be at the right file position for this collection + PQDIFIterator iter( + m_pcont, + m_buffer, + m_size, + m_pos, + pcoll ); + + // Recursively parse the new collection + accepted = iter.ParseCollection(); + + } + } + break; + + case ID_ELEMENT_TYPE_SCALAR: + { + + // Alloc & read data + BYTE * pdata; + if( pelement->isEmbedded ) + { + // Pull the data from the embedded value + pdata = (BYTE *) pelement->valueEmbedded; + } + else + { + // Seek to the link + m_pos = pelement->link.linkElement; + //ASSERT( m_pos < m_size ); + //ASSERT( m_pos > 0 ); + if( m_pos >= m_size || m_pos < 0 ) + { + goto PQITPC_Abort; + } + + pdata = (BYTE *) ( m_buffer + m_pos ); + } + + // Accept data? + accepted = m_pcont->acceptScalar( + m_pcoll, + idx, + pelement->tagElement, + pelement->typePhysical, + (void *) pdata) != NULL; + + } + break; + + case ID_ELEMENT_TYPE_VECTOR: + { + + // Seek to the link (to the vector header) + m_pos = pelement->link.linkElement; + //ASSERT( m_pos < m_size ); + //ASSERT( m_pos > 0 ); + if( m_pos >= m_size || m_pos < 0 ) + { + goto PQITPC_Abort; + } + + // Grab vector header + c_vector vector = *( (c_vector *) ( m_buffer + m_pos ) ); + m_pos += sizeof( vector ); + + // It is possible that this points off the end, + // if vector.count == 0. + //ASSERT( m_pos < m_size || vector.count == 0 ); + //ASSERT( m_pos > 0 ); + + // Grab pointer to data + BYTE * pdata = (BYTE *) ( m_buffer + m_pos ); + + // Accept data? (The acceptVector() function + // must be careful not to go off the end if + // vector.count == 0. + accepted = m_pcont->acceptVector( + m_pcoll, + idx, + pelement->tagElement, + pelement->typePhysical, + &vector, + (void *) pdata) != NULL; + + } + break; + } // switch() + } // for () + +PQITPC_Abort: + + return accepted; + } diff --git a/LFtid1056/pqdif/include/ser_iter_el.h b/LFtid1056/pqdif/include/ser_iter_el.h new file mode 100644 index 0000000..00220a8 --- /dev/null +++ b/LFtid1056/pqdif/include/ser_iter_el.h @@ -0,0 +1,41 @@ +// File name: $Workfile: ser_iter_el.h $ +// Last modified: $Modtime: 11/21/00 4:50p $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/ser_iter_el.h $ +// VCS revision: $Revision: 3 $ + + +class PQController; + +class PQDIFIterator + { + public: + PQDIFIterator + ( + PQController * pcont, + BYTE * buffer, + SIZE4 size, + long pos, + CPQDIF_E_Collection * pcoll + ); + ~PQDIFIterator(); + + bool ParseCollection( void ); + + protected: + // Who wants the results? + PQController * m_pcont; + + // Keep track of the record body buffer + // and our position in it + BYTE * m_buffer; + long m_pos; + long m_size; + + // Keep track of how far deep into the PQDIF record we are + CPQDIF_E_Collection * m_pcoll; + + private: + + }; diff --git a/LFtid1056/pqdif/include/str_base.cpp b/LFtid1056/pqdif/include/str_base.cpp new file mode 100644 index 0000000..e171d96 --- /dev/null +++ b/LFtid1056/pqdif/include/str_base.cpp @@ -0,0 +1,146 @@ +/* +** CPQDIF_StreamIO class. The base class for implementing "stream I/O" which +** works along with a CPQDIF_PersistController class to supports a specific +** persistence mechanism. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: str_base.cpp $ +** Last modified: $Modtime: 9/21/00 9:09a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/str_base.cpp $ +** VCS revision: $Revision: 8 $ +*/ +#include "PQDIF_classes.h" + + +// Local constants +const long sizeDefaultGrowBy = 16*1024; + +// Construction +// ============ + +CPQDIF_StreamIO::CPQDIF_StreamIO() +{ + m_processor = NULL; + + m_canWriteFull = false; + m_canWriteInc = false; + + m_buffRead.SetSize( 0, sizeDefaultGrowBy ); + m_posRead = 0; + m_buffWrite.SetSize( 0, sizeDefaultGrowBy ); + m_posWrite = 0; +} + + +CPQDIF_StreamIO::~CPQDIF_StreamIO() +{ +} + + +bool CPQDIF_StreamIO::ConnectProcessor( CPQDIF_StreamProcessor * proc ) +{ + m_processor = proc; + + return TRUE; +} + + +long CPQDIF_StreamIO::GetChecksum( void ) +{ + return m_processor->GetChecksum(); +} + + +void CPQDIF_StreamIO::ResetChecksum( void ) +{ + m_processor->ResetChecksum(); +} + + +bool CPQDIF_StreamIO::ExecuteProcessorEncode( void ) +{ + bool status = false; + + if( m_processor ) + { + // Make sure we are connected to it + m_processor->ConnectStream( this ); + + status = m_processor->StreamEncode(); + } + + return status; +} + + +bool CPQDIF_StreamIO::ExecuteProcessorDecode( void ) +{ + bool status = false; + + if( m_processor ) + { + // Make sure we are connected to it + m_processor->ConnectStream( this ); + + status = m_processor->StreamDecode(); + } + + return status; +} + + +bool CPQDIF_StreamIO::ProcessRead( const BYTE * &buffer, long max, long& sizeActual ) +{ + buffer = m_buffRead.GetData() + m_posRead; // Adjust to current position + sizeActual = m_buffRead.GetSize() - m_posRead; // Get size minus current position + if( max > 0 && max > sizeActual ) + sizeActual = max; + return sizeActual > 0; +} + + +bool CPQDIF_StreamIO::ProcessWriteReserve( BYTE * & buffer, long size ) +{ + buffer = NULL; + bool status = m_buffWrite.SetSize( m_posWrite + size ); + if( status ) + { + buffer = m_buffWrite.GetData() + m_posWrite; + } + return status; +} + + +bool CPQDIF_StreamIO::ProcessWriteRelease( long size ) +{ + bool status = m_buffWrite.SetSize( m_posWrite + size ); + if( status ) + m_posWrite += size; + return status; +} + + +bool CPQDIF_StreamIO::BeginBlock( void ) +{ + bool status = true; + + // Clear buffers + m_buffRead.SetSize( 0, sizeDefaultGrowBy ); + m_posRead = 0; + + return status; +} + + +bool CPQDIF_StreamIO::AppendBlock( BYTE * buffer, long size ) +{ + bool status = true; + + // Fill the read buffer + m_buffRead.Append( buffer, size ); + + return status; +} + diff --git a/LFtid1056/pqdif/include/str_base.h b/LFtid1056/pqdif/include/str_base.h new file mode 100644 index 0000000..b1aa103 --- /dev/null +++ b/LFtid1056/pqdif/include/str_base.h @@ -0,0 +1,79 @@ +// File name: $Workfile: str_base.h $ +// Last modified: $Modtime: 9/20/00 11:42a $ +// Last modified by: $Author: Bill $ +// +// VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/str_base.h $ +// VCS revision: $Revision: 6 $ + +// External interfaces +class CPQDIF_StreamProcessor; + +class CPQDIF_StreamIO + { + public: + CPQDIF_StreamIO(); + virtual ~CPQDIF_StreamIO(); + + // Attributes + public: + + // Operations + public: + virtual bool SeekPos( int pos ) = 0; + virtual bool GetPos( int& pos ) = 0; + virtual bool SeekEnd( void ) = 0; + + virtual BYTE * ReadBlock( long size, int& actualSize ) = 0; + + virtual bool CanWriteFull( void ) const { return m_canWriteFull; } + virtual bool CanWriteIncremental( void ) const { return m_canWriteInc; } + + virtual bool BeginBlock( void ); + virtual bool AppendBlock( BYTE * buffer, long size ); + virtual bool WriteBlock( int &sizeActual ) = 0; + + virtual void Flush( void ) {} // Optional (default behavior: nothing) + + virtual bool ConnectProcessor( CPQDIF_StreamProcessor * proc ); + virtual long GetChecksum( void ); + virtual void ResetChecksum( void ); + + // Called by the processor + // ======================= + // Dereferences data buffered in the stream for the processor to read. + // The number of bytes available is returned in sizeActual. If max is 0, + // the total remaining length of the input buffer is returned. + // Returns FALSE when at end of buffer, TRUE otherwise. + virtual bool ProcessRead ( const BYTE * &buffer, long max, long& sizeActual ); + + // Reserves storage in the stream for the processor to write + // data into. + virtual bool ProcessWriteReserve( BYTE * &buffer, long size ); + + // This function is set the actual size of the buffer reserved + // by preceeding ProceWriteReserve call. + virtual bool ProcessWriteRelease( long sizeActual ); + + // Implementation + protected: + virtual bool ExecuteProcessorEncode( void ); + virtual bool ExecuteProcessorDecode( void ); + + // Member data + protected: + // This is connected to the object, but not owned by it. + CPQDIF_StreamProcessor * m_processor; + + // These are owned by the stream object + bool m_canWriteFull; + bool m_canWriteInc; + + CPQByteArray m_buffRead; + long m_sizeRead; + long m_posRead; + + CPQByteArray m_buffWrite; + long m_sizeWrite; + long m_posWrite; + }; + diff --git a/LFtid1056/pqdif/include/str_chnk.cpp b/LFtid1056/pqdif/include/str_chnk.cpp new file mode 100644 index 0000000..787f073 --- /dev/null +++ b/LFtid1056/pqdif/include/str_chnk.cpp @@ -0,0 +1,211 @@ +/* +** CPQDIF_S_Chunk class. A stream I/O implementing which supports "chunks." +** This will allow a PQDIF file to be embedded in a database binary field, +** for example. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: str_chnk.cpp $ +** Last modified: $Modtime: 10/11/01 12:48p $ +** Last modified by: $Author: Tomm $ +** +** VCS archive path: $Archive: /ElectrotekLibs/Borland/PQDIFlib/str_chnk.cpp $ +** VCS revision: $Revision: 7 $ +*/ +#include "PQDIF_classes.h" + + +// Construction +// ============ + +CPQDIF_S_Chunk::CPQDIF_S_Chunk() + { + m_chunkRead = NULL; + m_sizeChunkRead = 0; + m_chunkWrite.SetSize( 0, 64 ); + m_posChunk = 0; + } + +CPQDIF_S_Chunk::~CPQDIF_S_Chunk() + { + // Nothing to delete + } + + +bool CPQDIF_S_Chunk::SetInput( BYTE * chunk, long size ) + { + bool status = FALSE; + + if( chunk && size > 0 ) + { + m_chunkRead = chunk; + m_sizeChunkRead = size; + status = TRUE; + } + else + { + m_chunkRead = NULL; + m_sizeChunkRead = 0; + } + + return status; + } + + +bool CPQDIF_S_Chunk::GetOutputSize( long& size ) + { + bool status = FALSE; + + size = m_chunkWrite.GetSize(); + status = TRUE; + + return status; + } + + +bool CPQDIF_S_Chunk::GetOutput( BYTE * chunk, long maxSize ) + { + bool status = FALSE; + long sizeActual; + + if( chunk && maxSize > 0 ) + { + sizeActual = min( maxSize, (long) m_chunkWrite.GetSize() ); + memcpy( chunk, (BYTE *) m_chunkWrite.GetData(), sizeActual ); + status = TRUE; + } + + return status; + } + + +bool CPQDIF_S_Chunk::SeekPos( int pos ) + { + bool status = FALSE; + + m_posChunk = pos; + status = TRUE; + + return status; + } + +bool CPQDIF_S_Chunk::SeekEnd( void ) + { + bool status = FALSE; + + // Are we in read mode? + if( m_chunkRead ) + { + m_posChunk = m_sizeChunkRead; + status = TRUE; + } + else + { + // Nope, write mode. + m_posChunk = m_chunkWrite.GetSize(); + status = TRUE; + } + + return status; + } + +bool CPQDIF_S_Chunk::GetPos( int& pos ) + { + bool status = false; + + pos = m_posChunk; + status = true; + + return status; + } + +BYTE * CPQDIF_S_Chunk::ReadBlock( long size, int& actualSize ) + { + BYTE * buffRet = NULL; + long sizeAvailable; + long sizeRead; + bool status = FALSE; + + // Init + sizeRead = 0; + + // Clear buffers + m_buffRead.SetSize( 0 ); + m_posRead = 0; + m_buffWrite.SetSize( 0 ); + m_posWrite = 0; + + // Do we have a valid chunk to read? + if( m_chunkRead && m_sizeChunkRead > 0 && m_posChunk >= 0 ) + { + // Attempt to read the block + sizeAvailable = m_sizeChunkRead - m_posChunk; + if( sizeAvailable > size ) + { + sizeRead = size; + } + else + { + sizeRead = sizeAvailable; + } + + // Did we get anything? + // (If not, we are at the end of the chunk and will return NULL.) + if( sizeRead > 0 ) + { + // Size the buffer first & then copy the block + m_buffRead.SetSize( sizeRead ); + memcpy( m_buffRead.GetData(), m_chunkRead+m_posChunk, sizeRead ); + + // Increment past the part we just read. + m_posChunk += sizeRead; + + // We got the block -- now decode it. + status = ExecuteProcessorDecode(); + if( status ) + { + // Pass back the decoded buffer + buffRet = m_buffWrite.GetData(); + actualSize = (long) m_buffWrite.GetSize(); + } + } + } + return buffRet; + } + + +bool CPQDIF_S_Chunk::WriteBlock( int &sizeActual ) + { + bool status = FALSE; + BYTE * pdataChunk; + + // Init + m_buffWrite.SetSize( 0 ); + m_posWrite = 0; + sizeActual = 0; + + // Encode the block + status = ExecuteProcessorEncode(); + if( status ) + { + // The write buffer should contain the output + sizeActual = m_buffWrite.GetSize(); + if( sizeActual > 0 ) + { + // Force the position to the end of the chunk... + // and resize the write chunk. + m_posChunk = m_chunkWrite.GetSize(); + m_chunkWrite.SetSize( m_posChunk + sizeActual ); + + // Find where this block goes + pdataChunk = (BYTE *) m_buffWrite.GetData(); + pdataChunk += m_posChunk; + + // Copy over the block + memcpy( pdataChunk, (BYTE *) m_buffWrite.GetData(), sizeActual ); + m_posChunk += sizeActual; + status = TRUE; + } + } + + return status; + } diff --git a/LFtid1056/pqdif/include/str_chnk.h b/LFtid1056/pqdif/include/str_chnk.h new file mode 100644 index 0000000..a018054 --- /dev/null +++ b/LFtid1056/pqdif/include/str_chnk.h @@ -0,0 +1,36 @@ + +class CPQDIF_S_Chunk : public CPQDIF_StreamIO + { + public: + CPQDIF_S_Chunk(); + virtual ~CPQDIF_S_Chunk(); + + // Attributes + public: + + // Operations + public: + bool SetInput( BYTE * chunk, long size ); + + bool GetOutputSize( long& size ); + bool GetOutput( BYTE * chunk, long maxSize ); + + // Overridables + public: + virtual bool SeekPos( int pos ); + virtual bool GetPos( int& pos ); + virtual bool SeekEnd( void ); + + virtual BYTE * ReadBlock( long size, int& actualSize ); + virtual bool WriteBlock( int &sizeActual ); + + // Implementation + protected: + BYTE * m_chunkRead; + long m_sizeChunkRead; + + CPQByteArray m_chunkWrite; + + long m_posChunk; + }; + diff --git a/LFtid1056/pqdif/include/str_flat.cpp b/LFtid1056/pqdif/include/str_flat.cpp new file mode 100644 index 0000000..2b00851 --- /dev/null +++ b/LFtid1056/pqdif/include/str_flat.cpp @@ -0,0 +1,239 @@ +/* +** CPQDIF_S_FlatFile class. A stream I/O implementing which supports the +** standard flat file. This is the normal persistence mechanism for PQDIF. +** -------------------------------------------------------------------------- +** +** File name: $Workfile: str_flat.cpp $ +** Last modified: $Modtime: 9/21/00 8:19a $ +** Last modified by: $Author: Bill $ +** +** VCS archive path: $Archive: /Hank/DMM/FirmWare/Level3/ObDatMgr/str_flat.cpp $ +** VCS revision: $Revision: 7 $ +*/ +#include "PQDIF_classes.h" + +// Construction +// ============ + +CPQDIF_S_FlatFile::CPQDIF_S_FlatFile() + { + m_pf = NULL; + } + + +CPQDIF_S_FlatFile::~CPQDIF_S_FlatFile() + { + if( m_pf ) + { + fclose( m_pf ); + } + } + + +bool CPQDIF_S_FlatFile::Open + ( + const char * fname, + bool readOnly + ) + { + bool status = FALSE; + const char * flagsOpen = ""; + + if( readOnly ) + { + // Read-only + flagsOpen = "rb"; + m_canWriteFull = FALSE; + m_canWriteInc = FALSE; + } + else + { + // Read/write + flagsOpen = "r+b"; + m_canWriteFull = TRUE; + m_canWriteInc = TRUE; + } + + if( !m_pf ) + { +#ifdef WIN32 + fopen_s(&m_pf,fname, flagsOpen); + +#else + m_pf = fopen(fname, flagsOpen); + +#endif // WIN32 + + if( m_pf ) + status = TRUE; + } + + return status; + } + + +bool CPQDIF_S_FlatFile::New( const char * fname ) + { + bool status = FALSE; + + // Init + m_canWriteFull = FALSE; + m_canWriteInc = FALSE; + + if( !m_pf ) + { +#ifdef WIN32 + fopen_s(&m_pf,fname, "w+b"); + +#else + m_pf = fopen(fname, "w+b"); + +#endif // WIN32 + + if( m_pf ) + { + m_canWriteFull = TRUE; + m_canWriteInc = TRUE; + status = TRUE; + } + } + + return status; + } + + +bool CPQDIF_S_FlatFile::SeekPos( int pos ) + { + bool status = FALSE; + + if( m_pf ) + { + int rc = fseek( m_pf, pos, SEEK_SET ); + if( rc == 0 ) + status = TRUE; + } + + return status; + } + +bool CPQDIF_S_FlatFile::SeekEnd( void ) + { + bool status = FALSE; + + if( m_pf ) + { + int rc = fseek( m_pf, 0, SEEK_END ); + if( rc == 0 ) + status = TRUE; + } + + return status; + } + +bool CPQDIF_S_FlatFile::GetPos( int& pos ) + { + bool status = FALSE; + + if( m_pf ) + { +//#ifdef WIN32 + pos = ftell( m_pf ); +//#else +// fpos_t position; +// fgetpos( m_pf, &position); +// pos = (long)position; +//#endif + status = TRUE; + } + + return status; + } + +BYTE * CPQDIF_S_FlatFile::ReadBlock( long size, int& actualSize ) + { + BYTE * buffRet = NULL; + long sizeRead; + bool status = FALSE; + + // Init + sizeRead = 0; + + // Clear buffers + m_buffRead.SetSize( 0 ); + m_posRead = 0; + m_buffWrite.SetSize( 0 ); + m_posWrite = 0; + + if( m_pf ) + { + // End of file yet? + if( ! feof( m_pf ) ) + { + // Nope, read a buffer full... + // Size the buffer first + m_buffRead.SetSize( size ); + + // Attempt to read the block + sizeRead = (long) fread( (BYTE*) m_buffRead.GetData(), 1, size, m_pf ); + if( sizeRead > 0 ) + { + // We got the block -- now decode it. + m_buffRead.SetSize( sizeRead ); + status = ExecuteProcessorDecode(); + if( status ) + { + // Pass back the decoded buffer + buffRet = m_buffWrite.GetData(); + actualSize = (long) m_buffWrite.GetSize(); + } + } + } + } + + return buffRet; + } + + +bool CPQDIF_S_FlatFile::WriteBlock( int &sizeActual ) + { + bool status = FALSE; + long sizeWritten; + + m_buffWrite.SetSize( 0 ); + m_posWrite = 0; + sizeActual = 0; + + if( m_pf ) + { + // End of file yet? + if( ! feof( m_pf ) ) + { + // Encode the block + status = ExecuteProcessorEncode(); + if( status ) + { + // The write buffer should contain the output + sizeActual = m_buffWrite.GetSize(); + + // Attempt to read the block + sizeWritten = (long) fwrite( (BYTE*) m_buffWrite.GetData(), 1, sizeActual, m_pf ); + if( sizeWritten == sizeActual ) + { + status = TRUE; + } + } + } + } + + return status; + } + + +void CPQDIF_S_FlatFile::Flush( void ) + { + if( m_pf ) + { + fflush( m_pf ); + } + } + diff --git a/LFtid1056/pqdif/include/str_flat.h b/LFtid1056/pqdif/include/str_flat.h new file mode 100644 index 0000000..ab39086 --- /dev/null +++ b/LFtid1056/pqdif/include/str_flat.h @@ -0,0 +1,38 @@ +#include + +class CPQDIF_S_FlatFile : public CPQDIF_StreamIO + { + public: + CPQDIF_S_FlatFile(); + virtual ~CPQDIF_S_FlatFile(); + + // Attributes + public: + + // Operations + public: + bool Open + ( + const char * fname, + bool readOnly + ); + bool New( const char * fname ); + bool Connect( FILE * pf ) { m_pf = pf; return true; } + FILE * GetFile( void ) { return m_pf; } + + // Overridables + public: + virtual bool SeekPos( int pos ); + virtual bool GetPos( int& pos ); + virtual bool SeekEnd( void ); + + virtual BYTE * ReadBlock( long size, int& actualSize ); + virtual bool WriteBlock( int &sizeActual ); + + virtual void Flush( void ); + + // Implementation + protected: + FILE * m_pf; + }; + diff --git a/LFtid1056/pqdif/include/zconf.h b/LFtid1056/pqdif/include/zconf.h new file mode 100644 index 0000000..7bc054f --- /dev/null +++ b/LFtid1056/pqdif/include/zconf.h @@ -0,0 +1,248 @@ +/* zconf.h -- configuration of the zlib compression library + * Copyright (C) 1995-1998 Jean-loup Gailly. + * For conditions of distribution and use, see copyright notice in zlib.h + */ + +/* @(#) $Id$ */ + +#ifndef _ZCONF_H +#define _ZCONF_H + +/* + * If you *really* need a unique prefix for all types and library functions, + * compile with -DZ_PREFIX. The "standard" zlib should be compiled without it. + */ +#ifdef Z_PREFIX +# define deflateInit_ z_deflateInit_ +# define deflate z_deflate +# define deflateEnd z_deflateEnd +# define inflateInit_ z_inflateInit_ +# define inflate z_inflate +# define inflateEnd z_inflateEnd +# define deflateInit2_ z_deflateInit2_ +# define deflateSetDictionary z_deflateSetDictionary +# define deflateCopy z_deflateCopy +# define deflateReset z_deflateReset +# define deflateParams z_deflateParams +# define inflateInit2_ z_inflateInit2_ +# define inflateSetDictionary z_inflateSetDictionary +# define inflateSync z_inflateSync +# define inflateSyncPoint z_inflateSyncPoint +# define inflateReset z_inflateReset +# define compress z_compress +# define uncompress z_uncompress +# define adler32 z_adler32 +# define crc32 z_crc32 +# define get_crc_table z_get_crc_table + +# define Byte z_Byte +# define uInt z_uInt +# define uLong z_uLong +# define Bytef z_Bytef +# define charf z_charf +# define intf z_intf +# define uIntf z_uIntf +# define uLongf z_uLongf +# define voidpf z_voidpf +# define voidp z_voidp +#endif + +#if (defined(_WIN32) || defined(__WIN32__)) && !defined(WIN32) +# define WIN32 +#endif +#if defined(__GNUC__) || defined(WIN32) || defined(__386__) || defined(i386) +# ifndef __32BIT__ +# define __32BIT__ +# endif +#endif +#if defined(__MSDOS__) && !defined(MSDOS) +# define MSDOS +#endif + +/* + * Compile with -DMAXSEG_64K if the alloc function cannot allocate more + * than 64k bytes at a time (needed on systems with 16-bit int). + */ +#if defined(MSDOS) && !defined(__32BIT__) +# define MAXSEG_64K +#endif +#ifdef MSDOS +# define UNALIGNED_OK +#endif + +#if (defined(MSDOS) || defined(_WINDOWS) || defined(WIN32)) && !defined(STDC) +# define STDC +#endif +#if defined(__STDC__) || defined(__cplusplus) || defined(__OS2__) +# ifndef STDC +# define STDC +# endif +#endif + +#ifndef STDC +# ifndef const /* cannot use !defined(STDC) && !defined(const) on Mac */ +# define const +# endif +#endif + +/* Some Mac compilers merge all .h files incorrectly: */ +#if defined(__MWERKS__) || defined(applec) ||defined(THINK_C) ||defined(__SC__) +# define NO_DUMMY_DECL +#endif + +/* Borland C incorrectly complains about missing returns: */ +#if defined(__BORLANDC__) +# define NEED_DUMMY_RETURN +#endif + + +/* Maximum value for memLevel in deflateInit2 */ +#ifndef MAX_MEM_LEVEL +# ifdef MAXSEG_64K +# define MAX_MEM_LEVEL 8 +# else +# define MAX_MEM_LEVEL 9 +# endif +#endif + +/* Maximum value for windowBits in deflateInit2 and inflateInit2. + * WARNING: reducing MAX_WBITS makes minigzip unable to extract .gz files + * created by gzip. (Files created by minigzip can still be extracted by + * gzip.) + */ +#ifndef MAX_WBITS +# define MAX_WBITS 15 /* 32K LZ77 window */ +#endif + +/* The memory requirements for deflate are (in bytes): + (1 << (windowBits+2)) + (1 << (memLevel+9)) + that is: 128K for windowBits=15 + 128K for memLevel = 8 (default values) + plus a few kilobytes for small objects. For example, if you want to reduce + the default memory requirements from 256K to 128K, compile with + make CFLAGS="-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7" + Of course this will generally degrade compression (there's no free lunch). + + The memory requirements for inflate are (in bytes) 1 << windowBits + that is, 32K for windowBits=15 (default value) plus a few kilobytes + for small objects. +*/ + + /* Type declarations */ + +#ifndef OF /* function prototypes */ +# ifdef STDC +# define OF(args) args +# else +# define OF(args) () +# endif +#endif + +/* The following definitions for FAR are needed only for MSDOS mixed + * model programming (small or medium model with some far allocations). + * This was tested only with MSC; for other MSDOS compilers you may have + * to define NO_MEMCPY in zutil.h. If you don't need the mixed model, + * just define FAR to be empty. + */ +#if (defined(M_I86SM) || defined(M_I86MM)) && !defined(__32BIT__) + /* MSC small or medium model */ +# define SMALL_MEDIUM +# ifdef _MSC_VER +# define FAR __far +# else +# define FAR far +# endif +#endif +#if defined(__BORLANDC__) && (defined(__SMALL__) || defined(__MEDIUM__)) +# ifndef __32BIT__ +# define SMALL_MEDIUM +# define FAR __far +# endif +#endif +#ifndef FAR +# define FAR +#endif + +typedef unsigned char Byte; /* 8 bits */ +typedef unsigned int uInt; /* 16 bits or more */ +typedef unsigned long uLong; /* 32 bits or more */ + +#if defined(__BORLANDC__) && defined(SMALL_MEDIUM) + /* Borland C/C++ ignores FAR inside typedef */ +# define Bytef Byte FAR +#else + typedef Byte FAR Bytef; +#endif +typedef char FAR charf; +typedef int FAR intf; +typedef uInt FAR uIntf; +typedef uLong FAR uLongf; + +#ifdef STDC + typedef void FAR *voidpf; + typedef void *voidp; +#else + typedef Byte FAR *voidpf; + typedef Byte *voidp; +#endif + +#ifdef HAVE_UNISTD_H +# include /* for off_t */ +# include /* for SEEK_* and off_t */ +# define z_off_t off_t +#endif +#ifndef SEEK_SET +# define SEEK_SET 0 /* Seek from beginning of file. */ +# define SEEK_CUR 1 /* Seek from current position. */ +#endif +#ifndef z_off_t +# define z_off_t long +#endif + +/* Compile with -DZLIB_DLL for Windows DLL support */ +#if (defined(_WINDOWS) || defined(WINDOWS)) && defined(ZLIB_DLL) +# undef FAR +# include +# define EXPORT WINAPI +# ifdef WIN32 +# define EXPORTVA WINAPIV +# else +# define EXPORTVA FAR _cdecl _export +# endif +#else +# if defined (__BORLANDC__) && defined (_Windows) && defined (__DLL__) +# define EXPORT _export +# define EXPORTVA _export +# else +# define EXPORT +# define EXPORTVA +# endif +#endif + +/* MVS linker does not support external names larger than 8 bytes */ +#if defined(__MVS__) +# pragma map(deflateInit_,"DEIN") +# pragma map(deflateInit2_,"DEIN2") +# pragma map(deflateEnd,"DEEND") +# pragma map(inflateInit_,"ININ") +# pragma map(inflateInit2_,"ININ2") +# pragma map(inflateEnd,"INEND") +# pragma map(inflateSync,"INSY") +# pragma map(inflateSetDictionary,"INSEDI") +# pragma map(inflate_blocks,"INBL") +# pragma map(inflate_blocks_new,"INBLNE") +# pragma map(inflate_blocks_free,"INBLFR") +# pragma map(inflate_blocks_reset,"INBLRE") +# pragma map(inflate_codes_free,"INCOFR") +# pragma map(inflate_codes,"INCO") +# pragma map(inflate_fast,"INFA") +# pragma map(inflate_flush,"INFLU") +# pragma map(inflate_mask,"INMA") +# pragma map(inflate_set_dictionary,"INSEDI2") +# pragma map(inflate_copyright,"INCOPY") +# pragma map(inflate_trees_bits,"INTRBI") +# pragma map(inflate_trees_dynamic,"INTRDY") +# pragma map(inflate_trees_fixed,"INTRFI") +# pragma map(inflate_trees_free,"INTRFR") +#endif + +#endif /* _ZCONF_H */ diff --git a/LFtid1056/pqdif/include/zlib.h b/LFtid1056/pqdif/include/zlib.h new file mode 100644 index 0000000..2319835 --- /dev/null +++ b/LFtid1056/pqdif/include/zlib.h @@ -0,0 +1,868 @@ +/* zlib.h -- interface of the 'zlib' general purpose compression library + version 1.0.8, Jan 27th, 1998 + + Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jean-loup Gailly Mark Adler + jloup@gzip.org madler@alumni.caltech.edu + + + The data format used by the zlib library is described by RFCs (Request for + Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt + (zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format). +*/ + +#ifndef _ZLIB_H +#define _ZLIB_H + +#ifdef __cplusplus +extern "C" { +#endif + +#include "zconf.h" + +#define ZLIB_VERSION "1.0.8" + +/* + The 'zlib' compression library provides in-memory compression and + decompression functions, including integrity checks of the uncompressed + data. This version of the library supports only one compression method + (deflation) but other algorithms will be added later and will have the same + stream interface. + + Compression can be done in a single step if the buffers are large + enough (for example if an input file is mmap'ed), or can be done by + repeated calls of the compression function. In the latter case, the + application must provide more input and/or consume the output + (providing more output space) before each call. + + The library also supports reading and writing files in gzip (.gz) format + with an interface similar to that of stdio. + + The library does not install any signal handler. The decoder checks + the consistency of the compressed data, so the library should never + crash even in case of corrupted input. +*/ + +typedef voidpf (*alloc_func) OF((voidpf opaque, uInt items, uInt size)); +typedef void (*free_func) OF((voidpf opaque, voidpf address)); + +struct internal_state; + +typedef struct z_stream_s { + Bytef *next_in; /* next input byte */ + uInt avail_in; /* number of bytes available at next_in */ + uLong total_in; /* total nb of input bytes read so far */ + + Bytef *next_out; /* next output byte should be put there */ + uInt avail_out; /* remaining free space at next_out */ + uLong total_out; /* total nb of bytes output so far */ + + char *msg; /* last error message, NULL if no error */ + struct internal_state FAR *state; /* not visible by applications */ + + alloc_func zalloc; /* used to allocate the internal state */ + free_func zfree; /* used to free the internal state */ + voidpf opaque; /* private data object passed to zalloc and zfree */ + + int data_type; /* best guess about the data type: ascii or binary */ + uLong adler; /* adler32 value of the uncompressed data */ + uLong reserved; /* reserved for future use */ +} z_stream; + +typedef z_stream FAR *z_streamp; + +/* + The application must update next_in and avail_in when avail_in has + dropped to zero. It must update next_out and avail_out when avail_out + has dropped to zero. The application must initialize zalloc, zfree and + opaque before calling the init function. All other fields are set by the + compression library and must not be updated by the application. + + The opaque value provided by the application will be passed as the first + parameter for calls of zalloc and zfree. This can be useful for custom + memory management. The compression library attaches no meaning to the + opaque value. + + zalloc must return Z_NULL if there is not enough memory for the object. + On 16-bit systems, the functions zalloc and zfree must be able to allocate + exactly 65536 bytes, but will not be required to allocate more than this + if the symbol MAXSEG_64K is defined (see zconf.h). WARNING: On MSDOS, + pointers returned by zalloc for objects of exactly 65536 bytes *must* + have their offset normalized to zero. The default allocation function + provided by this library ensures this (see zutil.c). To reduce memory + requirements and avoid any allocation of 64K objects, at the expense of + compression ratio, compile the library with -DMAX_WBITS=14 (see zconf.h). + + The fields total_in and total_out can be used for statistics or + progress reports. After compression, total_in holds the total size of + the uncompressed data and may be saved for use in the decompressor + (particularly if the decompressor wants to decompress everything in + a single step). +*/ + + /* constants */ + +#define Z_NO_FLUSH 0 +#define Z_PARTIAL_FLUSH 1 /* will be removed, use Z_SYNC_FLUSH instead */ +#define Z_SYNC_FLUSH 2 +#define Z_FULL_FLUSH 3 +#define Z_FINISH 4 +/* Allowed flush values; see deflate() below for details */ + +#define Z_OK 0 +#define Z_STREAM_END 1 +#define Z_NEED_DICT 2 +#define Z_ERRNO (-1) +#define Z_STREAM_ERROR (-2) +#define Z_DATA_ERROR (-3) +#define Z_MEM_ERROR (-4) +#define Z_BUF_ERROR (-5) +#define Z_VERSION_ERROR (-6) +/* Return codes for the compression/decompression functions. Negative + * values are errors, positive values are used for special but normal events. + */ + +#define Z_NO_COMPRESSION 0 +#define Z_BEST_SPEED 1 +#define Z_BEST_COMPRESSION 9 +#define Z_DEFAULT_COMPRESSION (-1) +/* compression levels */ + +#define Z_FILTERED 1 +#define Z_HUFFMAN_ONLY 2 +#define Z_DEFAULT_STRATEGY 0 +/* compression strategy; see deflateInit2() below for details */ + +#define Z_BINARY 0 +#define Z_ASCII 1 +#define Z_UNKNOWN 2 +/* Possible values of the data_type field */ + +#define Z_DEFLATED 8 +/* The deflate compression method (the only one supported in this version) */ + +#define Z_NULL 0 /* for initializing zalloc, zfree, opaque */ + +#define zlib_version zlibVersion() +/* for compatibility with versions < 1.0.2 */ + + /* basic functions */ + +extern const char * EXPORT zlibVersion OF((void)); +/* The application can compare zlibVersion and ZLIB_VERSION for consistency. + If the first character differs, the library code actually used is + not compatible with the zlib.h header file used by the application. + This check is automatically made by deflateInit and inflateInit. + */ + +/* +extern int EXPORT deflateInit OF((z_streamp strm, int level)); + + Initializes the internal stream state for compression. The fields + zalloc, zfree and opaque must be initialized before by the caller. + If zalloc and zfree are set to Z_NULL, deflateInit updates them to + use default allocation functions. + + The compression level must be Z_DEFAULT_COMPRESSION, or between 0 and 9: + 1 gives best speed, 9 gives best compression, 0 gives no compression at + all (the input data is simply copied a block at a time). + Z_DEFAULT_COMPRESSION requests a default compromise between speed and + compression (currently equivalent to level 6). + + deflateInit returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if level is not a valid compression level, + Z_VERSION_ERROR if the zlib library version (zlib_version) is incompatible + with the version assumed by the caller (ZLIB_VERSION). + msg is set to null if there is no error message. deflateInit does not + perform any compression: this will be done by deflate(). +*/ + + +extern int EXPORT deflate OF((z_streamp strm, int flush)); +/* + deflate compresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may introduce some + output latency (reading input without producing any output) except when + forced to flush. + + The detailed semantics are as follows. deflate performs one or both of the + following actions: + + - Compress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in and avail_in are updated and + processing will resume at this point for the next call of deflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. This action is forced if the parameter flush is non zero. + Forcing flush frequently degrades the compression ratio, so this parameter + should be set only when necessary (in interactive applications). + Some output may be provided even if flush is not set. + + Before the call of deflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating avail_in or avail_out accordingly; avail_out + should never be zero before the call. The application can consume the + compressed output when it wants, for example when the output buffer is full + (avail_out == 0), or after each call of deflate(). If deflate returns Z_OK + and with zero avail_out, it must be called again after making room in the + output buffer because there might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, all pending output is + flushed to the output buffer and the output is aligned on a byte boundary, so + that the decompressor can get all input data available so far. (In particular + avail_in is zero after the call if enough output space has been provided + before the call.) Flushing may degrade compression for some compression + algorithms and so it should be used only when necessary. + + If flush is set to Z_FULL_FLUSH, all output is flushed as with + Z_SYNC_FLUSH, and the compression state is reset so that decompression can + restart from this point if previous compressed data has been damaged or if + random access is desired. Using Z_FULL_FLUSH too often can seriously degrade + the compression. + + If deflate returns with avail_out == 0, this function must be called again + with the same value of the flush parameter and more output space (updated + avail_out), until the flush is complete (deflate returns with non-zero + avail_out). + + If the parameter flush is set to Z_FINISH, pending input is processed, + pending output is flushed and deflate returns with Z_STREAM_END if there + was enough output space; if deflate returns with Z_OK, this function must be + called again with Z_FINISH and more output space (updated avail_out) but no + more input data, until it returns with Z_STREAM_END or an error. After + deflate has returned Z_STREAM_END, the only possible operations on the + stream are deflateReset or deflateEnd. + + Z_FINISH can be used immediately after deflateInit if all the compression + is to be done in a single step. In this case, avail_out must be at least + 0.1% larger than avail_in plus 12 bytes. If deflate does not return + Z_STREAM_END, then it must be called again as described above. + + deflate() sets strm->adler to the adler32 checksum of all input read + so far (that is, total_in bytes). + + deflate() may update data_type if it can make a good guess about + the input data type (Z_ASCII or Z_BINARY). In doubt, the data is considered + binary. This field is only for information purposes and does not affect + the compression algorithm in any manner. + + deflate() returns Z_OK if some progress has been made (more input + processed or more output produced), Z_STREAM_END if all input has been + consumed and all output has been produced (only when flush is set to + Z_FINISH), Z_STREAM_ERROR if the stream state was inconsistent (for example + if next_in or next_out was NULL), Z_BUF_ERROR if no progress is possible. +*/ + + +extern int EXPORT deflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + deflateEnd returns Z_OK if success, Z_STREAM_ERROR if the + stream state was inconsistent, Z_DATA_ERROR if the stream was freed + prematurely (some input or output was discarded). In the error case, + msg may be set but then points to a static string (which must not be + deallocated). +*/ + + +/* +extern int EXPORT inflateInit OF((z_streamp strm)); + + Initializes the internal stream state for decompression. The fields + next_in, avail_in, zalloc, zfree and opaque must be initialized before by + the caller. If next_in is not Z_NULL and avail_in is large enough (the exact + value depends on the compression method), inflateInit determines the + compression method from the zlib header and allocates all data structures + accordingly; otherwise the allocation will be deferred to the first call of + inflate. If zalloc and zfree are set to Z_NULL, inflateInit updates them to + use default allocation functions. + + inflateInit returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_VERSION_ERROR if the zlib library version is incompatible with the + version assumed by the caller. msg is set to null if there is no error + message. inflateInit does not perform any decompression apart from reading + the zlib header if present: this will be done by inflate(). (So next_in and + avail_in may be modified, but next_out and avail_out are unchanged.) +*/ + + +extern int EXPORT inflate OF((z_streamp strm, int flush)); +/* + inflate decompresses as much data as possible, and stops when the input + buffer becomes empty or the output buffer becomes full. It may some + introduce some output latency (reading input without producing any output) + except when forced to flush. + + The detailed semantics are as follows. inflate performs one or both of the + following actions: + + - Decompress more input starting at next_in and update next_in and avail_in + accordingly. If not all input can be processed (because there is not + enough room in the output buffer), next_in is updated and processing + will resume at this point for the next call of inflate(). + + - Provide more output starting at next_out and update next_out and avail_out + accordingly. inflate() provides as much output as possible, until there + is no more input data or no more space in the output buffer (see below + about the flush parameter). + + Before the call of inflate(), the application should ensure that at least + one of the actions is possible, by providing more input and/or consuming + more output, and updating the next_* and avail_* values accordingly. + The application can consume the uncompressed output when it wants, for + example when the output buffer is full (avail_out == 0), or after each + call of inflate(). If inflate returns Z_OK and with zero avail_out, it + must be called again after making room in the output buffer because there + might be more output pending. + + If the parameter flush is set to Z_SYNC_FLUSH, inflate flushes as much + output as possible to the output buffer. The flushing behavior of inflate is + not specified for values of the flush parameter other than Z_SYNC_FLUSH + and Z_FINISH, but the current implementation actually flushes as much output + as possible anyway. + + inflate() should normally be called until it returns Z_STREAM_END or an + error. However if all decompression is to be performed in a single step + (a single call of inflate), the parameter flush should be set to + Z_FINISH. In this case all pending input is processed and all pending + output is flushed; avail_out must be large enough to hold all the + uncompressed data. (The size of the uncompressed data may have been saved + by the compressor for this purpose.) The next operation on this stream must + be inflateEnd to deallocate the decompression state. The use of Z_FINISH + is never required, but can be used to inform inflate that a faster routine + may be used for the single inflate() call. + + If a preset dictionary is needed at this point (see inflateSetDictionary + below), inflate sets strm-adler to the adler32 checksum of the + dictionary chosen by the compressor and returns Z_NEED_DICT; otherwise + it sets strm->adler to the adler32 checksum of all output produced + so far (that is, total_out bytes) and returns Z_OK, Z_STREAM_END or + an error code as described below. At the end of the stream, inflate() + checks that its computed adler32 checksum is equal to that saved by the + compressor and returns Z_STREAM_END only if the checksum is correct. + + inflate() returns Z_OK if some progress has been made (more input processed + or more output produced), Z_STREAM_END if the end of the compressed data has + been reached and all uncompressed output has been produced, Z_NEED_DICT if a + preset dictionary is needed at this point, Z_DATA_ERROR if the input data was + corrupted (input stream not conforming to the zlib format or incorrect + adler32 checksum), Z_STREAM_ERROR if the stream structure was inconsistent + (for example if next_in or next_out was NULL), Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if no progress is possible or if there was not + enough room in the output buffer when Z_FINISH is used. In the Z_DATA_ERROR + case, the application may then call inflateSync to look for a good + compression block. +*/ + + +extern int EXPORT inflateEnd OF((z_streamp strm)); +/* + All dynamically allocated data structures for this stream are freed. + This function discards any unprocessed input and does not flush any + pending output. + + inflateEnd returns Z_OK if success, Z_STREAM_ERROR if the stream state + was inconsistent. In the error case, msg may be set but then points to a + static string (which must not be deallocated). +*/ + + /* Advanced functions */ + +/* + The following functions are needed only in some special applications. +*/ + +/* +extern int EXPORT deflateInit2 OF((z_streamp strm, + int level, + int method, + int windowBits, + int memLevel, + int strategy)); + + This is another version of deflateInit with more compression options. The + fields next_in, zalloc, zfree and opaque must be initialized before by + the caller. + + The method parameter is the compression method. It must be Z_DEFLATED in + this version of the library. + + The windowBits parameter is the base two logarithm of the window size + (the size of the history buffer). It should be in the range 8..15 for this + version of the library. Larger values of this parameter result in better + compression at the expense of memory usage. The default value is 15 if + deflateInit is used instead. + + The memLevel parameter specifies how much memory should be allocated + for the internal compression state. memLevel=1 uses minimum memory but + is slow and reduces compression ratio; memLevel=9 uses maximum memory + for optimal speed. The default value is 8. See zconf.h for total memory + usage as a function of windowBits and memLevel. + + The strategy parameter is used to tune the compression algorithm. Use the + value Z_DEFAULT_STRATEGY for normal data, Z_FILTERED for data produced by a + filter (or predictor), or Z_HUFFMAN_ONLY to force Huffman encoding only (no + string match). Filtered data consists mostly of small values with a + somewhat random distribution. In this case, the compression algorithm is + tuned to compress them better. The effect of Z_FILTERED is to force more + Huffman coding and less string matching; it is somewhat intermediate + between Z_DEFAULT and Z_HUFFMAN_ONLY. The strategy parameter only affects + the compression ratio but not the correctness of the compressed output even + if it is not set appropriately. + + deflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as an invalid + method). msg is set to null if there is no error message. deflateInit2 does + not perform any compression: this will be done by deflate(). +*/ + +extern int EXPORT deflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the compression dictionary from the given byte sequence + without producing any compressed output. This function must be called + immediately after deflateInit or deflateInit2, before any call of + deflate. The compressor and decompressor must use exactly the same + dictionary (see inflateSetDictionary). + + The dictionary should consist of strings (byte sequences) that are likely + to be encountered later in the data to be compressed, with the most commonly + used strings preferably put towards the end of the dictionary. Using a + dictionary is most useful when the data to be compressed is short and can be + predicted with good accuracy; the data can then be compressed better than + with the default empty dictionary. + + Depending on the size of the compression data structures selected by + deflateInit or deflateInit2, a part of the dictionary may in effect be + discarded, for example if the dictionary is larger than the window size in + deflate or deflate2. Thus the strings most likely to be useful should be + put at the end of the dictionary, not at the front. + + Upon return of this function, strm->adler is set to the Adler32 value + of the dictionary; the decompressor may later use this value to determine + which dictionary has been used by the compressor. (The Adler32 value + applies to the whole dictionary even if only a subset of the dictionary is + actually used by the compressor.) + + deflateSetDictionary returns Z_OK if success, or Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent (for example if deflate has already been called for this stream + or if the compression method is bsort). deflateSetDictionary does not + perform any compression: this will be done by deflate(). +*/ + +extern int EXPORT deflateCopy OF((z_streamp dest, + z_streamp source)); +/* + Sets the destination stream as a complete copy of the source stream. + + This function can be useful when several compression strategies will be + tried, for example when there are several ways of pre-processing the input + data with a filter. The streams that will be discarded should then be freed + by calling deflateEnd. Note that deflateCopy duplicates the internal + compression state which can be quite large, so this strategy is slow and + can consume lots of memory. + + deflateCopy returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_STREAM_ERROR if the source stream state was inconsistent + (such as zalloc being NULL). msg is left unchanged in both source and + destination. +*/ + +extern int EXPORT deflateReset OF((z_streamp strm)); +/* + This function is equivalent to deflateEnd followed by deflateInit, + but does not free and reallocate all the internal compression state. + The stream will keep the same compression level and any other attributes + that may have been set by deflateInit2. + + deflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + +extern int EXPORT deflateParams OF((z_streamp strm, int level, int strategy)); +/* + Dynamically update the compression level and compression strategy. The + interpretation of level and strategy is as in deflateInit2. This can be + used to switch between compression and straight copy of the input data, or + to switch to a different kind of input data requiring a different + strategy. If the compression level is changed, the input available so far + is compressed with the old level (and may be flushed); the new level will + take effect only at the next call of deflate(). + + Before the call of deflateParams, the stream state must be set as for + a call of deflate(), since the currently available input may have to + be compressed and flushed. In particular, strm->avail_out must be non-zero. + + deflateParams returns Z_OK if success, Z_STREAM_ERROR if the source + stream state was inconsistent or if a parameter was invalid, Z_BUF_ERROR + if strm->avail_out was zero. +*/ + +/* +extern int EXPORT inflateInit2 OF((z_streamp strm, + int windowBits)); + + This is another version of inflateInit with an extra parameter. The + fields next_in, avail_in, zalloc, zfree and opaque must be initialized + before by the caller. + + The windowBits parameter is the base two logarithm of the maximum window + size (the size of the history buffer). It should be in the range 8..15 for + this version of the library. The default value is 15 if inflateInit is used + instead. If a compressed stream with a larger window size is given as + input, inflate() will return with the error code Z_DATA_ERROR instead of + trying to allocate a larger window. + + inflateInit2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_STREAM_ERROR if a parameter is invalid (such as a negative + memLevel). msg is set to null if there is no error message. inflateInit2 + does not perform any decompression apart from reading the zlib header if + present: this will be done by inflate(). (So next_in and avail_in may be + modified, but next_out and avail_out are unchanged.) +*/ + +extern int EXPORT inflateSetDictionary OF((z_streamp strm, + const Bytef *dictionary, + uInt dictLength)); +/* + Initializes the decompression dictionary from the given uncompressed byte + sequence. This function must be called immediately after a call of inflate + if this call returned Z_NEED_DICT. The dictionary chosen by the compressor + can be determined from the Adler32 value returned by this call of + inflate. The compressor and decompressor must use exactly the same + dictionary (see deflateSetDictionary). + + inflateSetDictionary returns Z_OK if success, Z_STREAM_ERROR if a + parameter is invalid (such as NULL dictionary) or the stream state is + inconsistent, Z_DATA_ERROR if the given dictionary doesn't match the + expected one (incorrect Adler32 value). inflateSetDictionary does not + perform any decompression: this will be done by subsequent calls of + inflate(). +*/ + +extern int EXPORT inflateSync OF((z_streamp strm)); +/* + Skips invalid compressed data until a full flush point (see above the + description of deflate with Z_FULL_FLUSH) can be found, or until all + available input is skipped. No output is provided. + + inflateSync returns Z_OK if a full flush point has been found, Z_BUF_ERROR + if no more input was provided, Z_DATA_ERROR if no flush point has been found, + or Z_STREAM_ERROR if the stream structure was inconsistent. In the success + case, the application may save the current current value of total_in which + indicates where valid compressed data was found. In the error case, the + application may repeatedly call inflateSync, providing more input each time, + until success or end of the input data. +*/ + +extern int EXPORT inflateReset OF((z_streamp strm)); +/* + This function is equivalent to inflateEnd followed by inflateInit, + but does not free and reallocate all the internal decompression state. + The stream will keep attributes that may have been set by inflateInit2. + + inflateReset returns Z_OK if success, or Z_STREAM_ERROR if the source + stream state was inconsistent (such as zalloc or state being NULL). +*/ + + + /* utility functions */ + +/* + The following utility functions are implemented on top of the + basic stream-oriented functions. To simplify the interface, some + default options are assumed (compression level and memory usage, + standard memory allocation functions). The source code of these + utility functions can easily be modified if you need special options. +*/ + +extern int EXPORT compress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Compresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be at least 0.1% larger than + sourceLen plus 12 bytes. Upon exit, destLen is the actual size of the + compressed buffer. + This function can be used to compress a whole file at once if the + input file is mmap'ed. + compress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer. +*/ + +extern int EXPORT compress2 OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen, + int level)); +/* + Compresses the source buffer into the destination buffer. The level + parameter has the same meaning as in deflateInit. sourceLen is the byte + length of the source buffer. Upon entry, destLen is the total size of the + destination buffer, which must be at least 0.1% larger than sourceLen plus + 12 bytes. Upon exit, destLen is the actual size of the compressed buffer. + + compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough + memory, Z_BUF_ERROR if there was not enough room in the output buffer, + Z_STREAM_ERROR if the level parameter is invalid. +*/ + +extern int EXPORT uncompress OF((Bytef *dest, uLongf *destLen, + const Bytef *source, uLong sourceLen)); +/* + Decompresses the source buffer into the destination buffer. sourceLen is + the byte length of the source buffer. Upon entry, destLen is the total + size of the destination buffer, which must be large enough to hold the + entire uncompressed data. (The size of the uncompressed data must have + been saved previously by the compressor and transmitted to the decompressor + by some mechanism outside the scope of this compression library.) + Upon exit, destLen is the actual size of the compressed buffer. + This function can be used to decompress a whole file at once if the + input file is mmap'ed. + + uncompress returns Z_OK if success, Z_MEM_ERROR if there was not + enough memory, Z_BUF_ERROR if there was not enough room in the output + buffer, or Z_DATA_ERROR if the input data was corrupted. +*/ + + +typedef voidp gzFile; + +extern gzFile EXPORT gzopen OF((const char *path, const char *mode)); +/* + Opens a gzip (.gz) file for reading or writing. The mode parameter + is as in fopen ("rb" or "wb") but can also include a compression level + ("wb9") or a strategy: 'f' for filtered data as in "wb6f", 'h' for + Huffman only compression as in "wb1h". (See the description + of deflateInit2 for more information about the strategy parameter.) + + gzopen can be used to read a file which is not in gzip format; in this + case gzread will directly read from the file without decompression. + + gzopen returns NULL if the file could not be opened or if there was + insufficient memory to allocate the (de)compression state; errno + can be checked to distinguish the two cases (if errno is zero, the + zlib error is Z_MEM_ERROR). */ + +extern gzFile EXPORT gzdopen OF((int fd, const char *mode)); +/* + gzdopen() associates a gzFile with the file descriptor fd. File + descriptors are obtained from calls like open, dup, creat, pipe or + fileno (in the file has been previously opened with fopen). + The mode parameter is as in gzopen. + The next call of gzclose on the returned gzFile will also close the + file descriptor fd, just like fclose(fdopen(fd), mode) closes the file + descriptor fd. If you want to keep fd open, use gzdopen(dup(fd), mode). + gzdopen returns NULL if there was insufficient memory to allocate + the (de)compression state. +*/ + +extern int EXPORT gzsetparams OF((gzFile file, int level, int strategy)); +/* + Dynamically update the compression level or strategy. See the description + of deflateInit2 for the meaning of these parameters. + gzsetparams returns Z_OK if success, or Z_STREAM_ERROR if the file was not + opened for writing. +*/ + +extern int EXPORT gzread OF((gzFile file, voidp buf, unsigned len)); +/* + Reads the given number of uncompressed bytes from the compressed file. + If the input file was not in gzip format, gzread copies the given number + of bytes into the buffer. + gzread returns the number of uncompressed bytes actually read (0 for + end of file, -1 for error). */ + +extern int EXPORT gzwrite OF((gzFile file, const voidp buf, unsigned len)); +/* + Writes the given number of uncompressed bytes into the compressed file. + gzwrite returns the number of uncompressed bytes actually written + (0 in case of error). +*/ + +extern int EXPORTVA gzprintf OF((gzFile file, const char *format, ...)); +/* + Converts, formats, and writes the args to the compressed file under + control of the format string, as in fprintf. gzprintf returns the number of + uncompressed bytes actually written (0 in case of error). +*/ + +extern int EXPORT gzputc OF((gzFile file, int c)); +/* + Writes c, converted to an unsigned char, into the compressed file. + gzputc returns the value that was written, or -1 in case of error. +*/ + +extern int EXPORT gzgetc OF((gzFile file)); +/* + Reads one byte from the compressed file. gzgetc returns this byte + or -1 in case of end of file or error. +*/ + +extern int EXPORT gzflush OF((gzFile file, int flush)); +/* + Flushes all pending output into the compressed file. The parameter + flush is as in the deflate() function. The return value is the zlib + error number (see function gzerror below). gzflush returns Z_OK if + the flush parameter is Z_FINISH and all output could be flushed. + gzflush should be called only when strictly necessary because it can + degrade compression. +*/ + +extern z_off_t EXPORT gzseek OF((gzFile file, z_off_t offset, int whence)); +/* + Sets the starting position for the next gzread or gzwrite on the given + compressed file. The offset represents a number of bytes in the + uncompressed data stream. The whence parameter is defined as in lseek(2); + the value SEEK_END is not supported. + If the file is opened for reading, this function is emulated but can be + extremely slow. If the file is opened for writing, only forward seeks are + supported; gzseek then compresses a sequence of zeroes up to the new + starting position. + + gzseek returns the resulting offset location as measured in bytes from + the beginning of the uncompressed stream, or -1 in case of error, in + particular if the file is opened for writing and the new starting position + would be before the current position. +*/ + +extern int EXPORT gzrewind OF((gzFile file)); +/* + Rewinds the given file. This function is supported only for reading. + + gzrewind(file) is equivalent to (int)gzseek(file, 0L, SEEK_SET) +*/ + +extern z_off_t EXPORT gztell OF((gzFile file)); +/* + Returns the starting position for the next gzread or gzwrite on the + given compressed file. This position represents a number of bytes in the + uncompressed data stream. + + gztell(file) is equivalent to gzseek(file, 0L, SEEK_CUR) +*/ + +extern int EXPORT gzeof OF((gzFile file)); +/* + Returns 1 when EOF has previously been detected reading the given + input stream, otherwise zero. +*/ + +extern int EXPORT gzclose OF((gzFile file)); +/* + Flushes all pending output if necessary, closes the compressed file + and deallocates all the (de)compression state. The return value is the zlib + error number (see function gzerror below). +*/ + +extern const char * EXPORT gzerror OF((gzFile file, int *errnum)); +/* + Returns the error message for the last error which occurred on the + given compressed file. errnum is set to zlib error number. If an + error occurred in the file system and not in the compression library, + errnum is set to Z_ERRNO and the application may consult errno + to get the exact error code. +*/ + + /* checksum functions */ + +/* + These functions are not related to compression but are exported + anyway because they might be useful in applications using the + compression library. +*/ + +extern uLong EXPORT adler32 OF((uLong adler, const Bytef *buf, uInt len)); + +/* + Update a running Adler-32 checksum with the bytes buf[0..len-1] and + return the updated checksum. If buf is NULL, this function returns + the required initial value for the checksum. + An Adler-32 checksum is almost as reliable as a CRC32 but can be computed + much faster. Usage example: + + uLong adler = adler32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + adler = adler32(adler, buffer, length); + } + if (adler != original_adler) error(); +*/ + +extern uLong EXPORT crc32 OF((uLong crc, const Bytef *buf, uInt len)); +/* + Update a running crc with the bytes buf[0..len-1] and return the updated + crc. If buf is NULL, this function returns the required initial value + for the crc. Pre- and post-conditioning (one's complement) is performed + within this function so it shouldn't be done by the application. + Usage example: + + uLong crc = crc32(0L, Z_NULL, 0); + + while (read_buffer(buffer, length) != EOF) { + crc = crc32(crc, buffer, length); + } + if (crc != original_crc) error(); +*/ + + + /* various hacks, don't look :) */ + +/* deflateInit and inflateInit are macros to allow checking the zlib version + * and the compiler's view of z_stream: + */ +extern int EXPORT deflateInit_ OF((z_streamp strm, int level, + const char *version, int stream_size)); +extern int EXPORT inflateInit_ OF((z_streamp strm, + const char *version, int stream_size)); +extern int EXPORT deflateInit2_ OF((z_streamp strm, int level, int method, + int windowBits, int memLevel, int strategy, + const char *version, int stream_size)); +extern int EXPORT inflateInit2_ OF((z_streamp strm, int windowBits, + const char *version, int stream_size)); +#define deflateInit(strm, level) \ + deflateInit_((strm), (level), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit(strm) \ + inflateInit_((strm), ZLIB_VERSION, sizeof(z_stream)) +#define deflateInit2(strm, level, method, windowBits, memLevel, strategy) \ + deflateInit2_((strm),(level),(method),(windowBits),(memLevel),\ + (strategy), ZLIB_VERSION, sizeof(z_stream)) +#define inflateInit2(strm, windowBits) \ + inflateInit2_((strm), (windowBits), ZLIB_VERSION, sizeof(z_stream)) + + +#if !defined(_Z_UTIL_H) && !defined(NO_DUMMY_DECL) + struct internal_state {int dummy;}; /* hack for buggy compilers */ +#endif + +extern const char * EXPORT zError OF((int err)); +extern int EXPORT inflateSyncPoint OF((z_streamp z)); +extern const uLongf * EXPORT get_crc_table OF((void)); + +#ifdef __cplusplus +} +#endif + +#endif /* _ZLIB_H */ diff --git a/LFtid1056/pqdif/lib/libpqdiflib.a b/LFtid1056/pqdif/lib/libpqdiflib.a new file mode 100644 index 0000000..06316de Binary files /dev/null and b/LFtid1056/pqdif/lib/libpqdiflib.a differ diff --git a/LFtid1056/pqdif/lib/libz.a b/LFtid1056/pqdif/lib/libz.a new file mode 100644 index 0000000..eb06f96 Binary files /dev/null and b/LFtid1056/pqdif/lib/libz.a differ diff --git a/LFtid1056/pqdif_thread_processor.cpp b/LFtid1056/pqdif_thread_processor.cpp new file mode 100644 index 0000000..488a33c --- /dev/null +++ b/LFtid1056/pqdif_thread_processor.cpp @@ -0,0 +1,726 @@ +#include "pqdif_thread_processor.h" + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +// PQDIF +#include "pqdif/PQDIF.h" +#include "pqdif/include/pqdif_ph.h" +#include "pqdif/include/pqdif_id.h" + +namespace fs = std::experimental::filesystem; + +namespace { + + // ============================ + // ò + // ============================ + + constexpr int kScanIntervalSec = 60; // ɨĿ¼ + constexpr int kBackupLimit = 4800; // ɹ/ʧĿ¼ļ + constexpr size_t kParsedCacheLimit = 128; // ڴ滺 + + const char* kPqdRootDir = "download"; // Ŀ¼download//*.pqd + const char* kDoneRootDir = "download_done"; + const char* kFailRootDir = "download_fail"; + + // ============================ + // ڴ滺 + // ============================ + + std::deque g_parsed_cache; + std::mutex g_parsed_cache_mutex; + + // ============================ + // ߺ + // ============================ + + // ============================ + // Դӡ + // ãݴ浽ڴ PQDIF ݴӡ + // ============================ + + // GUID תַڲ鿴ǩֵ + std::string guid_to_string(const GUID& g) + { + char buf[64] = { 0 }; + std::snprintf(buf, sizeof(buf), + "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x", + static_cast(g.Data1), + static_cast(g.Data2), + static_cast(g.Data3), + static_cast(g.Data4[0]), + static_cast(g.Data4[1]), + static_cast(g.Data4[2]), + static_cast(g.Data4[3]), + static_cast(g.Data4[4]), + static_cast(g.Data4[5]), + static_cast(g.Data4[6]), + static_cast(g.Data4[7])); + return std::string(buf); + } + + // ӡֵǰ־ + void print_value_preview(const std::vector& values, const char* title, size_t preview_count = 5) + { + if (values.empty()) + return; + + std::cout << " " << title << " count=" << values.size() << " preview=["; + const size_t n = std::min(values.size(), preview_count); + for (size_t i = 0; i < n; ++i) + { + if (i > 0) + std::cout << ", "; + std::cout << values[i]; + } + if (values.size() > preview_count) + std::cout << ", ..."; + std::cout << "]" << std::endl; + } + + // ӡʱǰ + void print_time_preview(const std::vector& values, const char* title, size_t preview_count = 5) + { + if (values.empty()) + return; + + std::cout << " " << title << " count=" << values.size() << " preview=["; + const size_t n = std::min(values.size(), preview_count); + for (size_t i = 0; i < n; ++i) + { + if (i > 0) + std::cout << ", "; + std::cout << static_cast(values[i]); + } + if (values.size() > preview_count) + std::cout << ", ..."; + std::cout << "]" << std::endl; + } + + // ӡijһ series ıǩ + void print_series_meta(const RawSeriesTagMeta& meta, const char* name) + { + std::cout << " [" << name << "]" + << " units_id=" << meta.quantity_units_id + << " characteristic_id=" << guid_to_string(meta.quantity_characteristic_id) + << " value_type_id=" << guid_to_string(meta.value_type_id) + << " base_type=" << meta.series_base_type + << " scale=" << meta.series_scale + << " offset=" << meta.series_offset + << std::endl; + } + + // ӡͨ + void dump_channel_detail(const std::string& key, const RawChannelSeries& ch) + { + std::cout << " [CHANNEL]" + << " key=" << key + << " raw_name=" << ch.channel_tag.raw_channel_name + << " phase_id=" << ch.channel_tag.phase_id + << " quantity_type_id=" << guid_to_string(ch.channel_tag.quantity_type_id) + << " quantity_measured_id=" << ch.channel_tag.quantity_measured_id + << " freq=" << ch.channel_tag.channel_frequency + << " group_id=" << ch.channel_tag.group_id + << std::endl; + + if (!ch.times.empty()) + { + print_series_meta(ch.time_meta, "TIME"); + print_time_preview(ch.times, "TIME"); + } + + if (!ch.max_values.empty()) + { + print_series_meta(ch.max_meta, "MAX"); + print_value_preview(ch.max_values, "MAX"); + } + + if (!ch.min_values.empty()) + { + print_series_meta(ch.min_meta, "MIN"); + print_value_preview(ch.min_values, "MIN"); + } + + if (!ch.avg_values.empty()) + { + print_series_meta(ch.avg_meta, "AVG"); + print_value_preview(ch.avg_values, "AVG"); + } + + if (!ch.cp95_values.empty()) + { + print_series_meta(ch.cp95_meta, "CP95"); + print_value_preview(ch.cp95_values, "CP95"); + } + + if (!ch.val_values.empty()) + { + print_series_meta(ch.val_meta, "VAL"); + print_value_preview(ch.val_values, "VAL"); + } + } + + // ӡļݴժҪ + void dump_parsed_map_summary(const std::string& file_path, const RawChannelMap& raw_map) + { + std::cout << "========== PQDIF PARSED SUMMARY ==========" << std::endl; + std::cout << "file=" << file_path + << ", channel_count=" << raw_map.size() + << std::endl; + + for (const auto& kv : raw_map) + { + dump_channel_detail(kv.first, kv.second); + } + + std::cout << "==========================================" << std::endl; + } + + bool dump_file_basic_info(const std::string& file_path, std::string& err) + { + std::error_code ec; + fs::path p(file_path); + + if (!fs::exists(p, ec)) + { + err = "file not exists"; + return false; + } + + if (!fs::is_regular_file(p, ec)) + { + err = "not a regular file"; + return false; + } + + auto file_size = fs::file_size(p, ec); + if (ec) + { + err = "cannot get file size"; + return false; + } + + std::ifstream ifs(file_path, std::ios::binary); + if (!ifs.is_open()) + { + err = "ifstream open failed"; + return false; + } + + std::cout << "[PQDIF] file basic info: path=" << file_path + << ", size=" << file_size << std::endl; + + // ӡǰ 32 ֽʮƣжǷ׼ļͷ + unsigned char buf[32] = { 0 }; + ifs.read(reinterpret_cast(buf), sizeof(buf)); + std::streamsize n = ifs.gcount(); + + std::ostringstream oss; + oss << "[PQDIF] first " << n << " bytes: "; + for (std::streamsize i = 0; i < n; ++i) + { + oss << std::hex << std::setw(2) << std::setfill('0') + << static_cast(buf[i]) << " "; + } + std::cout << oss.str() << std::endl; + + return true; + } + + std::string to_upper_copy(std::string s) + { + std::transform(s.begin(), s.end(), s.begin(), [](unsigned char c) { + return static_cast(std::toupper(c)); + }); + return s; + } + + std::string trim_copy(const std::string& s) + { + size_t beg = 0; + while (beg < s.size() && std::isspace(static_cast(s[beg]))) + ++beg; + + size_t end = s.size(); + while (end > beg && std::isspace(static_cast(s[end - 1]))) + --end; + + return s.substr(beg, end - beg); + } + + // 淶ͨ + // ע⣺ǰ׶ֻ map keyΪʶ + std::string normalize_key(const std::string& src) + { + std::string out; + out.reserve(src.size()); + + for (char c : src) + { + unsigned char uc = static_cast(c); + if (std::isalnum(uc) || c == '[' || c == ']') + out.push_back(static_cast(std::toupper(uc))); + } + + return out; + } + + bool is_pqdif_file(const fs::path& path) + { + if (!fs::is_regular_file(path)) + return false; + + const std::string ext = to_upper_copy(path.extension().string()); + return ext == ".PQD" || ext == ".PQDIF"; + } + + bool ensure_dir(const fs::path& dir) + { + std::error_code ec; + if (fs::exists(dir, ec)) + return true; + + return fs::create_directories(dir, ec) || fs::exists(dir, ec); + } + + bool move_file_with_fallback(const fs::path& src, const fs::path& dst) + { + std::error_code ec; + ensure_dir(dst.parent_path()); + + fs::rename(src, dst, ec); + if (!ec) + return true; + + ec.clear(); + fs::copy_file(src, dst, fs::copy_options::overwrite_existing, ec); + if (ec) + return false; + + ec.clear(); + fs::remove(src, ec); + return !ec; + } + + void cleanup_backup_dir(const fs::path& dir, int limit) + { + if (limit < 0) + return; + + std::error_code ec; + if (!fs::exists(dir, ec) || !fs::is_directory(dir, ec)) + return; + + std::vector files; + for (fs::directory_iterator it(dir, ec), end; !ec && it != end; it.increment(ec)) + { + if (!ec && is_pqdif_file(it->path())) + files.push_back(it->path()); + } + + if (files.size() <= static_cast(limit)) + return; + + std::sort(files.begin(), files.end(), [](const fs::path& a, const fs::path& b) { + std::error_code ea, eb; + return fs::last_write_time(a, ea) < fs::last_write_time(b, eb); + }); + + const size_t remove_count = files.size() - static_cast(limit); + for (size_t i = 0; i < remove_count; ++i) + { + std::error_code remove_ec; + fs::remove(files[i], remove_ec); + } + } + + // ȶ keyֻڴ洢 + // ָʶҪ + std::string build_channel_key(const std::string& channel_name, double channel_freq, int group_id) + { + std::ostringstream oss; + oss << trim_copy(channel_name); + + if (channel_freq > 0.0) + { + const int harmonic_no = static_cast(std::llround(channel_freq / 50.0)); + if (harmonic_no > 0) + oss << "[" << harmonic_no << "]"; + } + else if (group_id > 0) + { + oss << "[" << group_id << "]"; + } + + return normalize_key(oss.str()); + } + + // ============================ + // + // ============================ + + bool push_parsed_result_to_cache(ParsedPqdifFile&& parsed) + { + std::lock_guard guard(g_parsed_cache_mutex); + + if (g_parsed_cache.size() >= kParsedCacheLimit) + { + std::cout << "[PQDIF] cache full, drop oldest: " + << g_parsed_cache.front().source_file << std::endl; + g_parsed_cache.pop_front(); + } + + g_parsed_cache.emplace_back(std::move(parsed)); + return true; + } + + // ============================ + // PQDIF ԭʼ + // ǰ׶Σֻǩ + ԭʼֵ + // ============================ + + bool parse_pqdif_file_raw(const std::string& file_path, RawChannelMap& out_map, std::string& err) + { + CPQDIF file_convert; + file_convert.put_FlatFileName(file_path); + + std::string basic_err; + if (!dump_file_basic_info(file_path, basic_err)) + { + err = "precheck failed: " + basic_err; + return false; + } + + if (!file_convert.Read()) + { + err = "CPQDIF::Read() failed"; + return false; + } + + const int record_count = static_cast(file_convert.RecordGetCount()); + + for (int i_record = 0; i_record < record_count; ++i_record) + { + GUID record_guid{}; + std::string record_name; + + if (!file_convert.RecordGetInfo(i_record, &record_guid, record_name)) + continue; + + // ǰ׶ֻ Observation Record + if (!PQDIF_IsEqualGUID(record_guid, tagRecObservation)) + continue; + + long observation_handle = 0; + if (!file_convert.RecordRequestObservation(i_record, &observation_handle)) + continue; + + DATE time_start = 0; + std::string observation_name; + long channel_count = 0; + + if (!file_convert.ObservationGetInfo(observation_handle, time_start, observation_name, channel_count)) + { + file_convert.RecordReleaseObservation(observation_handle); + continue; + } + + // ǰֻ߳ͳ Observation¼ Observation + long trigger_method_id = 0; + DATE trigger_time = 0; + file_convert.ObservationGetTriggerInfo(observation_handle, &trigger_method_id, &trigger_time); + + if (trigger_method_id == ID_TRIGGER_METH_CHANNEL || trigger_method_id == -1) + { + file_convert.RecordReleaseObservation(observation_handle); + continue; + } + + time_t observation_start_ts = 0; + file_convert.GetTime(time_start, &observation_start_ts); + + // ͨ + for (int i_channel = 0; i_channel < channel_count; ++i_channel) + { + PqdifChannelInfoEx ch_info; + if (!file_convert.ObservationGetChannelInfoEx(observation_handle, i_channel, &ch_info)) + continue; + + if (ch_info.name.empty()) + continue; + + double channel_freq = 0.0; + int group_id = 0; + file_convert.ObservationGetChannelFreq(observation_handle, i_channel, &channel_freq); + file_convert.ObservationGetChannelGroupID(observation_handle, i_channel, &group_id); + + const std::string key = build_channel_key(ch_info.name, channel_freq, group_id); + RawChannelSeries& raw_series = out_map[key]; + + // ͨǩ + raw_series.channel_tag.raw_channel_name = ch_info.name; + raw_series.channel_tag.normalized_channel_name = key; + raw_series.channel_tag.phase_id = ch_info.phaseId; + raw_series.channel_tag.quantity_type_id = ch_info.quantityTypeId; + raw_series.channel_tag.quantity_measured_id = ch_info.quantityMeasuredId; + raw_series.channel_tag.channel_frequency = channel_freq; + raw_series.channel_tag.group_id = group_id; + + // ͨµ series + for (int i_series = 0; i_series < ch_info.countSeries; ++i_series) + { + PqdifSeriesInfoEx sr_info; + if (!file_convert.ObservationGetSeriesInfoEx(observation_handle, i_channel, i_series, &sr_info)) + continue; + + double* values = nullptr; + long value_count = 0; + + if (!file_convert.ObservationGetSeriesData(observation_handle, i_channel, i_series, &values, &value_count) || + values == nullptr || value_count <= 0) + { + delete[] values; + continue; + } + + RawSeriesTagMeta series_meta; + series_meta.quantity_units_id = sr_info.quantityUnitsId; + series_meta.quantity_characteristic_id = sr_info.quantityCharacteristicId; + series_meta.value_type_id = sr_info.valueTypeId; + series_meta.series_base_type = sr_info.seriesBaseType; + series_meta.series_scale = sr_info.scale; + series_meta.series_offset = sr_info.offset; + + // ͬ valueType 浽ͬͰ + if (PQDIF_IsEqualGUID(sr_info.valueTypeId, ID_SERIES_VALUE_TYPE_TIME)) + { + raw_series.time_meta = series_meta; + for (long i = 0; i < value_count; ++i) + { + raw_series.times.push_back( + observation_start_ts + static_cast(std::llround(values[i])) + ); + } + } + else if (PQDIF_IsEqualGUID(sr_info.valueTypeId, ID_SERIES_VALUE_TYPE_MAX)) + { + raw_series.max_meta = series_meta; + raw_series.max_values.insert(raw_series.max_values.end(), values, values + value_count); + } + else if (PQDIF_IsEqualGUID(sr_info.valueTypeId, ID_SERIES_VALUE_TYPE_MIN)) + { + raw_series.min_meta = series_meta; + raw_series.min_values.insert(raw_series.min_values.end(), values, values + value_count); + } + else if (PQDIF_IsEqualGUID(sr_info.valueTypeId, ID_SERIES_VALUE_TYPE_AVG)) + { + raw_series.avg_meta = series_meta; + raw_series.avg_values.insert(raw_series.avg_values.end(), values, values + value_count); + } + else if (PQDIF_IsEqualGUID(sr_info.valueTypeId, ID_SERIES_VALUE_TYPE_P95)) + { + raw_series.cp95_meta = series_meta; + raw_series.cp95_values.insert(raw_series.cp95_values.end(), values, values + value_count); + } + else if (PQDIF_IsEqualGUID(sr_info.valueTypeId, ID_SERIES_VALUE_TYPE_VAL)) + { + raw_series.val_meta = series_meta; + raw_series.val_values.insert(raw_series.val_values.end(), values, values + value_count); + } + + delete[] values; + } + } + + file_convert.RecordReleaseObservation(observation_handle); + } + + file_convert.Close(); + return true; + } + + // ============================ + // ļ + // ============================ + + bool process_single_pqdif_file(const fs::path& file_path, const std::string& mac) + { + RawChannelMap raw_map; + std::string err; + + if (!parse_pqdif_file_raw(file_path.string(), raw_map, err)) + { + std::cout << "[PQDIF] parse failed: " << file_path.string() + << " reason=" << err << std::endl; + return false; + } + + // ԣӡνݴ + dump_parsed_map_summary(file_path.string(), raw_map); + + ParsedPqdifFile parsed_file; + parsed_file.mac = mac; + parsed_file.source_file = file_path.string(); + parsed_file.parsed_at = std::time(nullptr); + parsed_file.channels = std::move(raw_map); + + if (!push_parsed_result_to_cache(std::move(parsed_file))) + { + std::cout << "[PQDIF] push cache failed: " << file_path.string() << std::endl; + return false; + } + + std::cout << "[PQDIF] processed ok: " << file_path.string() + << " channels=" << GetParsedPqdifCacheSize() + << std::endl; + + //ڴ˴ļ + + + return true; + } + + // ============================ + // ɨĿ¼ + // ============================ + + void scan_once() + { + ensure_dir(kPqdRootDir); + ensure_dir(kDoneRootDir); + ensure_dir(kFailRootDir); + + std::error_code ec; + if (!fs::exists(kPqdRootDir, ec) || !fs::is_directory(kPqdRootDir, ec)) + return; + + // һĿ¼ mac + for (fs::directory_iterator mac_it(kPqdRootDir, ec), mac_end; !ec && mac_it != mac_end; mac_it.increment(ec)) + { + if (ec || !fs::is_directory(mac_it->path())) + continue; + + const std::string mac = mac_it->path().filename().string(); + std::vector pqdif_files; + + std::error_code file_ec; + for (fs::directory_iterator file_it(mac_it->path(), file_ec), file_end; !file_ec && file_it != file_end; file_it.increment(file_ec)) + { + if (!file_ec && is_pqdif_file(file_it->path())) + pqdif_files.push_back(file_it->path()); + } + + if (pqdif_files.empty()) + continue; + + // ȴļ + std::sort(pqdif_files.begin(), pqdif_files.end(), [](const fs::path& a, const fs::path& b) { + std::error_code ea, eb; + return fs::last_write_time(a, ea) > fs::last_write_time(b, eb); + }); + + for (const auto& file_path : pqdif_files) + { + const bool ok = process_single_pqdif_file(file_path, mac); + + const fs::path target_root = ok ? fs::path(kDoneRootDir) : fs::path(kFailRootDir); + const fs::path dst = target_root / mac / file_path.filename(); + + //ʱʱرļת + /*if (!move_file_with_fallback(file_path, dst)) + { + std::cout << "[PQDIF] move failed: " + << file_path.string() << " -> " << dst.string() + << std::endl; + }*/ + } + + cleanup_backup_dir(fs::path(kDoneRootDir) / mac, kBackupLimit); + cleanup_backup_dir(fs::path(kFailRootDir) / mac, kBackupLimit); + } + } + +} // namespace + +// ============================ +// ⻺ӿ +// ============================ + +bool PopOldestParsedPqdifFile(ParsedPqdifFile& out) +{ + std::lock_guard guard(g_parsed_cache_mutex); + + if (g_parsed_cache.empty()) + return false; + + out = std::move(g_parsed_cache.front()); + g_parsed_cache.pop_front(); + return true; +} + +bool PeekOldestParsedPqdifFile(ParsedPqdifFile& out) +{ + std::lock_guard guard(g_parsed_cache_mutex); + + if (g_parsed_cache.empty()) + return false; + + out = g_parsed_cache.front(); + return true; +} + +size_t GetParsedPqdifCacheSize() +{ + std::lock_guard guard(g_parsed_cache_mutex); + return g_parsed_cache.size(); +} + +void ClearParsedPqdifCache() +{ + std::lock_guard guard(g_parsed_cache_mutex); + g_parsed_cache.clear(); +} + +// ============================ +// ߳ѭ +// ============================ + +void RunPqdifScanLoop() +{ + std::cout << "[PQDIF] scan loop started, root=" << kPqdRootDir + << ", interval=" << kScanIntervalSec << "s" + << std::endl; + + while (true) + { + try + { + scan_once(); + } + catch (const std::exception& ex) + { + std::cout << "[PQDIF] scan exception: " << ex.what() << std::endl; + } + catch (...) + { + std::cout << "[PQDIF] scan exception: unknown" << std::endl; + } + + std::this_thread::sleep_for(std::chrono::seconds(kScanIntervalSec)); + } +} \ No newline at end of file diff --git a/LFtid1056/pqdif_thread_processor.h b/LFtid1056/pqdif_thread_processor.h new file mode 100644 index 0000000..e1a4595 --- /dev/null +++ b/LFtid1056/pqdif_thread_processor.h @@ -0,0 +1,84 @@ +#pragma once +#pragma once + +#include +#include +#include +#include +#include + +#include "pqdif/include/pqdif_ph.h" + +// ============================ +// ͨǩ +// ============================ +struct RawChannelTagMeta +{ + std::string raw_channel_name; // ԭʼ tagChannelName + std::string normalized_channel_name; // ڲõĹ淶 key + + long phase_id = -1; // tagPhaseID + GUID quantity_type_id{}; // tagQuantityTypeID + long quantity_measured_id = -1; // tagQuantityMeasuredID + + double channel_frequency = 0.0; // ʶг + int group_id = 0; // ʶг +}; + +// ============================ +// ϵмǩ +// ============================ +struct RawSeriesTagMeta +{ + long quantity_units_id = -1; // tagQuantityUnitsID + GUID quantity_characteristic_id{}; // tagQuantityCharacteristicID + GUID value_type_id{}; // tagValueTypeID + + long series_base_type = -1; // ǰṩϢ + double series_scale = 1.0; // ϵ + double series_offset = 0.0; // ƫ +}; + +// ============================ +// ͨһԭʼͳ +// ǰ׶ֻǩ + ԭʼֵ +// ============================ +struct RawChannelSeries +{ + RawChannelTagMeta channel_tag; + + RawSeriesTagMeta time_meta; + RawSeriesTagMeta max_meta; + RawSeriesTagMeta min_meta; + RawSeriesTagMeta avg_meta; + RawSeriesTagMeta cp95_meta; + RawSeriesTagMeta val_meta; + + std::vector times; + std::vector max_values; + std::vector min_values; + std::vector avg_values; + std::vector cp95_values; + std::vector val_values; +}; + +// ļͨ +using RawChannelMap = std::map; + +// һ PQDIF ļݴ +struct ParsedPqdifFile +{ + std::string mac; // 豸Ŀ¼ + std::string source_file; // ԭʼļ· + time_t parsed_at = 0; // ʱ + RawChannelMap channels; // ͨ +}; + +// PQDIF ɨ߳ +void RunPqdifScanLoop(); + +// ʽӿ +bool PopOldestParsedPqdifFile(ParsedPqdifFile& out); +bool PeekOldestParsedPqdifFile(ParsedPqdifFile& out); +size_t GetParsedPqdifCacheSize(); +void ClearParsedPqdifCache(); \ No newline at end of file