修复连续采集时没有时间间隔导致通讯失败从而导致无有法正常连续采集的问题 修改如下
This commit is contained in:
8
.gitignore
vendored
8
.gitignore
vendored
@ -22,3 +22,11 @@ dist-ssr
|
||||
*.njsproj
|
||||
*.sln
|
||||
*.sw?
|
||||
/myis11/project/is11/cmake-build-debug-visual-studio-2022/
|
||||
/myis11/project/is11/cmake-build-release-visual-studio-2022/
|
||||
/myis11/project/is11/vscode/
|
||||
/myis11/.vscode/
|
||||
/myis11/.cmake/
|
||||
/.vscode/
|
||||
/src-tauri/.cargo/
|
||||
/.vscode/
|
||||
|
@ -23,7 +23,7 @@
|
||||
padding: 0px;
|
||||
}
|
||||
</style>
|
||||
<script src="http://localhost:8098"></script>
|
||||
<!-- <script src="http://localhost:8098"></script> -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
27
myis11/project/is11/CMakeLists.txt
Normal file
27
myis11/project/is11/CMakeLists.txt
Normal file
@ -0,0 +1,27 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
project(is11lib)
|
||||
if (MSVC)
|
||||
# 静态链接多线程版本的运行时库
|
||||
set(CMAKE_CXX_FLAGS "/MT")
|
||||
set(CMAKE_C_FLAGS "/MT")
|
||||
|
||||
endif()
|
||||
include_directories(../../src/test)
|
||||
include_directories(../../src/is11)
|
||||
add_library(is11lib SHARED
|
||||
../../src/test/test.cpp
|
||||
../../src/is11/SensorIS11.cpp
|
||||
../../src/is11/SensorIS11.h
|
||||
../../src/is11/IS11Comon.cpp
|
||||
../../src/is11/IS11Comon.h
|
||||
../../src/is11/IS11_INST.cpp
|
||||
../../src/is11/IS11_INST.h
|
||||
|
||||
)
|
||||
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||
|
||||
|
||||
add_executable(is11test
|
||||
testmain.cpp
|
||||
)
|
||||
target_link_libraries(is11test is11lib)
|
18
myis11/project/is11/testmain.cpp
Normal file
18
myis11/project/is11/testmain.cpp
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : testmain.cpp
|
||||
* @author : xin
|
||||
* @brief : None
|
||||
* @attention : None
|
||||
* @date : 2024/8/14
|
||||
******************************************************************************
|
||||
*/
|
||||
#include "IS11_INST.h"
|
||||
int main() {
|
||||
// IS11SensorInit();
|
||||
Set_Serial_FUN(NULL,NULL);
|
||||
return 0;
|
||||
}
|
||||
//
|
||||
// Created by xin on 2024/8/14.
|
||||
//
|
238
myis11/src/is11/IS11Comon.cpp
Normal file
238
myis11/src/is11/IS11Comon.cpp
Normal file
@ -0,0 +1,238 @@
|
||||
#include "IS11Comon.h"
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
#elif
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#endif
|
||||
|
||||
void delay(int ms){
|
||||
Sleep(ms);
|
||||
}
|
||||
|
||||
|
||||
u_char BufferForRead[10000];
|
||||
int TotalIndexNow = 0;
|
||||
u_char BufferFortempWrite[1000];
|
||||
// MySerialWrite=nullptr;
|
||||
SERIALWRITE MySerialWrite = nullptr;
|
||||
SERIALREAD MySerialRead = nullptr;
|
||||
bool ISIS11Init = false;
|
||||
uint16_t crc16(const uint8_t *data, size_t len, uint16_t polynomial)
|
||||
{
|
||||
uint16_t i, j, tmp, CRC16;
|
||||
|
||||
CRC16 = 0xFFFF; // CRC寄存器初始值
|
||||
for (i = 0; i < len; i++)
|
||||
{
|
||||
CRC16 ^= data[i];
|
||||
for (j = 0; j < 8; j++)
|
||||
{
|
||||
tmp = (uint16_t)(CRC16 & 0x0001);
|
||||
CRC16 >>= 1;
|
||||
if (tmp == 1)
|
||||
{
|
||||
CRC16 ^= polynomial; // 异或多项式
|
||||
}
|
||||
}
|
||||
}
|
||||
return CRC16;
|
||||
}
|
||||
|
||||
size_t SendSettingCommand(u_char *Command, size_t CommandLenth, u_char *Value, size_t ValueLenth)
|
||||
{
|
||||
memcpy(BufferFortempWrite, Command, CommandLenth);
|
||||
memcpy(BufferFortempWrite + CommandLenth, Value, ValueLenth);
|
||||
uint16_t crc = crc16(BufferFortempWrite, CommandLenth + ValueLenth);
|
||||
memcpy(BufferFortempWrite + CommandLenth + ValueLenth, &crc, 2);
|
||||
SerialWrite(BufferFortempWrite, CommandLenth + ValueLenth + 2);
|
||||
// Serial.write(BufferFortempWrite, CommandLenth+ValueLenth + 2);
|
||||
return GetSetBackFromSensor();
|
||||
}
|
||||
|
||||
size_t SendGetData(int shutter)
|
||||
{
|
||||
int lenth = sizeof(GET_ALL_DN);
|
||||
uint16_t crc = crc16(GET_ALL_DN, lenth);
|
||||
memcpy(BufferFortempWrite, GET_ALL_DN, lenth);
|
||||
memcpy(BufferFortempWrite + lenth, &crc, 2);
|
||||
SerialWrite(BufferFortempWrite, lenth + 2);
|
||||
// Serial.write(BufferFortempWrite, lenth + 2);
|
||||
// Serial.println(shutter);
|
||||
|
||||
|
||||
delay(shutter);
|
||||
return GetInfoBackFromSensor(true);
|
||||
}
|
||||
|
||||
size_t SendGetSensorInfo(u_char *Command, size_t lenth)
|
||||
{
|
||||
|
||||
uint16_t crc = crc16(Command, lenth);
|
||||
memcpy(BufferFortempWrite, Command, lenth);
|
||||
memcpy(BufferFortempWrite + lenth, &crc, 2);
|
||||
// Serial.println((int)MySerialWrite);
|
||||
// Serial.write(BufferFortempWrite,lenth+2);
|
||||
//delay(200);
|
||||
SerialWrite(BufferFortempWrite, lenth + 2);
|
||||
|
||||
size_t retunnumber = GetInfoBackFromSensor();
|
||||
|
||||
return retunnumber;
|
||||
}
|
||||
|
||||
size_t GetSetBackFromSensor()
|
||||
{
|
||||
TotalIndexNow = 0;
|
||||
TotalIndexNow += (int)SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
|
||||
while (TotalIndexNow < 8)
|
||||
{
|
||||
// Serial.println(TotalIndexNow);
|
||||
// Serial.write(BufferForRead,1);
|
||||
TotalIndexNow += (int)SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
}
|
||||
return TotalIndexNow;
|
||||
}
|
||||
|
||||
bool panduanHeader()
|
||||
{
|
||||
if (TotalIndexNow < 2)
|
||||
{
|
||||
return false;
|
||||
/* code */
|
||||
}
|
||||
int temp = 0;
|
||||
while (BufferForRead[temp] != 0x01 &&
|
||||
!(BufferForRead[temp + 1] == 0x03 || BufferForRead[temp + 1] == 0x06 || BufferForRead[temp + 1] == 0x10))
|
||||
{
|
||||
if (temp >= TotalIndexNow - 2)
|
||||
{
|
||||
break;
|
||||
/* code */
|
||||
}
|
||||
temp++;
|
||||
|
||||
/* code */
|
||||
}
|
||||
memcpy(BufferForRead, BufferForRead + temp, TotalIndexNow - temp);
|
||||
TotalIndexNow = TotalIndexNow - temp;
|
||||
temp = 0;
|
||||
if (BufferForRead[temp] != 0x01 &&
|
||||
!(BufferForRead[temp + 1] == 0x03 || BufferForRead[temp + 1] == 0x06 || BufferForRead[temp + 1] == 0x10))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
size_t GetInfoBackFromSensor(bool isbig) // big 是指用几个字节表示数据长度 暂时只发现采集数据时用两个字节
|
||||
{
|
||||
|
||||
if (isbig)
|
||||
{
|
||||
// 长度用两个字节表示
|
||||
// Serial.println(shutter);
|
||||
// Serial.println("i am here12312312312312312");
|
||||
TotalIndexNow = 0;
|
||||
BufferForRead[0] = 0x00;
|
||||
TotalIndexNow +=(int) SerailRead(BufferForRead + TotalIndexNow, 2);
|
||||
|
||||
// while(BufferForRead)
|
||||
|
||||
while (!panduanHeader())
|
||||
{
|
||||
TotalIndexNow +=(int) SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
}
|
||||
while (TotalIndexNow < 4)
|
||||
{
|
||||
// Serial.write(BufferForRead,TotalIndexNow);
|
||||
//delay(20);
|
||||
// Serial.println("i am here12312312312312312");
|
||||
TotalIndexNow += (int)SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
}
|
||||
|
||||
int lenth = BufferForRead[2] * 256 + BufferForRead[3];
|
||||
while (TotalIndexNow < lenth + 4)
|
||||
{
|
||||
// delay(20);
|
||||
// Serial.write(BufferForRead,TotalIndexNow);
|
||||
// Serial.println(lenth);
|
||||
// Serial.println(TotalIndexNow);
|
||||
// Serial.println("i am here12312312312312312");
|
||||
TotalIndexNow +=(int) SerailRead(BufferForRead + TotalIndexNow, 1024);
|
||||
}
|
||||
return TotalIndexNow;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 长度用一个字节表示
|
||||
TotalIndexNow = 0;
|
||||
TotalIndexNow += (int)SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
|
||||
while (TotalIndexNow < 3)
|
||||
{
|
||||
TotalIndexNow += (int)SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
}
|
||||
int lenth = BufferForRead[2];
|
||||
while (TotalIndexNow < lenth + 5)
|
||||
{
|
||||
TotalIndexNow += (int)SerailRead(BufferForRead + TotalIndexNow, 1);
|
||||
}
|
||||
// Serial.write(BufferForRead,TotalIndexNow);
|
||||
return TotalIndexNow;
|
||||
}
|
||||
}
|
||||
|
||||
size_t SerialWrite(u_char *data, size_t lenth)
|
||||
{
|
||||
if (MySerialWrite != nullptr)
|
||||
{
|
||||
// Serial.println("init ok");
|
||||
return MySerialWrite(data, lenth);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t SerailRead(u_char *data, size_t lenth)
|
||||
{
|
||||
if (MySerialRead != nullptr)
|
||||
{
|
||||
return MySerialRead(data, lenth);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
void InitFunction(SERIALWRITE a, SERIALWRITE readfunc)
|
||||
{
|
||||
MySerialWrite = a;
|
||||
MySerialRead = readfunc;
|
||||
//std::string temp = "01";
|
||||
//a((u_char *)temp.c_str(), 2);
|
||||
ISIS11Init = true;
|
||||
}
|
||||
|
||||
u_char *GetDataBufferPTR()
|
||||
{
|
||||
return BufferForRead;
|
||||
}
|
||||
bool isSensorInit()
|
||||
{
|
||||
return ISIS11Init;
|
||||
}
|
||||
|
||||
void CoverLittleAndBig(char *data, int lenth)
|
||||
{
|
||||
char *tempdata = new char[lenth];
|
||||
memcpy(tempdata, data, lenth);
|
||||
|
||||
for (size_t i = 0; i < lenth / 2; i++)
|
||||
{
|
||||
data[2 * i] = tempdata[2 * i + 1];
|
||||
data[2 * i + 1] = tempdata[2 * i];
|
||||
/* code */
|
||||
}
|
||||
delete[] tempdata;
|
||||
}
|
136
myis11/src/is11/IS11Comon.h
Normal file
136
myis11/src/is11/IS11Comon.h
Normal file
@ -0,0 +1,136 @@
|
||||
|
||||
/**
|
||||
* @brief is11相关底层函数
|
||||
*
|
||||
*/
|
||||
#ifndef __IS11COMON_H__
|
||||
#define __IS11COMON_H__
|
||||
|
||||
#ifndef IS11COMMON_H
|
||||
#define IS11COMMON_H
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string>
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
#define COMMAND_GET 0x03
|
||||
#define COMMAND_SET 0x06
|
||||
#define COMMAND_MULTSET 0x10
|
||||
#define POLYNOMIAL 0xa001 //modbus crc
|
||||
#include "comon.h"
|
||||
|
||||
|
||||
const u_char GET_ADDRESS[]={0x01,0x03,0x00,0x01,0x00,0x01};
|
||||
const u_char GET_BANDRATE[]={0x01,0x03,0x00,0x02,0x00,0x01};
|
||||
const u_char GET_INTEGRAL_TIME[]={0x01,0x03,0x00,0x06,0x00,0x01};
|
||||
const u_char GET_AVERAGE_NUMBER[]={0x01,0x03,0x00,0x07,0x00,0x01};
|
||||
const u_char GET_WAVELENTH_AT_BAND[]={0x01, 0x03, 0x00,0x10, 0x00,0x02};
|
||||
const u_char GET_VALUE_AT_BAND[]={0x01, 0x03, 0x00,0x30, 0x00,0x02};
|
||||
const u_char GET_SETTING_OF_LAMP[]={0x01, 0x03, 0x00,0x04, 0x00,0x01};
|
||||
const u_char GET_WAVELENTH_COEFF[]={0x01, 0x03, 0x00,0x20, 0x00,0x08};
|
||||
const u_char GET_ALL_DN[]={0x01, 0x03, 0x01,0x00, 0x10,0x00};
|
||||
const u_char GET_SERIAL_NUMBER[]={0x01, 0x03, 0x00,0x40, 0x00,0x00};
|
||||
const u_char GET_PRODUCT_NAME[]={0x01, 0x03, 0x00,0x50, 0x00,0x00};
|
||||
|
||||
const u_char SET_ADDRESS[]={0x01,0x06, 0x00,0x01};
|
||||
const u_char SET_BandRATE[]={0x01,0x06, 0x00,0x02};
|
||||
const u_char SET_INTEGRAL_TIME[]={0x01,0x06, 0x00,0x06};
|
||||
const u_char SET_AVERAGE_NUMBER[]={0x01,0x06, 0x00,0x07};
|
||||
const u_char SET_WORK_MODE[]={0x01,0x06, 0x00,0x01};
|
||||
const u_char SET_WAVELENTH_COEFF[]={0x01,0x10,0x00,0x20,0x00,0x08,0x16};
|
||||
|
||||
/**
|
||||
* @brief 判断传感器是否初始化完成
|
||||
*
|
||||
* @return true
|
||||
* @return false
|
||||
*/
|
||||
bool isSensorInit();
|
||||
/**
|
||||
* @brief 初始化传感器
|
||||
*
|
||||
* @param writefunc 写函数
|
||||
* @param readfunc 读函数
|
||||
*/
|
||||
void InitFunction(SERIALWRITE writefunc,SERIALWRITE readfunc);
|
||||
|
||||
/**
|
||||
* @brief 获取 BufferForRead 的指针 用于读取返回的数据
|
||||
*
|
||||
*/
|
||||
u_char * GetDataBufferPTR();
|
||||
|
||||
/**
|
||||
* @brief 发送获取设备信息的指令 适用于Get指令
|
||||
*
|
||||
* @param Command 指令 预定的数组
|
||||
* @param lenth 指令长度 可以用sizeof来求算
|
||||
* @return size_t 返回数据的长度 输出存放于 BufferForRead;
|
||||
*/
|
||||
size_t SendGetSensorInfo(u_char * Command,size_t lenth);//此过程不适合获取数据
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param shutter
|
||||
* @return size_t
|
||||
*/
|
||||
size_t SendGetData(int shutter);
|
||||
/**
|
||||
* @brief 发送设置指令
|
||||
*
|
||||
* @param Command 指令内容
|
||||
* @param CommandLenth 指令长度
|
||||
* @param Value 设置值
|
||||
* @param ValueLenth 值长度 默认是两个字节
|
||||
* @return size_t 返回值长度
|
||||
*/
|
||||
size_t SendSettingCommand(u_char * Command,size_t CommandLenth,u_char *Value,size_t ValueLenth=2);
|
||||
|
||||
//big
|
||||
/**
|
||||
* @brief 用来获取信息的返回的数据
|
||||
*
|
||||
* @param isbig 是指用几个字节表示数据长度 暂时只发现采集数据时用两个字节
|
||||
* @return size_t 接收到的数据大小
|
||||
*/
|
||||
size_t GetInfoBackFromSensor(bool isbig=false);
|
||||
/**
|
||||
* @brief 获取设置后返回数据
|
||||
*
|
||||
* @return size_t 返回数据长度;
|
||||
*/
|
||||
size_t GetSetBackFromSensor();
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @brief
|
||||
*
|
||||
* @param data
|
||||
* @param lenth
|
||||
* @return size_t
|
||||
*/
|
||||
|
||||
size_t SerialWrite(u_char* data,size_t lenth);
|
||||
size_t SerailRead(u_char* data,size_t lenth=0);
|
||||
/**
|
||||
* @brief 计算crc16
|
||||
*
|
||||
* @param data 数据
|
||||
* @param len 数据长度
|
||||
* @param polynomial crc16多项式 默认是A001H
|
||||
* @return uint16_t crc16的值
|
||||
*/
|
||||
uint16_t crc16(const uint8_t *data, size_t len, uint16_t polynomial=POLYNOMIAL) ;
|
||||
|
||||
bool panduanHeader();
|
||||
|
||||
|
||||
void CoverLittleAndBig(char *data,int lenth);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
#endif // __IS11COMON_H__
|
60
myis11/src/is11/IS11_INST.cpp
Normal file
60
myis11/src/is11/IS11_INST.cpp
Normal file
@ -0,0 +1,60 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : IS11_INST.cpp
|
||||
* @author : xin
|
||||
* @brief : None
|
||||
* @attention : None
|
||||
* @date : 2024/8/14
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Created by xin on 2024/8/14.
|
||||
//
|
||||
#include "SensorIS11.h"
|
||||
#include "IS11_INST.h"
|
||||
#include "iostream"
|
||||
#include "cstring"
|
||||
|
||||
SensorIS11 *thissensorIS11;
|
||||
int IS11SensorInit()
|
||||
{
|
||||
std::cout<< "IS11SensorInit" << std::endl;
|
||||
thissensorIS11 = new SensorIS11();
|
||||
thissensorIS11->initSensor(1);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void Set_Serial_FUN(SERIALWRITE writefunc,SERIALWRITE readfunc)
|
||||
{
|
||||
InitFunction(writefunc,readfunc);
|
||||
}
|
||||
|
||||
STRsensorinfo_C Get_SensorInfo() {
|
||||
STRSensorInfo sensorinfo= thissensorIS11->SensorInfo;
|
||||
STRsensorinfo_C sensorinfo_c;
|
||||
//把sensorname 拷贝到sensorinfo_c
|
||||
strcpy_s(sensorinfo_c.SensorName,sensorinfo.SensorName.c_str());
|
||||
sensorinfo_c.BandNum = sensorinfo.BandNum;
|
||||
sensorinfo_c.maxValue = sensorinfo.maxValue;
|
||||
strcpy_s(sensorinfo_c.serialnumber,sensorinfo.serialnumber.c_str());
|
||||
sensorinfo_c.a1 = sensorinfo.a1;
|
||||
sensorinfo_c.a2 = sensorinfo.a2;
|
||||
sensorinfo_c.a3 = sensorinfo.a3;
|
||||
sensorinfo_c.a4 = sensorinfo.a4;
|
||||
sensorinfo_c.issensorinit= sensorinfo.isSensorInit;
|
||||
return sensorinfo_c;
|
||||
|
||||
|
||||
}
|
||||
|
||||
int IS11OptSnenser(int percent) {
|
||||
return thissensorIS11->OptSnenser(percent);
|
||||
}
|
||||
|
||||
int IS11GetData(uint16_t *outdata, int shuttertime) {
|
||||
thissensorIS11->GetOneDate(shuttertime);
|
||||
memcpy(outdata,thissensorIS11->DATABUFF, sizeof(int16_t)*thissensorIS11->SensorInfo.BandNum);
|
||||
return thissensorIS11->SensorInfo.BandNum;
|
||||
|
||||
}
|
34
myis11/src/is11/IS11_INST.h
Normal file
34
myis11/src/is11/IS11_INST.h
Normal file
@ -0,0 +1,34 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : IS11_INST.h
|
||||
* @author : xin
|
||||
* @brief : None
|
||||
* @attention : None
|
||||
* @date : 2024/8/14
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Created by xin on 2024/8/14.
|
||||
//
|
||||
|
||||
#ifndef IS11LIB_IS11_INST_H
|
||||
#define IS11LIB_IS11_INST_H
|
||||
#include "comon.h"
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
|
||||
__declspec(dllexport) int IS11SensorInit();
|
||||
__declspec(dllexport) void Set_Serial_FUN(SERIALWRITE writefunc,SERIALWRITE readfunc);
|
||||
__declspec(dllexport) STRsensorinfo_C Get_SensorInfo();
|
||||
__declspec(dllexport) int IS11OptSnenser(int percent);
|
||||
__declspec(dllexport) int IS11GetData(uint16_t *outdata,int shuttertime);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#endif //IS11LIB_IS11_INST_H
|
292
myis11/src/is11/SensorIS11.cpp
Normal file
292
myis11/src/is11/SensorIS11.cpp
Normal file
@ -0,0 +1,292 @@
|
||||
#include"SensorIS11.h"
|
||||
#include "iostream"
|
||||
bool SensorIS11::initSensor(int id)
|
||||
{
|
||||
|
||||
DataRetrun=GetDataBufferPTR();
|
||||
// IS1Sensor.SetPortName(id);
|
||||
SensorInfo=GetSensorInfo();
|
||||
// pinMode(22,OUTPUT);
|
||||
// pinMode(23,OUTPUT);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
STRSensorInfo SensorIS11::GetSensorInfo()
|
||||
{
|
||||
|
||||
STRSensorInfo setem;
|
||||
if (!isSensorInit())
|
||||
{
|
||||
|
||||
return setem;
|
||||
}
|
||||
|
||||
|
||||
int retlenth= SendGetSensorInfo((u_char *)GET_SERIAL_NUMBER,sizeof(GET_SERIAL_NUMBER));
|
||||
|
||||
char * result=new char[5];
|
||||
memcpy(result,DataRetrun+3,4);
|
||||
result[4]='\0';
|
||||
std::cout<<result<<std::endl;
|
||||
std::string str11(result);
|
||||
setem.serialnumber=str11;
|
||||
delete[] result;
|
||||
//Serial.println(setem.serialnumber);
|
||||
|
||||
retlenth= SendGetSensorInfo((u_char *)GET_PRODUCT_NAME,sizeof(GET_PRODUCT_NAME));
|
||||
result=new char[5];
|
||||
memcpy(result,DataRetrun+3,4);
|
||||
// delay(500);
|
||||
|
||||
result[4]='\0';
|
||||
std::string str1(result);
|
||||
setem.SensorName=str1;
|
||||
delete result;
|
||||
setem.BandNum=2048;
|
||||
|
||||
setem.maxValue=65535;
|
||||
|
||||
setem.wavelenthlist=new float[setem.BandNum]();
|
||||
retlenth= SendGetSensorInfo((u_char *)GET_WAVELENTH_COEFF,sizeof(GET_WAVELENTH_COEFF));
|
||||
float a[4];
|
||||
memcpy(a,DataRetrun+3,16);
|
||||
|
||||
CoverLittleAndBig((char *)a,4*sizeof(float));
|
||||
int bandsss= setem.BandNum;
|
||||
#ifdef ARDUINO
|
||||
|
||||
Serial.print("a0:");
|
||||
Serial.print(a[0]);
|
||||
Serial.print(" a1:");
|
||||
Serial.print(a[1]);
|
||||
Serial.print(" a2:");
|
||||
Serial.print(a[2]);
|
||||
Serial.print(" a3:");
|
||||
Serial.println(a[3]);
|
||||
#endif
|
||||
|
||||
std::cout<<"a0:"<<a[0]<<" a1:"<<a[1]<<" a2:"<<a[2]<<" a3:"<<a[3]<<std::endl;
|
||||
|
||||
setem.a1=a[0];
|
||||
setem.a2=a[1];
|
||||
setem.a3=a[2];
|
||||
setem.a4=a[3];
|
||||
for ( int i = 1; i <=bandsss ; i++)
|
||||
{
|
||||
setem.wavelenthlist[i-1] = a[0] * i*i*i + a[1] * i*i + a[2] * i + a[3];
|
||||
setem.WavelenthStr=setem.WavelenthStr+std::to_string( setem.wavelenthlist[i-1])+",";
|
||||
}
|
||||
// delay(500);
|
||||
// Serial.write(dataretrun,retlenth);
|
||||
// memcpy(a,dataretrun+)
|
||||
u_char temp[2]={0x00,0x01};
|
||||
retlenth=SendSettingCommand((u_char*)SET_AVERAGE_NUMBER,sizeof(SET_AVERAGE_NUMBER),temp,sizeof(temp));
|
||||
// Serial.println("init ok");
|
||||
|
||||
return setem;
|
||||
|
||||
|
||||
}
|
||||
|
||||
void SensorIS11::SetShutter(int id)
|
||||
{
|
||||
#ifdef ARDUINO
|
||||
switch (id) {
|
||||
case 0:
|
||||
{
|
||||
digitalWrite(22,LOW);
|
||||
digitalWrite(23,LOW);
|
||||
delay(200);
|
||||
break;
|
||||
}
|
||||
case 1:{
|
||||
digitalWrite(23,HIGH);
|
||||
digitalWrite(22,LOW);
|
||||
delay(200);
|
||||
break;
|
||||
}
|
||||
case 2:{
|
||||
digitalWrite(22,HIGH);
|
||||
digitalWrite(23,LOW);
|
||||
delay(200);
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void SensorIS11::GetOneDate(int msc)
|
||||
{
|
||||
|
||||
if (msc!=shutternow)
|
||||
{
|
||||
u_char shutter[2];
|
||||
shutter[0]=msc/256;
|
||||
shutter[1]=msc%256;
|
||||
SendSettingCommand((u_char *) SET_INTEGRAL_TIME,sizeof(SET_INTEGRAL_TIME),shutter,sizeof(shutter));
|
||||
|
||||
}
|
||||
shutternow=msc;
|
||||
size_t retsize= SendGetData(shutternow);
|
||||
memcpy(DATABUFF,DataRetrun+4,4096);
|
||||
shortLittletoBiG(DATABUFF, SensorInfo.BandNum*2);
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
int SensorIS11::OptSnenser(int persent)
|
||||
{
|
||||
long maxtime = 20000;
|
||||
int maxvalue=SensorInfo.maxValue*1.0*persent / 100;
|
||||
int maxvaluenow = 0;
|
||||
float shutternow = 10;
|
||||
GetOneDate(shutternow);
|
||||
maxvaluenow= Getmaxvalue(DATABUFF, SensorInfo.BandNum);
|
||||
|
||||
int numberoftry = 0;
|
||||
while (maxvaluenow<maxvalue*0.95 || maxvaluenow>maxvalue) {
|
||||
if (maxvaluenow > maxvalue)
|
||||
{
|
||||
shutternow = shutternow *0.7;
|
||||
}
|
||||
else
|
||||
{
|
||||
shutternow = maxvalue * 0.98 / (maxvaluenow * 1.0)*shutternow + 1;
|
||||
}
|
||||
if (shutternow > maxtime)
|
||||
{
|
||||
shutternow = maxtime;
|
||||
break;
|
||||
}
|
||||
GetOneDate(shutternow);
|
||||
maxvaluenow= Getmaxvalue(DATABUFF, SensorInfo.BandNum);
|
||||
#ifdef ARDUINO
|
||||
Serial.print("now Shutter is :");
|
||||
Serial.print(shutternow);
|
||||
Serial.print(" maxvalue is :");
|
||||
Serial.println(maxvaluenow);
|
||||
#else
|
||||
std::cout<<"now Shutter is :"<<shutternow<<" maxvalue is :"<<maxvaluenow<<std::endl;
|
||||
#endif
|
||||
numberoftry++;
|
||||
if (numberoftry > 200)
|
||||
{
|
||||
|
||||
return maxtime;
|
||||
|
||||
}
|
||||
if (shutternow == maxtime)
|
||||
{
|
||||
|
||||
return maxtime;
|
||||
}
|
||||
}
|
||||
#ifdef ARDUINO
|
||||
Serial.print("zi dong value:");
|
||||
Serial.println(shutternow);
|
||||
#endif
|
||||
if (shutternow<0)
|
||||
{
|
||||
shutternow=maxtime;
|
||||
/* code */
|
||||
}
|
||||
|
||||
return shutternow;
|
||||
}
|
||||
|
||||
void SensorIS11::shortLittletoBiG(unsigned short *data,int lenth)
|
||||
{
|
||||
CoverLittleAndBig((char *)data,lenth);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
int SensorIS11::Getmaxvalue(unsigned short *data,int lenth)
|
||||
{
|
||||
int ret=-1;
|
||||
for (int i = 0; i < lenth; ++i) {
|
||||
if (data[i]>ret){
|
||||
ret=data[i];
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
void SensorIS11::TakeOneJob()
|
||||
{
|
||||
|
||||
SetShutter(1);
|
||||
int shutter=OptSnenser(90);
|
||||
|
||||
shutterup=shutter;
|
||||
GetOneDate(shutter);
|
||||
// Serial.println("Finish Up ------Green2313123");
|
||||
if (UpData==nullptr)
|
||||
{
|
||||
UpData=new unsigned short[SensorInfo.BandNum*2];
|
||||
/* code */
|
||||
}
|
||||
|
||||
memcpy(UpData,DATABUFF,SensorInfo.BandNum*2);
|
||||
SetShutter(0);
|
||||
GetOneDate(shutter);
|
||||
for (int i = 0; i < SensorInfo.BandNum; ++i) {
|
||||
// UpData[i]=UpData[i]-DATABUFF[i];
|
||||
}
|
||||
shutterup=shutter;
|
||||
|
||||
bool dingbing=false;
|
||||
#ifdef DINBIAO
|
||||
String strout="1 shutteruo is "+String(shutterup)+" Finish Up ------Green change the fiber";
|
||||
PrintFunc(strout );
|
||||
digitalWrite(21, LOW);
|
||||
delay(60000);
|
||||
SensorInfo.SensorName=SensorInfo.SensorName+"cali";
|
||||
Serial.println("begindown");
|
||||
digitalWrite(21, HIGH);
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
SetShutter(2);
|
||||
shutter=OptSnenser(90);
|
||||
shutterdown=shutter;
|
||||
GetOneDate(shutter);
|
||||
if (DownData==nullptr)
|
||||
{
|
||||
DownData=new unsigned short[SensorInfo.BandNum*2];
|
||||
/* code */
|
||||
}
|
||||
memcpy(DownData,DATABUFF,SensorInfo.BandNum*2);
|
||||
SetShutter(0);
|
||||
GetOneDate(shutter);
|
||||
|
||||
|
||||
for (int i = 0; i < SensorInfo.BandNum; ++i) {
|
||||
// DownData[i]=DownData[i]-DATABUFF[i];
|
||||
}
|
||||
shutterdown=shutter;
|
||||
|
||||
#ifdef DINBIAO
|
||||
String strout1="2 shutterdown is "+String(shutterdown)+" Down Finish ------Blue";
|
||||
PrintFunc(strout1 );
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
SensorIS11::SensorIS11()
|
||||
{
|
||||
shutternow=0;
|
||||
// DataRetrun=GetDataBufferPTR();
|
||||
}
|
43
myis11/src/is11/SensorIS11.h
Normal file
43
myis11/src/is11/SensorIS11.h
Normal file
@ -0,0 +1,43 @@
|
||||
#ifndef SENSORIS11_H
|
||||
#define SENSORIS11_H
|
||||
|
||||
#include "comon.h"
|
||||
#include "IS11Comon.h"
|
||||
|
||||
|
||||
|
||||
class SensorIS11 {
|
||||
public:
|
||||
SensorIS11();
|
||||
STRSensorInfo SensorInfo;
|
||||
bool initSensor(int id = 2);
|
||||
STRSensorInfo GetSensorInfo();
|
||||
void SetShutter(int id);// 0 dark 1 green 2 blue
|
||||
void GetOneDate(int msc);
|
||||
int OptSnenser(int percent);
|
||||
unsigned short DATABUFF[2048];
|
||||
int shutterup,shutterdown;
|
||||
unsigned short *DownData=nullptr;
|
||||
unsigned short *UpData=nullptr;
|
||||
void shortLittletoBiG( unsigned short *data,int lenth);
|
||||
|
||||
int Getmaxvalue(unsigned short *data,int lenth);
|
||||
void TakeOneJob();
|
||||
PRINTFUNC PrintFunc;
|
||||
|
||||
|
||||
|
||||
int shutternow;
|
||||
//uint16_t result[2048];
|
||||
|
||||
|
||||
u_char *DataRetrun;
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif
|
43
myis11/src/is11/comon.h
Normal file
43
myis11/src/is11/comon.h
Normal file
@ -0,0 +1,43 @@
|
||||
|
||||
#pragma once
|
||||
#include <string>
|
||||
|
||||
typedef unsigned char u_char;
|
||||
/**
|
||||
* @brief 串口写函数类型
|
||||
*
|
||||
*/
|
||||
typedef size_t (*SERIALWRITE)(u_char* data,size_t lenth);
|
||||
/**
|
||||
* @brief 串口读函数原型
|
||||
*
|
||||
*/
|
||||
typedef size_t (*SERIALREAD)(u_char* data,size_t lenth);
|
||||
struct STRSensorInfo
|
||||
{
|
||||
std::string SensorName;
|
||||
long maxValue;
|
||||
long BandNum;
|
||||
std::string WavelenthStr;
|
||||
float *wavelenthlist;
|
||||
//double *wavelenth;
|
||||
bool isSensorInit;
|
||||
std::string serialnumber;
|
||||
float a1,a2,a3,a4;
|
||||
|
||||
};
|
||||
struct STRsensorinfo_C
|
||||
{
|
||||
char SensorName[100];
|
||||
long maxValue;
|
||||
long BandNum;
|
||||
char serialnumber[100];
|
||||
float a1,a2,a3,a4;
|
||||
u_char issensorinit;
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef void (*PRINTFUNC)(std::string );
|
||||
|
25
myis11/src/test/test.cpp
Normal file
25
myis11/src/test/test.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : test.cpp
|
||||
* @author : xin
|
||||
* @brief : None
|
||||
* @attention : None
|
||||
* @date : 2024/8/14
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Created by xin on 2024/8/14.
|
||||
//
|
||||
|
||||
#include "test.h"
|
||||
#include "stdio.h"
|
||||
void test() {
|
||||
printf("hello world sdfsdf12131321321313132\n");
|
||||
printf("dsdf\n");
|
||||
}
|
||||
|
||||
//int isSensorInit() {
|
||||
//
|
||||
// return 1;
|
||||
//}
|
29
myis11/src/test/test.h
Normal file
29
myis11/src/test/test.h
Normal file
@ -0,0 +1,29 @@
|
||||
/**
|
||||
******************************************************************************
|
||||
* @file : test.h
|
||||
* @author : xin
|
||||
* @brief : None
|
||||
* @attention : None
|
||||
* @date : 2024/8/14
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
//
|
||||
// Created by xin on 2024/8/14.
|
||||
//
|
||||
|
||||
#ifndef MYIS11_TEST_H
|
||||
#define MYIS11_TEST_H
|
||||
|
||||
#include <cstdlib>
|
||||
#include <cinttypes>
|
||||
|
||||
extern "C" __declspec(dllexport) std::int32_t abs1(std::int32_t n) {
|
||||
return 100;
|
||||
}
|
||||
extern "C" {
|
||||
|
||||
}
|
||||
extern "C" __declspec(dllexport) void test();
|
||||
|
||||
#endif //MYIS11_TEST_H
|
57
package-lock.json
generated
57
package-lock.json
generated
@ -1579,12 +1579,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/braces/-/braces-3.0.3.tgz",
|
||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"fill-range": "^7.0.1"
|
||||
"fill-range": "^7.1.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
@ -2056,10 +2057,11 @@
|
||||
}
|
||||
},
|
||||
"node_modules/fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/fill-range/-/fill-range-7.1.1.tgz",
|
||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
},
|
||||
@ -2292,9 +2294,10 @@
|
||||
},
|
||||
"node_modules/is-number": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/is-number/-/is-number-7.0.0.tgz",
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=0.12.0"
|
||||
}
|
||||
@ -2571,12 +2574,13 @@
|
||||
}
|
||||
},
|
||||
"node_modules/micromatch": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
|
||||
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/micromatch/-/micromatch-4.0.8.tgz",
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"braces": "^3.0.2",
|
||||
"braces": "^3.0.3",
|
||||
"picomatch": "^2.3.1"
|
||||
},
|
||||
"engines": {
|
||||
@ -3128,9 +3132,10 @@
|
||||
},
|
||||
"node_modules/to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"is-number": "^7.0.0"
|
||||
},
|
||||
@ -4272,12 +4277,12 @@
|
||||
}
|
||||
},
|
||||
"braces": {
|
||||
"version": "3.0.2",
|
||||
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
|
||||
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/braces/-/braces-3.0.3.tgz",
|
||||
"integrity": "sha512-yQbXgO/OSZVD2IsiLlro+7Hf6Q18EJrKSEsdoMzKePKXct3gvD8oLcOQdIzGupr5Fj+EDe8gO/lxc1BzfMpxvA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"fill-range": "^7.0.1"
|
||||
"fill-range": "^7.1.1"
|
||||
}
|
||||
},
|
||||
"cache-content-type": {
|
||||
@ -4630,9 +4635,9 @@
|
||||
}
|
||||
},
|
||||
"fill-range": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
|
||||
"version": "7.1.1",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/fill-range/-/fill-range-7.1.1.tgz",
|
||||
"integrity": "sha512-YsGpe3WHLK8ZYi4tWDg2Jy3ebRz2rXowDxnld4bkQB00cc/1Zw9AWnC0i9ztDJitivtQvaI9KaLyKrc+hBW0yg==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"to-regex-range": "^5.0.1"
|
||||
@ -4798,7 +4803,7 @@
|
||||
},
|
||||
"is-number": {
|
||||
"version": "7.0.0",
|
||||
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/is-number/-/is-number-7.0.0.tgz",
|
||||
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
|
||||
"dev": true
|
||||
},
|
||||
@ -5027,12 +5032,12 @@
|
||||
"integrity": "sha512-iclAHeNqNm68zFtnZ0e+1L2yUIdvzNoauKU4WBA3VvH/vPFieF7qfRlwUZU+DA9P9bPXIS90ulxoUoCH23sV2w=="
|
||||
},
|
||||
"micromatch": {
|
||||
"version": "4.0.5",
|
||||
"resolved": "https://registry.npmjs.org/micromatch/-/micromatch-4.0.5.tgz",
|
||||
"integrity": "sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA==",
|
||||
"version": "4.0.8",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/micromatch/-/micromatch-4.0.8.tgz",
|
||||
"integrity": "sha512-PXwfBhYu0hBCPw8Dn0E+WDYb7af3dSLVWKi3HGv84IdF4TyFoC0ysxFd0Goxw7nSv4T/PzEJQxsYsEiFCKo2BA==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"braces": "^3.0.2",
|
||||
"braces": "^3.0.3",
|
||||
"picomatch": "^2.3.1"
|
||||
}
|
||||
},
|
||||
@ -5408,7 +5413,7 @@
|
||||
},
|
||||
"to-regex-range": {
|
||||
"version": "5.0.1",
|
||||
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"resolved": "https://mirrors.cloud.tencent.com/npm/to-regex-range/-/to-regex-range-5.0.1.tgz",
|
||||
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
|
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
{"pathofsave":"D:\\06Learn\\rust\\tarui\\testdarta","Filename":"test","caijiavgNumber":"1","useSG":true,"usehighpass":true}
|
||||
{"pathofsave":"D:\\06Learn\\rust\\tarui","Filename":"testaa","caijiavgNumber":"1","useSG":false,"usehighpass":false,"Dispatcher":{"isenable":true,"begin":"14:25","end":"23:59"}}
|
@ -1,51 +0,0 @@
|
||||
|
||||
use super::serport::serport::*;
|
||||
use super::mylog::*;
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
pub fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
#[tauri::command]
|
||||
pub fn getportnames() -> Vec<String> {
|
||||
get_port_name()
|
||||
}
|
||||
#[tauri::command]
|
||||
pub fn opencom(portname: serde_json::Value, baudrate: serde_json::Value) -> String {
|
||||
//tauri
|
||||
let portname = portname.as_str().unwrap();
|
||||
let baudrate = baudrate.as_u64().unwrap() as u32;
|
||||
set_port_info(&portname.to_string(), baudrate);
|
||||
|
||||
println!("opencom portname:{} baudrate:{}", portname, baudrate);
|
||||
logtorust(format!(
|
||||
"opencom portname:{} baudrate:{}",
|
||||
portname, baudrate
|
||||
));
|
||||
tryuseport()
|
||||
}
|
||||
#[tauri::command]
|
||||
pub fn clearportbuff() -> String {
|
||||
clearserilport()
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
pub fn setport(data: serde_json::Value) -> String {
|
||||
//判断是否存在portname和baudrate
|
||||
if !data.is_object() {
|
||||
return String::from("Invalid data");
|
||||
}
|
||||
if !data["portname"].is_string() || !data["baudrate"].is_u64() {
|
||||
return String::from("Invalid data");
|
||||
}
|
||||
let portname = data["portname"].as_str().unwrap();
|
||||
let baudrate = data["baudrate"].as_u64().unwrap() as u32;
|
||||
set_port_info(&portname.to_string(), baudrate);
|
||||
//println!("{}",readdatafromport(1000));
|
||||
String::from("Port set ok")
|
||||
}
|
||||
#[tauri::command]
|
||||
pub fn closecome() -> String {
|
||||
closeport()
|
||||
}
|
38
src-tauri/src/comman1.rs
Normal file
38
src-tauri/src/comman1.rs
Normal file
@ -0,0 +1,38 @@
|
||||
|
||||
use super::serport::serport::*;
|
||||
use super::mylog::*;
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
pub fn greet(name: &str) -> String {
|
||||
format!("Hello, {}! You've been greeted from Rust!", name)
|
||||
}
|
||||
#[tauri::command]
|
||||
pub fn getportnames() -> Vec<String> {
|
||||
get_port_name()
|
||||
|
||||
}
|
||||
// #[tauri::command]
|
||||
// pub fn opencom(portname: serde_json::Value, baudrate: serde_json::Value) -> String {
|
||||
// //tauri
|
||||
// let portname = portname.as_str().unwrap();
|
||||
// let baudrate = baudrate.as_u64().unwrap() as u32;
|
||||
// set_port_info(&portname.to_string(), baudrate);
|
||||
|
||||
// println!("opencom portname:{} baudrate:{}", portname, baudrate);
|
||||
// logtorust(format!(
|
||||
// "opencom portname:{} baudrate:{}",
|
||||
// portname, baudrate
|
||||
// ));
|
||||
// tryuseport()
|
||||
// }
|
||||
#[tauri::command]
|
||||
pub fn clearportbuff() -> String {
|
||||
clearserilport()
|
||||
}
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
pub fn closecome() -> String {
|
||||
closeport()
|
||||
}
|
@ -55,6 +55,11 @@ pub fn savecalibratefile_iris(gain: Vec<f32>, shutter: u32, direction: bool, fil
|
||||
|
||||
pub fn sendcalibratetodev_iris(gain: Vec<f32>, shutter: u32, direction: bool) -> String {
|
||||
let mut data = IS11DataStruct::default();
|
||||
if gain.len() != data.data.len() {
|
||||
logtorust(format!["Gain data length error"]);
|
||||
return "Gain data length error".to_string();
|
||||
|
||||
}
|
||||
data.data = gain.as_slice().try_into().unwrap();
|
||||
data.shutter_time = shutter as u32;
|
||||
data.direction = if direction { 1 } else { 0 };
|
||||
|
@ -93,9 +93,14 @@ pub fn _is11_opt_snenser(percent: i32) -> i32 {
|
||||
|
||||
pub fn is11_get_data(shuttertime: i32) -> Vec<u16> {
|
||||
let mut outdata: Vec<u16> = vec![0; 2048];
|
||||
|
||||
unsafe {
|
||||
|
||||
let len = IS11GetData(outdata.as_mut_ptr(), shuttertime);
|
||||
outdata.truncate(len as usize);
|
||||
|
||||
|
||||
}
|
||||
|
||||
outdata
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::is11base;
|
||||
use super::super::mydefine::*;
|
||||
use lazy_static::lazy_static;
|
||||
use chrono::{self, Datelike, Timelike};
|
||||
use chrono::{self, format, Datelike, Timelike};
|
||||
use std::thread;
|
||||
#[derive(PartialEq)]
|
||||
enum WorkStat {
|
||||
@ -12,6 +12,7 @@ enum WorkStat {
|
||||
|
||||
}
|
||||
|
||||
|
||||
use std::{
|
||||
sync::{Arc, Mutex},
|
||||
};
|
||||
@ -19,7 +20,15 @@ struct is11_dev_data {
|
||||
sensor_info: is11base::STRSensorInfo,
|
||||
shuttertime: i32,
|
||||
stat: WorkStat,
|
||||
percent: i32,
|
||||
workname: String,
|
||||
hasdark: bool,
|
||||
hasflat: bool,
|
||||
removedark: bool,
|
||||
computeflat: bool,
|
||||
average_number_data: u32,
|
||||
average_number_dark: u32,
|
||||
average_number_flat: u32,
|
||||
|
||||
}
|
||||
|
||||
@ -28,7 +37,16 @@ lazy_static! {
|
||||
sensor_info: is11base::STRSensorInfo::default(),
|
||||
shuttertime: 0,
|
||||
stat: WorkStat::IDLE,
|
||||
percent: 0,
|
||||
workname: "noting".to_string(),
|
||||
hasdark: false,
|
||||
hasflat: false,
|
||||
removedark: false,
|
||||
computeflat: true,
|
||||
average_number_data: 1,
|
||||
average_number_dark: 1,
|
||||
average_number_flat: 1,
|
||||
|
||||
}));
|
||||
}
|
||||
|
||||
@ -64,6 +82,7 @@ pub fn opt_sensor(percent: i32) -> i32 {
|
||||
}
|
||||
|
||||
dev_stat.stat=WorkStat::OPTING;
|
||||
dev_stat.percent=0;
|
||||
dev_stat.workname="opting".to_string();
|
||||
drop(dev_stat); //释放锁
|
||||
thread::spawn(move || {
|
||||
@ -73,6 +92,9 @@ pub fn opt_sensor(percent: i32) -> i32 {
|
||||
dev_statnow.stat=WorkStat::IDLE;
|
||||
dev_statnow.shuttertime=shuttertime;
|
||||
dev_statnow.workname="finish".to_string();
|
||||
dev_statnow.percent=100;
|
||||
dev_statnow.hasdark=false;
|
||||
dev_statnow.hasflat=false;
|
||||
}
|
||||
);
|
||||
|
||||
@ -83,22 +105,22 @@ pub fn opt_sensor(percent: i32) -> i32 {
|
||||
|
||||
}
|
||||
|
||||
pub fn get_now_stat()->(String,String){
|
||||
pub fn get_now_stat()->(String,String,i32){
|
||||
|
||||
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
match dev_stat.stat {
|
||||
WorkStat::IDLE => {
|
||||
return ("finish".to_string(),dev_stat.workname.clone());
|
||||
return ("finish".to_string(),dev_stat.workname.clone(),100);
|
||||
},
|
||||
WorkStat::WOKING => {
|
||||
return ("working".to_string(),dev_stat.workname.clone());
|
||||
return ("working".to_string(),dev_stat.workname.clone(),dev_stat.percent);
|
||||
},
|
||||
WorkStat::STOP => {
|
||||
return ("finish".to_string(),dev_stat.workname.clone());
|
||||
return ("finish".to_string(),dev_stat.workname.clone(),dev_stat.percent);
|
||||
},
|
||||
WorkStat::OPTING => {
|
||||
return ("opting".to_string(),dev_stat.workname.clone());
|
||||
return ("opting".to_string(),dev_stat.workname.clone(),dev_stat.percent);
|
||||
},
|
||||
|
||||
}
|
||||
@ -106,17 +128,36 @@ pub fn get_now_stat()->(String,String){
|
||||
|
||||
}
|
||||
|
||||
pub fn collect(shuttertime:u32){
|
||||
pub fn collect(shuttertime:u32,removedark:bool,computeflat:bool){
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
if dev_stat.stat != WorkStat::IDLE {
|
||||
return ;
|
||||
}
|
||||
|
||||
let averagenumber=dev_stat.average_number_data;
|
||||
dev_stat.stat=WorkStat::WOKING;
|
||||
dev_stat.percent=0;
|
||||
|
||||
dev_stat.workname="采集中".to_string();
|
||||
drop(dev_stat); //释放锁
|
||||
thread::spawn(move || {
|
||||
|
||||
|
||||
let data=is11base::is11_get_data(shuttertime as i32);
|
||||
let mut datasum:Vec<u32>=vec![0;2048];
|
||||
for _i in 0..averagenumber {
|
||||
let data=is11base::is11_get_data(shuttertime as i32);
|
||||
for i in 0..2048 {
|
||||
datasum[i]=datasum[i]+data[i] as u32;
|
||||
}
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
let info=format!("采集中,{}%",_i as f32/averagenumber as f32*100 as f32*0.9);
|
||||
dev_stat.workname=info;
|
||||
dev_stat.percent=((_i+1) as f32/averagenumber as f32*100 as f32*0.9) as i32;
|
||||
drop(dev_stat); //释放锁
|
||||
|
||||
|
||||
}
|
||||
let data=datasum.iter().map(|x| *x as f32/averagenumber as f32).collect::<Vec<f32>>();
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
let _lenth=data.len();
|
||||
println!("data len={}",_lenth);
|
||||
@ -137,8 +178,41 @@ pub fn collect(shuttertime:u32){
|
||||
tempis11data.datatype=0;
|
||||
|
||||
let mut data1=DATA_IS11.lock().unwrap();
|
||||
let darkdata=DARK_DATA.lock().unwrap();
|
||||
*data1=tempis11data;
|
||||
if removedark && dev_stat.hasdark {
|
||||
|
||||
for i in 0.._lenth {
|
||||
data1.data[i]=data1.data[i]-darkdata.data[i];
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if computeflat && dev_stat.hasflat {
|
||||
let flatdata=FLAT_DATA.lock().unwrap();
|
||||
for i in 0.._lenth {
|
||||
|
||||
let temp=flatdata.data[i]-darkdata.data[i];
|
||||
if temp<=0.0 {
|
||||
data1.data[i]=10000.0;
|
||||
}else{
|
||||
data1.data[i]=data1.data[i]/temp*10000.0;
|
||||
}
|
||||
if data1.data[i]<0.0 {
|
||||
data1.data[i]=0.0;
|
||||
|
||||
}
|
||||
if data1.data[i]>15000.0 {
|
||||
data1.data[i]=15000.0;
|
||||
}
|
||||
|
||||
// data1.data[i]=data1.data[i]/(flatdata.data[i]-darkdata.data[i])*10000.0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
dev_stat.stat=WorkStat::IDLE;
|
||||
dev_stat.percent=100;
|
||||
dev_stat.workname="finish".to_string();
|
||||
});
|
||||
|
||||
@ -154,12 +228,27 @@ pub fn collcect_dark(shuttertime:u32)
|
||||
if dev_stat.stat != WorkStat::IDLE {
|
||||
return ;
|
||||
}
|
||||
let averagenumber=dev_stat.average_number_dark;
|
||||
dev_stat.stat=WorkStat::WOKING;
|
||||
dev_stat.workname="采集中".to_string();
|
||||
dev_stat.percent=0;
|
||||
dev_stat.workname="采集Dark中".to_string();
|
||||
drop(dev_stat); //释放锁
|
||||
thread::spawn(move || {
|
||||
let mut datasum:Vec<u32>=vec![0;2048];
|
||||
for _i in 0..averagenumber {
|
||||
let data=is11base::is11_get_data(shuttertime as i32);
|
||||
for i in 0..2048 {
|
||||
datasum[i]=datasum[i]+data[i] as u32;
|
||||
}
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
let info=format!("采集Dark中,{}%",_i as f32/averagenumber as f32*100 as f32*0.9);
|
||||
dev_stat.workname=info;
|
||||
dev_stat.percent=((_i+1) as f32/averagenumber as f32*100 as f32*0.9) as i32;
|
||||
drop(dev_stat); //释放锁
|
||||
}
|
||||
let data=datasum.iter().map(|x| *x as f32/averagenumber as f32).collect::<Vec<f32>>();
|
||||
|
||||
|
||||
let data=is11base::is11_get_data(shuttertime as i32);
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
let _lenth=data.len();
|
||||
println!("data len={}",_lenth);
|
||||
@ -182,7 +271,9 @@ pub fn collcect_dark(shuttertime:u32)
|
||||
let mut data1=DARK_DATA.lock().unwrap();
|
||||
*data1=tempis11data;
|
||||
dev_stat.stat=WorkStat::IDLE;
|
||||
dev_stat.percent=100;
|
||||
dev_stat.workname="finish".to_string();
|
||||
dev_stat.hasdark=true;
|
||||
});
|
||||
|
||||
|
||||
@ -194,12 +285,26 @@ pub fn collcect_flat(shuttertime:u32)
|
||||
if dev_stat.stat != WorkStat::IDLE {
|
||||
return ;
|
||||
}
|
||||
let averagenumber=dev_stat.average_number_flat;
|
||||
dev_stat.stat=WorkStat::WOKING;
|
||||
dev_stat.percent=0;
|
||||
dev_stat.workname="采集中".to_string();
|
||||
drop(dev_stat); //释放锁
|
||||
thread::spawn(move || {
|
||||
let mut datasum:Vec<u32>=vec![0;2048];
|
||||
for _i in 0..averagenumber {
|
||||
let data=is11base::is11_get_data(shuttertime as i32);
|
||||
for i in 0..2048 {
|
||||
datasum[i]=datasum[i]+data[i] as u32;
|
||||
}
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
let info=format!("采集白板中,{}%",_i as f32/averagenumber as f32*100 as f32*0.9);
|
||||
dev_stat.workname=info;
|
||||
dev_stat.percent=((_i+1) as f32/averagenumber as f32*100 as f32*0.9) as i32;
|
||||
drop(dev_stat); //释放锁
|
||||
}
|
||||
let data=datasum.iter().map(|x| *x as f32/averagenumber as f32).collect::<Vec<f32>>();
|
||||
|
||||
let data=is11base::is11_get_data(shuttertime as i32);
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
let _lenth=data.len();
|
||||
println!("data len={}",_lenth);
|
||||
@ -222,7 +327,9 @@ pub fn collcect_flat(shuttertime:u32)
|
||||
let mut data1=FLAT_DATA.lock().unwrap();
|
||||
*data1=tempis11data;
|
||||
dev_stat.stat=WorkStat::IDLE;
|
||||
dev_stat.percent=100;
|
||||
dev_stat.workname="finish".to_string();
|
||||
dev_stat.hasflat=true;
|
||||
});
|
||||
}
|
||||
|
||||
@ -230,4 +337,31 @@ pub fn collcect_flat(shuttertime:u32)
|
||||
pub fn get_data()->IS11DataStruct{
|
||||
let data1=DATA_IS11.lock().unwrap();
|
||||
return data1.clone();
|
||||
}
|
||||
pub fn get_data_flat()->IS11DataStruct{
|
||||
let data1=FLAT_DATA.lock().unwrap();
|
||||
return data1.clone();
|
||||
}
|
||||
pub fn get_data_dark()->IS11DataStruct{
|
||||
let data1=DARK_DATA.lock().unwrap();
|
||||
return data1.clone();
|
||||
}
|
||||
pub fn get_is_computeref()->bool{
|
||||
let dev_stat=DEV_STAT.lock().unwrap();
|
||||
return dev_stat.computeflat;
|
||||
}
|
||||
|
||||
pub fn set_shutter_time(shuttertime:u32){
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
dev_stat.shuttertime=shuttertime as i32;
|
||||
dev_stat.hasdark=false;
|
||||
dev_stat.hasflat=false;
|
||||
}
|
||||
|
||||
|
||||
pub fn set_average_number(arverage_number_data:u32,arverage_number_dark:u32,arverage_number_flat:u32){
|
||||
let mut dev_stat=DEV_STAT.lock().unwrap();
|
||||
dev_stat.average_number_data=arverage_number_data;
|
||||
dev_stat.average_number_dark=arverage_number_dark;
|
||||
dev_stat.average_number_flat=arverage_number_flat;
|
||||
}
|
@ -1,23 +1,26 @@
|
||||
use super::mydefine::*;
|
||||
pub mod is11server;
|
||||
pub mod is11base;
|
||||
pub mod is11server;
|
||||
use super::mylog::*;
|
||||
use is11server::get_shuttertime;
|
||||
use serde_json::json;
|
||||
use std::ffi::CStr;
|
||||
use super::mylog::*;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pub fn sendtoport_andgetreturn(
|
||||
data: serde_json::Value,
|
||||
datatype: serde_json::Value,
|
||||
) -> Result<RetStruct, String> {
|
||||
|
||||
let command = data.get("command").unwrap().to_string();
|
||||
|
||||
println!("start_collect data:{}", data.to_string());
|
||||
match command.as_str() {
|
||||
|
||||
"\"start_collect_flat\"" => {
|
||||
return start_collect_flat(data, datatype);
|
||||
},
|
||||
|
||||
"\"start_collect_dark\"" => {
|
||||
return start_collect_dark(data, datatype);
|
||||
},
|
||||
"\"get_sensor_info\"" => {
|
||||
is11base::is11_init();
|
||||
logtorust("init is11 ok".to_string());
|
||||
@ -27,7 +30,7 @@ pub fn sendtoport_andgetreturn(
|
||||
let serilnumber_cstr = unsafe { CStr::from_ptr(sensor_info.serialnumber.as_ptr()) };
|
||||
let serilnumber = serilnumber_cstr.to_str().unwrap();
|
||||
//定义一个json对象
|
||||
let jsonforret= json!({
|
||||
let jsonforret = json!({
|
||||
"bochangxishu":{
|
||||
"a0":sensor_info.a1,
|
||||
"a1":sensor_info.a2,
|
||||
@ -35,22 +38,25 @@ pub fn sendtoport_andgetreturn(
|
||||
"a3":sensor_info.a4,
|
||||
},
|
||||
"serialnumber":serilnumber,
|
||||
"name":sensor_name,
|
||||
|
||||
"name":"IS11",
|
||||
// "name":sensor_name,
|
||||
"version":"1.0.0",
|
||||
"return_data_type":0,
|
||||
"work_mode":"advanced_mode",
|
||||
"sensor":"JZ-IS11",
|
||||
|
||||
});
|
||||
logtorust(format!("get_sensor_info:{}",jsonforret.to_string()));
|
||||
logtorust(format!("get_sensor_info:{}", jsonforret.to_string()));
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: jsonforret.to_string(),
|
||||
data:IS11DataStruct::default() ,
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
}
|
||||
"\"start_opt\"" => {
|
||||
is11server::opt_sensor(90);
|
||||
let jsonforret= json!({
|
||||
let jsonforret = json!({
|
||||
"command":"start_opt"
|
||||
|
||||
});
|
||||
@ -59,82 +65,139 @@ pub fn sendtoport_andgetreturn(
|
||||
content: jsonforret.to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
"\"get_opt\"" => {
|
||||
println!("get_opt");
|
||||
let ret=get_opt_result();
|
||||
let ret = get_opt_result();
|
||||
return ret;
|
||||
|
||||
}
|
||||
"\"start_collect\"" => {
|
||||
return start_collect(data,datatype);
|
||||
|
||||
return start_collect(data, datatype);
|
||||
}
|
||||
|
||||
"\"get_caiji_state\"" =>{
|
||||
let (caiji_state,caiji_state_str)=is11server::get_now_stat();
|
||||
let jsonforret= json!({
|
||||
|
||||
"\"get_caiji_state\"" => {
|
||||
let (caiji_state, caiji_state_str,percent) = is11server::get_now_stat();
|
||||
let jsonforret = json!({
|
||||
"caiji_state":caiji_state,
|
||||
"info":caiji_state_str,
|
||||
"percent":percent,
|
||||
"return_data_type":0,
|
||||
});
|
||||
logtorust(format!("get_caiji_state:{}",jsonforret.to_string()));
|
||||
logtorust(format!("get_caiji_state:{}", jsonforret.to_string()));
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: jsonforret.to_string(),
|
||||
data:IS11DataStruct::default() ,
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
|
||||
}
|
||||
"\"get_data\""=>{
|
||||
return get_data(data,datatype);
|
||||
}
|
||||
"\"get_data\"" => {
|
||||
return get_data(data, datatype);
|
||||
},
|
||||
"\"get_data_flat\"" => {
|
||||
return get_data_flat(data, datatype);
|
||||
},
|
||||
"\"get_data_dark\"" => {
|
||||
return get_data_dark(data, datatype);
|
||||
},
|
||||
"\"set_shutter_time\"" => {
|
||||
return set_shutter_time(data, datatype);
|
||||
},
|
||||
_ => {
|
||||
return Err("command not found ".to_string()+"command is:"+&command);
|
||||
return Err("command not found ".to_string() + "command is:" + &command);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: "指令未实现".to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
pub fn get_opt_result() -> Result<RetStruct, String> {
|
||||
|
||||
|
||||
let shuttertime = is11server::get_shuttertime();
|
||||
|
||||
let jsonret = json!({
|
||||
"opt":shuttertime,
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: jsonret.to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
pub fn start_collect( data: serde_json::Value,
|
||||
pub fn set_shutter_time(data: serde_json::Value,
|
||||
datatype: serde_json::Value) -> Result<RetStruct, String> {
|
||||
let shuttertime = data.get("shutter_time").unwrap().as_u64().unwrap() as u32;
|
||||
logtorust(format!("start_collect,shutter time is:{}",shuttertime));
|
||||
|
||||
is11server::collect(shuttertime);
|
||||
|
||||
let shuttertime: u32;
|
||||
if data.get("shutter_time").is_none() {
|
||||
shuttertime = get_shuttertime() as u32;
|
||||
} else {
|
||||
shuttertime = data.get("shutter_time").unwrap().as_u64().unwrap() as u32;
|
||||
is11server::set_shutter_time(shuttertime);
|
||||
}
|
||||
|
||||
|
||||
let jsonret = json!({
|
||||
"shuttertime":"ok",
|
||||
|
||||
});
|
||||
|
||||
|
||||
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: jsonret.to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
}
|
||||
pub fn start_collect(
|
||||
data: serde_json::Value,
|
||||
datatype: serde_json::Value,
|
||||
) -> Result<RetStruct, String> {
|
||||
|
||||
|
||||
let shuttertime: u32;
|
||||
if data.get("shutter_time").is_none() {
|
||||
shuttertime = get_shuttertime() as u32;
|
||||
} else {
|
||||
shuttertime = data.get("shutter_time").unwrap().as_u64().unwrap() as u32;
|
||||
}
|
||||
//判断是否有这个参数
|
||||
|
||||
let removedark: bool;
|
||||
if data.get("remove_dark").is_none() {
|
||||
removedark = false;
|
||||
} else {
|
||||
if data.get("remove_dark").unwrap().is_boolean() {
|
||||
removedark = data.get("remove_dark").unwrap().as_bool().unwrap();
|
||||
} else if data.get("remove_dark").unwrap().is_string() {
|
||||
let remove_dark_str = data.get("remove_dark").unwrap().as_str().unwrap();
|
||||
if remove_dark_str == "yes" {
|
||||
removedark = true;
|
||||
} else {
|
||||
removedark = false;
|
||||
}
|
||||
} else {
|
||||
removedark = false;
|
||||
}
|
||||
}
|
||||
|
||||
let computeflat = is11server::get_is_computeref();
|
||||
logtorust(format!("start_collect,shutter time is:{}", shuttertime));
|
||||
if !data.get("collect_times").is_none() {
|
||||
if data.get("collect_times").unwrap().is_u64() {
|
||||
let collect_times = data.get("collect_times").unwrap().as_u64().unwrap() as u32;
|
||||
is11server::set_average_number(collect_times,collect_times,collect_times );
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
is11server::collect(shuttertime, removedark, computeflat);
|
||||
let jsonret = json!({
|
||||
"command":"start_collect"
|
||||
|
||||
@ -144,26 +207,116 @@ pub fn start_collect( data: serde_json::Value,
|
||||
content: jsonret.to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
}
|
||||
|
||||
pub fn start_collect_dark(
|
||||
data: serde_json::Value,
|
||||
datatype: serde_json::Value,
|
||||
) -> Result<RetStruct, String> {
|
||||
let shuttertime: u32;
|
||||
if data.get("shutter_time").is_none() {
|
||||
shuttertime = get_shuttertime() as u32;
|
||||
} else {
|
||||
shuttertime = data.get("shutter_time").unwrap().as_u64().unwrap() as u32;
|
||||
}
|
||||
//判断是否有这个参数
|
||||
if !data.get("collect_times").is_none() {
|
||||
if data.get("collect_times").unwrap().is_u64() {
|
||||
let collect_times = data.get("collect_times").unwrap().as_u64().unwrap() as u32;
|
||||
is11server::set_average_number(collect_times,collect_times,collect_times );
|
||||
}
|
||||
}
|
||||
|
||||
is11server::collcect_dark(shuttertime);
|
||||
let jsonret = json!({
|
||||
"command":"start_collect_dark"
|
||||
|
||||
});
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: jsonret.to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
pub fn get_data( data: serde_json::Value,
|
||||
datatype: serde_json::Value) -> Result<RetStruct, String> {
|
||||
pub fn start_collect_flat(
|
||||
data: serde_json::Value,
|
||||
datatype: serde_json::Value,
|
||||
) -> Result<RetStruct, String> {
|
||||
let shuttertime: u32;
|
||||
if data.get("shutter_time").is_none() {
|
||||
shuttertime = get_shuttertime() as u32;
|
||||
} else {
|
||||
shuttertime = data.get("shutter_time").unwrap().as_u64().unwrap() as u32;
|
||||
}
|
||||
//判断是否有这个参数
|
||||
if !data.get("collect_times").is_none() {
|
||||
if data.get("collect_times").unwrap().is_u64() {
|
||||
let collect_times = data.get("collect_times").unwrap().as_u64().unwrap() as u32;
|
||||
is11server::set_average_number(collect_times,collect_times,collect_times );
|
||||
}
|
||||
}
|
||||
|
||||
let is11_data=is11server::get_data() ;
|
||||
|
||||
is11server::collcect_flat(shuttertime);
|
||||
let jsonret = json!({
|
||||
"command":"start_collect_flat"
|
||||
|
||||
});
|
||||
return Ok(RetStruct {
|
||||
datatype: 0,
|
||||
content: jsonret.to_string(),
|
||||
data: IS11DataStruct::default(),
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
pub fn get_data(data: serde_json::Value, datatype: serde_json::Value) -> Result<RetStruct, String> {
|
||||
let is11_data = is11server::get_data();
|
||||
|
||||
let jsonret = json!({
|
||||
"command":"get_data"
|
||||
|
||||
});
|
||||
|
||||
return Ok(RetStruct {
|
||||
datatype: 2,
|
||||
content: jsonret.to_string(),
|
||||
data: is11_data,
|
||||
});
|
||||
}
|
||||
|
||||
pub fn get_data_flat(data: serde_json::Value, datatype: serde_json::Value) -> Result<RetStruct, String> {
|
||||
let is11_data = is11server::get_data_flat();
|
||||
|
||||
let jsonret = json!({
|
||||
"command":"get_data_flat"
|
||||
|
||||
});
|
||||
|
||||
return Ok(RetStruct {
|
||||
datatype: 2,
|
||||
content:jsonret.to_string(),
|
||||
content: jsonret.to_string(),
|
||||
data: is11_data,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_data_dark(data: serde_json::Value, datatype: serde_json::Value) -> Result<RetStruct, String> {
|
||||
let is11_data = is11server::get_data_dark();
|
||||
|
||||
let jsonret = json!({
|
||||
"command":"get_data_dark"
|
||||
|
||||
});
|
||||
|
||||
return Ok(RetStruct {
|
||||
datatype: 2,
|
||||
content: jsonret.to_string(),
|
||||
data: is11_data,
|
||||
});
|
||||
}
|
@ -6,27 +6,90 @@ mod mylog;
|
||||
mod serport;
|
||||
mod irishypersptral;
|
||||
mod mydefine;
|
||||
mod comman;
|
||||
mod comman1;
|
||||
mod jianzhiis11;
|
||||
use comman::*;
|
||||
use comman1::*;
|
||||
use algorithm::interpolate_spline;
|
||||
use algorithm::sg_smooth;
|
||||
use mydefine::*;
|
||||
|
||||
enum DevName {
|
||||
IRIS_IS11,
|
||||
JZ_IS11
|
||||
|
||||
}
|
||||
|
||||
use lazy_static::lazy_static;
|
||||
use tauri::api::version;
|
||||
use std::sync::Mutex;
|
||||
use std::sync::Arc;
|
||||
//设置一个可修改的全局变量
|
||||
lazy_static! {
|
||||
static ref DEVNAME: Mutex<DevName> = Mutex::new(DevName::IRIS_IS11);
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
fn setport(data: serde_json::Value) -> String {
|
||||
//判断是否存在portname和baudrate
|
||||
if !data.is_object() {
|
||||
return String::from("Invalid data");
|
||||
}
|
||||
if !data["portname"].is_string() || !data["baudrate"].is_u64() {
|
||||
return String::from("Invalid data");
|
||||
}
|
||||
let portname = data["portname"].as_str().unwrap();
|
||||
let baudrate = data["baudrate"].as_u64().unwrap() as u32;
|
||||
serport::serport::set_port_info(&portname.to_string(), baudrate);
|
||||
//println!("{}",readdatafromport(1000));
|
||||
String::from("Port set ok")
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn savecalibratefile(gain: Vec<f32>, shutter: u32, direction: bool, filepath: String) -> String {
|
||||
irishypersptral::savecalibratefile_iris(gain, shutter, direction, filepath)
|
||||
let devname=DEVNAME.lock().unwrap();
|
||||
match *devname {
|
||||
DevName::IRIS_IS11=>{
|
||||
return irishypersptral::savecalibratefile_iris(gain, shutter, direction, filepath);
|
||||
},
|
||||
DevName::JZ_IS11=>{
|
||||
return irishypersptral::savecalibratefile_iris(gain, shutter, direction, filepath);
|
||||
//return jianzhiis11::s(gain, shutter, direction, filepath);
|
||||
}
|
||||
|
||||
}
|
||||
//irishypersptral::savecalibratefile_iris(gain, shutter, direction, filepath)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn sendcalibratetodev(gain: Vec<f32>, shutter: u32, direction: bool) -> String {
|
||||
irishypersptral::sendcalibratetodev_iris(gain, shutter, direction)
|
||||
fn sendcalibratetodev(gain: Vec<f32>, shutter: u32, direction: u32) -> String {
|
||||
let devname=DEVNAME.lock().unwrap();
|
||||
println!("sendcalibratetodev");
|
||||
match *devname {
|
||||
DevName::IRIS_IS11=>{
|
||||
return irishypersptral::sendcalibratetodev_iris(gain, shutter, direction !=0);
|
||||
},
|
||||
DevName::JZ_IS11=>{
|
||||
return irishypersptral::sendcalibratetodev_iris(gain, shutter, direction !=0);
|
||||
//return jianzhiis11::s(gain, shutter, direction, filepath);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
//irishypersptral::sendcalibratetodev_iris(gain, shutter, direction)
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#[tauri::command]
|
||||
fn __sendto_portbinary(data: Vec<u8>, command: u8) -> String {
|
||||
irishypersptral::sendtoportbinary_iris(data, command)
|
||||
@ -42,13 +105,53 @@ fn readformport(commanid: serde_json::Value, wait_time_json: serde_json::Value)
|
||||
irishypersptral::readformport_iris(commanid, wait_time_json)
|
||||
}
|
||||
|
||||
#[tauri::command]
|
||||
fn opencom(portname: serde_json::Value, baudrate: serde_json::Value) -> String {
|
||||
//tauri
|
||||
let portname = portname.as_str().unwrap();
|
||||
let devname=DEVNAME.lock().unwrap();
|
||||
let mut baudrate :u32=0;
|
||||
match *devname {
|
||||
DevName::IRIS_IS11=>{
|
||||
baudrate =115200 as u32;
|
||||
},
|
||||
DevName::JZ_IS11=>{
|
||||
baudrate =921600 as u32;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// let baudrate = baudrate.as_u64().unwrap() as u32;
|
||||
serport::serport::set_port_info(&portname.to_string(), baudrate);
|
||||
|
||||
println!("opencom portname:{} baudrate:{}", portname, baudrate);
|
||||
mylog::logtorust(format!(
|
||||
"opencom portname:{} baudrate:{}",
|
||||
portname, baudrate
|
||||
));
|
||||
serport::serport::tryuseport()
|
||||
}
|
||||
#[tauri::command]
|
||||
fn sendtoport_andgetreturn(
|
||||
data: serde_json::Value,
|
||||
datatype: serde_json::Value,
|
||||
) -> Result<RetStruct, String> {
|
||||
//irishypersptral::sendtoport_andgetreturn_iris(data, datatype)
|
||||
jianzhiis11::sendtoport_andgetreturn(data, datatype)
|
||||
//irishypersptral::sendtoport_andgetreturn_iris(data, datatype)
|
||||
let devname=DEVNAME.lock().unwrap();
|
||||
match *devname {
|
||||
DevName::IRIS_IS11=>{
|
||||
return irishypersptral::sendtoport_andgetreturn_iris(data, datatype);
|
||||
},
|
||||
DevName::JZ_IS11=>{
|
||||
return jianzhiis11::sendtoport_andgetreturn(data, datatype);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
//jianzhiis11::sendtoport_andgetreturn(data, datatype)
|
||||
|
||||
}
|
||||
|
||||
@ -69,7 +172,6 @@ fn main() {
|
||||
greet,
|
||||
getportnames,
|
||||
opencom,
|
||||
setport,
|
||||
closecome,
|
||||
sendtoport_andgetreturn,
|
||||
readformport,
|
||||
@ -83,7 +185,18 @@ fn main() {
|
||||
algorithm::find_peek
|
||||
])
|
||||
.setup(|app| {
|
||||
|
||||
|
||||
|
||||
let config = app.config();
|
||||
|
||||
|
||||
// 打印配置信息,例如窗口标题
|
||||
let producnaem = config.package.product_name.clone().unwrap();
|
||||
let version=config.package.version.clone().unwrap();
|
||||
println!("producnaem:{:?}", producnaem);
|
||||
let main_window = app.get_window("main").unwrap();
|
||||
main_window.set_title(&(producnaem+"_v"+&version));
|
||||
|
||||
// 获取屏幕大小
|
||||
if let Some(monitor) = main_window.primary_monitor().unwrap() {
|
||||
|
@ -25,6 +25,9 @@ pub struct IS11DataStruct {
|
||||
pub hour:u8,
|
||||
pub minute:u8,
|
||||
pub second:u8,
|
||||
pub nca:u8,
|
||||
pub ncb:u8,
|
||||
pub ncc:u8,
|
||||
pub shutter_time: u32,
|
||||
pub index: u64,
|
||||
pub temprature: [f32; 8],
|
||||
@ -45,7 +48,9 @@ pub struct IS11DataStruct {
|
||||
hour:0,
|
||||
minute:0,
|
||||
second:0,
|
||||
|
||||
nca:0,
|
||||
ncb:0,
|
||||
ncc:0,
|
||||
shutter_time: 0,
|
||||
index: 0,
|
||||
temprature: [0.0; 8],
|
||||
@ -67,6 +72,10 @@ impl IS11DataStruct {
|
||||
hour: self.hour,
|
||||
minute: self.minute,
|
||||
second: self.second,
|
||||
nca:self.nca,
|
||||
ncb:self.ncb,
|
||||
ncc:self.ncc,
|
||||
|
||||
shutter_time: self.shutter_time,
|
||||
index: self.index,
|
||||
temprature: self.temprature,
|
||||
|
@ -57,7 +57,10 @@ pub fn set_port_info(portname: &String, baudrate: u32) {
|
||||
|
||||
pub fn get_port_name() -> Vec<String> {
|
||||
let ports = serialport::available_ports().expect("No ports found!");
|
||||
println!("Available ports:{}", ports.len());
|
||||
let mut portnames: Vec<String> = Vec::new();
|
||||
println!("{}",portnames.len() );
|
||||
// portnames.push("COM5".to_string());
|
||||
for p in ports {
|
||||
portnames.push(p.port_name);
|
||||
}
|
||||
@ -91,7 +94,8 @@ pub fn closeport() -> String {
|
||||
//关闭端口
|
||||
port_info.port = None;
|
||||
println!("Port is closed");
|
||||
String::from("Port is closed")
|
||||
String::from("串口已关闭")
|
||||
//String::from("Port is closed")
|
||||
}
|
||||
|
||||
pub fn sendtoprot(data: Vec<u8>) -> String {
|
||||
|
@ -10,7 +10,7 @@
|
||||
|
||||
"package": {
|
||||
"productName": "SpectralPlot",
|
||||
"version": "0.5.1"
|
||||
"version": "0.5.57"
|
||||
},
|
||||
"tauri": {
|
||||
|
||||
@ -24,6 +24,7 @@
|
||||
"open": true
|
||||
},
|
||||
"fs": {
|
||||
|
||||
"scope": ["**"],
|
||||
"all": true
|
||||
|
||||
@ -65,11 +66,11 @@
|
||||
},
|
||||
|
||||
"icon": [
|
||||
"icons/1.jpg",
|
||||
"icons/1.jpg",
|
||||
"icons/1.jpg",
|
||||
"icons/1.jpg",
|
||||
"icons/1.jpg"
|
||||
"icons/icon.ico",
|
||||
"icons/icon.ico",
|
||||
"icons/icon.ico",
|
||||
"icons/icon.ico",
|
||||
"icons/icon.ico"
|
||||
]
|
||||
}
|
||||
|
||||
|
@ -8,6 +8,7 @@ import SetName from "./components/menubox/SetName.vue";
|
||||
import SetWorkmode from "./components/menubox/SetWorkmode.vue";
|
||||
import setCalibrate from "./components/menubox/SetCalibrate.vue";
|
||||
import Greet from "./components/Greet.vue";
|
||||
import EventBus from "./eventBus.js";
|
||||
import {$ref} from "vue3-json-editor/dist/vue3-json-editor.cjs.js";
|
||||
//引入
|
||||
|
||||
@ -15,7 +16,7 @@ export default {
|
||||
async onmenuclicked(command){
|
||||
|
||||
console.log("menuclicked main "+command.name)
|
||||
if (command.type=="Set")
|
||||
if (command.type=="Set" )
|
||||
{
|
||||
if (!this.isDevOpen())
|
||||
{
|
||||
@ -86,6 +87,16 @@ export default {
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (command.type=="Work")
|
||||
{
|
||||
if (!this.isDevOpen())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EventBus.emit('LetSiderDo',command.name);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -10,6 +10,7 @@ import eventBus from "../eventBus.js";
|
||||
this.initChart();
|
||||
eventBus.on("plotsetwavelength",this.setwavelength);
|
||||
eventBus.on('setprogressbar',this.setprogressbar);
|
||||
eventBus.on('setplotname',this.setplotname);
|
||||
|
||||
},
|
||||
data() {
|
||||
|
@ -48,12 +48,44 @@ export default {
|
||||
let chart = echarts.getInstanceByDom(chartDom);
|
||||
chart.setOption(this.option);
|
||||
},
|
||||
setplotname(params){
|
||||
this.option.series[0].name=params.up;
|
||||
this.option.legend.data[0]=params.up;
|
||||
if (typeof params.donw!="undefined")
|
||||
{
|
||||
this.option.series[1].name=params.donw;
|
||||
this.option.legend.data[1]=params.donw;
|
||||
}else{
|
||||
//如果大于1个数据 则删最后一个
|
||||
if (this.option.series.length>1)
|
||||
{
|
||||
this.option.series.pop();
|
||||
this.option.legend.data.pop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const chartDom = this.$refs.chart;
|
||||
let chart = echarts.getInstanceByDom(chartDom);
|
||||
chart.setOption(this.option);
|
||||
|
||||
},
|
||||
plotGraph(data, index) {
|
||||
|
||||
|
||||
if (index>=1&&this.option.series.length < 2) {
|
||||
this.option.series.push({
|
||||
data: [], // 使用二维数组表示数据点的坐标
|
||||
type: 'line',
|
||||
name: 'DOWN',
|
||||
symbol: 'none', // 不显示数据点
|
||||
smooth: false, // 不使用平滑处理
|
||||
//step: 'start' // 设置 step 类型的起始位置
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
this.option.series[index].data = data;
|
||||
|
||||
|
||||
const chartDom = this.$refs.chart;
|
||||
|
||||
@ -132,7 +164,8 @@ export default {
|
||||
left: '5%',
|
||||
right: '5%',
|
||||
bottom: '5%',
|
||||
top: '5%'
|
||||
top: '5%',
|
||||
|
||||
},
|
||||
// visualMap: [
|
||||
// {
|
||||
@ -163,7 +196,7 @@ export default {
|
||||
// },
|
||||
series: [
|
||||
{
|
||||
data: [[1, 150], [2, 230], [3, 224], [4, 218], [5, 135], [6, 147], [7, 260]], // 使用二维数组表示数据点的坐标
|
||||
data: [], // 使用二维数组表示数据点的坐标
|
||||
type: 'line',
|
||||
name: 'UP',
|
||||
symbol: 'none', // 不显示数据点
|
||||
@ -171,7 +204,7 @@ export default {
|
||||
// step: 'start' // 设置 step 类型的起始位置
|
||||
},
|
||||
{
|
||||
data: [[1, 150], [2, 230], [3, 224], [4, 218], [5, 135], [6, 147], [7, 260]], // 使用二维数组表示数据点的坐标
|
||||
data: [], // 使用二维数组表示数据点的坐标
|
||||
type: 'line',
|
||||
name: 'DOWN',
|
||||
symbol: 'none', // 不显示数据点
|
||||
@ -207,7 +240,18 @@ export default {
|
||||
console.log("resize")
|
||||
const chartDom = this.$refs.chart;
|
||||
let chart = echarts.getInstanceByDom(chartDom);
|
||||
chart.resize()
|
||||
chart.resize();
|
||||
let width=chartDom.clientWidth;
|
||||
if (width<800)
|
||||
{
|
||||
let option =this.option;
|
||||
option.grid.left="10%";
|
||||
chart.setOption(option);
|
||||
}else{
|
||||
let option =this.option;
|
||||
option.grid.left="5%";
|
||||
chart.setOption(option);
|
||||
}
|
||||
},
|
||||
|
||||
|
||||
|
@ -28,6 +28,50 @@ async function Dev_Opt() {
|
||||
|
||||
|
||||
}
|
||||
|
||||
async function Get_Data_from_dev(Datatype) {
|
||||
|
||||
let drection=Datatype;
|
||||
//获取数据 UPDN
|
||||
let data = {
|
||||
data: {
|
||||
command: "get_data",
|
||||
return_data_type: CommanDeffine.DataTypeforSend.UpDN
|
||||
},
|
||||
datatype: "json"
|
||||
}
|
||||
if(drection=="UP")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDN;
|
||||
}else if(drection=="DOWN")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.DOWNDN;
|
||||
} else if (drection=="DARK")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDarkDN;
|
||||
} else if (drection=="RAD_UP")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpRadiance;
|
||||
} else if (drection=="RAD_DOWN")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.DownRadiance;
|
||||
}
|
||||
else if (drection=="REF")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.Ref;
|
||||
|
||||
}
|
||||
|
||||
let message=await invoke("sendtoport_andgetreturn",data);
|
||||
while (message.datatype!=0x02)
|
||||
{
|
||||
message=await invoke("sendtoport_andgetreturn",data);
|
||||
}
|
||||
return message.data
|
||||
}
|
||||
|
||||
|
||||
|
||||
async function Get_Date_on_Derction(drection,shuttertimes,autoremovedark=false,avgnumber=1) {
|
||||
|
||||
|
||||
@ -37,12 +81,12 @@ async function Get_Date_on_Derction(drection,shuttertimes,autoremovedark=false,
|
||||
datatype:"json"
|
||||
}
|
||||
data.data.command="start_collect";
|
||||
if (drection=="UP")
|
||||
if (drection=="UP" || drection == "RAD_UP")
|
||||
{
|
||||
data.data.direction="up";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
|
||||
}else if (drection=="DOWN")
|
||||
}else if (drection=="DOWN"||drection == "RAD_DOWN")
|
||||
{
|
||||
data.data.direction="down";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
@ -77,6 +121,65 @@ async function Get_Date_on_Derction(drection,shuttertimes,autoremovedark=false,
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.DOWNDN;
|
||||
} else if (drection=="DARK")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDarkDN;
|
||||
} else if (drection=="RAD_UP")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpRadiance;
|
||||
} else if (drection=="RAD_DOWN")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.DownRadiance;
|
||||
}
|
||||
|
||||
message=await invoke("sendtoport_andgetreturn",data);
|
||||
while (message.datatype!=0x02)
|
||||
{
|
||||
message=await invoke("sendtoport_andgetreturn",data);
|
||||
}
|
||||
return message.data
|
||||
}
|
||||
|
||||
async function Get_Dark_Data(drection,shuttertimes,avgnumber=1) {
|
||||
var Command={command:""};
|
||||
let data={
|
||||
data:Command,
|
||||
datatype:"json"
|
||||
}
|
||||
data.data.command="start_collect_dark";
|
||||
if (drection=="UP")
|
||||
{
|
||||
data.data.direction="up";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
|
||||
}else if (drection=="DOWN")
|
||||
{
|
||||
data.data.direction="down";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
}else if(drection=="DARK")
|
||||
{
|
||||
data.data.direction="dark";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
}
|
||||
|
||||
data.data.collect_times=Number(avgnumber);
|
||||
let message=await invoke("sendtoport_andgetreturn",data);
|
||||
await EnsureNotWorking();
|
||||
|
||||
//获取数据 UPDN
|
||||
data = {
|
||||
data: {
|
||||
command: "get_data_dark",
|
||||
return_data_type: CommanDeffine.DataTypeforSend.UpDN
|
||||
},
|
||||
datatype: "json"
|
||||
}
|
||||
if(drection=="UP")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDN;
|
||||
}else if(drection=="DOWN")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.DOWNDN;
|
||||
} else if (drection=="DARK")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDarkDN;
|
||||
}
|
||||
@ -86,6 +189,73 @@ async function Get_Date_on_Derction(drection,shuttertimes,autoremovedark=false,
|
||||
{
|
||||
message=await invoke("sendtoport_andgetreturn",data);
|
||||
}
|
||||
EventBus.emit('showbox', {title: "系统", body: "采集Dark 完成",interval:10});
|
||||
EventBus.emit('setprogressbar',{percent:100,info:""});
|
||||
EventBus.emit('SetMenubutton', {name:"DC",state:"OK"});
|
||||
return message.data
|
||||
}
|
||||
|
||||
|
||||
async function Get_Flat_Data(drection,shuttertimes,avgnumber=1) {
|
||||
var Command={command:""};
|
||||
let data={
|
||||
data:Command,
|
||||
datatype:"json"
|
||||
}
|
||||
data.data.command="start_collect_flat";
|
||||
if (drection=="UP")
|
||||
{
|
||||
data.data.direction="up";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
|
||||
}else if (drection=="DOWN")
|
||||
{
|
||||
data.data.direction="down";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
}else if(drection=="DARK")
|
||||
{
|
||||
data.data.direction="dark";
|
||||
data.data.shutter_time=Number(shuttertimes);
|
||||
}
|
||||
|
||||
data.data.collect_times=Number(avgnumber);
|
||||
let message=await invoke("sendtoport_andgetreturn",data);
|
||||
await EnsureNotWorking();
|
||||
|
||||
|
||||
|
||||
|
||||
//获取数据 UPDN
|
||||
data = {
|
||||
data: {
|
||||
command: "get_data_flat",
|
||||
return_data_type: CommanDeffine.DataTypeforSend.UpDN
|
||||
},
|
||||
datatype: "json"
|
||||
}
|
||||
if(drection=="UP")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDN;
|
||||
}else if(drection=="DOWN")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.DOWNDN;
|
||||
} else if (drection=="DARK")
|
||||
{
|
||||
data.data.return_data_type=CommanDeffine.DataTypeforSend.UpDarkDN;
|
||||
}
|
||||
|
||||
message=await invoke("sendtoport_andgetreturn",data);
|
||||
while (message.datatype!=0x02)
|
||||
{
|
||||
message=await invoke("sendtoport_andgetreturn",data);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
EventBus.emit('showbox', {title: "系统", body: "采集FLat 完成",interval:10});
|
||||
EventBus.emit('setprogressbar',{percent:100,info:""});
|
||||
EventBus.emit('SetMenubutton', {name:"WR",state:"OK"});
|
||||
return message.data
|
||||
}
|
||||
|
||||
@ -170,7 +340,10 @@ function delay(ms) {
|
||||
export default {
|
||||
Dev_Opt,
|
||||
Get_Date_on_Derction,
|
||||
Get_Device_Info
|
||||
Get_Device_Info,
|
||||
Get_Dark_Data,
|
||||
Get_Flat_Data,
|
||||
Get_Data_from_dev
|
||||
|
||||
|
||||
|
||||
|
@ -3,7 +3,132 @@ import {ref} from "vue";
|
||||
import CommanDeffine from "./serportdefine.js";
|
||||
import EventBus from "../eventBus.js";
|
||||
import SerialportMethod from "./SerialPort/SerialportMethod.js";
|
||||
import { tr } from "element-plus/es/locales.mjs";
|
||||
import { type } from "vue3-json-editor/dist/vue3-json-editor.cjs.js";
|
||||
export default {
|
||||
|
||||
async onDevchange(){
|
||||
console.log(this.sensor_typeforset)
|
||||
|
||||
},
|
||||
|
||||
async onshuttimechange(time){
|
||||
|
||||
if(time ==this.lastshuttime&&this.caijiavgNumber==this.lastcaijiavgNumber) return;
|
||||
this.lastshuttime = time;
|
||||
this.lastcaijiavgNumber = this.caijiavgNumber;
|
||||
console.log(time);
|
||||
|
||||
if(!this.SerialInfo.isopen)
|
||||
{
|
||||
console.log("串口未打开");
|
||||
return;
|
||||
}
|
||||
var Command={command:"set_shutter_time",shutter_time:Number(time)};
|
||||
let data={
|
||||
data:Command,
|
||||
datatype:"json"
|
||||
}
|
||||
let message=await invoke("sendtoport_andgetreturn",data);
|
||||
|
||||
EventBus.emit('SetMenubutton', {name:"WR",state:"fail"});
|
||||
EventBus.emit('SetMenubutton', {name:"DC",state:"fail"});
|
||||
if (this.Devinfo.sensor_type!="IRIS-IS11")
|
||||
{
|
||||
this.UPStr="DN";
|
||||
EventBus.emit('setplotname',{up:"DN"});
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
async showdataasup(datatoshow){
|
||||
let coeffweave1=this.Devinfo.bochangxishu.a0;
|
||||
let coeffweave2=this.Devinfo.bochangxishu.a1;
|
||||
let coeffweave3=this.Devinfo.bochangxishu.a2;
|
||||
let coeffweave4=this.Devinfo.bochangxishu.a3;
|
||||
let lenthofdata=datatoshow.data.length;
|
||||
let dataforshow=[];
|
||||
for (var i=0;i<lenthofdata;i++)
|
||||
{
|
||||
var weave=coeffweave1*i*i*i+coeffweave2*i*i+coeffweave3*i+coeffweave4;
|
||||
dataforshow.push([weave,datatoshow.data[i]]);
|
||||
}
|
||||
|
||||
this.dataup=datatoshow;
|
||||
this.datainfoup.infolist=[];
|
||||
this.datainfoup.hasrecive=true;
|
||||
this.datainfoup.infolist.push({key:"intertime",value:datatoshow.shutter_time});
|
||||
//this.datainfoup.infolist.push({key:"序号",value:datatoshow.index});
|
||||
// this.datainfoup.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
this.Senddatatoother(dataforshow,0);
|
||||
},
|
||||
async letmedosomething(Command){
|
||||
|
||||
if (Command=="OPT")
|
||||
{
|
||||
await this.Dingbiao_OPT();
|
||||
this.GetoneData();
|
||||
}
|
||||
|
||||
|
||||
if(this.Devinfo.sensor_type=="IRIS-IS11")
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (Command=="DC")
|
||||
{
|
||||
|
||||
|
||||
let r= await confirm(' 请扣上遮光罩--》再点击确定');
|
||||
if (r)
|
||||
{
|
||||
this.iscollecting=true;
|
||||
|
||||
let datatoshow=await SerialportMethod.Get_Dark_Data("UP",this.ShutterTime[0],this.caijiavgNumber);
|
||||
this.iscollecting=false;
|
||||
// this.showdataasup(datatoshow);
|
||||
this.GetoneData();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
if (Command=="WR")
|
||||
{
|
||||
this.iscollecting=true;
|
||||
//获取波长系数
|
||||
|
||||
let datatoshow= await SerialportMethod.Get_Flat_Data("UP",this.ShutterTime[0],this.caijiavgNumber);
|
||||
// this.showdataasup(datatoshow)
|
||||
this.iscollecting=false;
|
||||
if (this.Devinfo.sensor_type!="IRIS-IS11")
|
||||
{
|
||||
this.UPStr="REF";
|
||||
EventBus.emit('setplotname',{up:"REF"});
|
||||
}
|
||||
this.GetoneData();
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
if (Command=="Save")
|
||||
{
|
||||
// if ( this.iscollecting) return;
|
||||
// await this.GetoneData("",Number(this.caijiavgNumber));
|
||||
// var aa={
|
||||
// code:"Space"
|
||||
|
||||
// }
|
||||
// await this.handlekeydown(aa);
|
||||
this.ContinueCelect(this.cajitimes);
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
async listSerialPorts() {
|
||||
|
||||
let that=this;
|
||||
@ -55,6 +180,7 @@ export default {
|
||||
if (isopen)
|
||||
{
|
||||
btn.disabled = true;
|
||||
this.buttoncolor.opencombutton="success";
|
||||
EventBus.emit('showbox',{title:"设备",body:"打开串口成功"});
|
||||
}else
|
||||
{
|
||||
@ -69,6 +195,7 @@ export default {
|
||||
async closecomport() {
|
||||
var btn = document.getElementById("opencom");
|
||||
btn.disabled = false;
|
||||
this.buttoncolor.opencombutton="light";
|
||||
var btnn = document.getElementById("closecomeside");
|
||||
btnn.disabled = true;
|
||||
alert(await invoke("closecome"));
|
||||
@ -84,6 +211,9 @@ export default {
|
||||
this.ShutterTime[0]=await SerialportMethod.Dev_Opt();
|
||||
this.ShutterTime[1]=this.ShutterTime[0];
|
||||
this.iscollecting=false;
|
||||
EventBus.emit('SetMenubutton', {name:"WR",state:"fail"});
|
||||
EventBus.emit('SetMenubutton', {name:"DC",state:"fail"});
|
||||
|
||||
},
|
||||
async GetoneData(event,caijiavgNumber=1){
|
||||
let caijimoshi=this.Devinfo.work_mode;
|
||||
@ -115,6 +245,24 @@ export default {
|
||||
await this.GetDataDrection("DARK",caijiavgNumber);
|
||||
await delay(100)
|
||||
}
|
||||
if(this.caijidirection=="RAD_UP")
|
||||
{
|
||||
await this.GetDataDrection("RAD_UP",caijiavgNumber);
|
||||
await delay(100)
|
||||
}
|
||||
if(this.caijidirection=="RAD_DOWN")
|
||||
{
|
||||
await this.GetDataDrection("RAD_DOWN",caijiavgNumber);
|
||||
await delay(100)
|
||||
}
|
||||
if(this.caijidirection=="REF")
|
||||
{
|
||||
await SerialportMethod.Get_Date_on_Derction("UP",this.ShutterTime[0],this.autoremovedark,caijiavgNumber);
|
||||
await SerialportMethod.Get_Date_on_Derction("DOWN",this.ShutterTime[1],this.autoremovedark,caijiavgNumber);
|
||||
let dataforshowup=await SerialportMethod.Get_Data_from_dev("REF");
|
||||
this.showdataasup(dataforshowup);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@ -124,10 +272,10 @@ export default {
|
||||
async GetDataDrection(drection,avgnumber=1){
|
||||
this.iscollecting=true;
|
||||
var shuttertimes=1;
|
||||
if (drection=="UP")
|
||||
if (drection=="UP"|| drection == "RAD_UP")
|
||||
{
|
||||
shuttertimes=Number(this.ShutterTime[0]);
|
||||
}else if (drection=="DOWN")
|
||||
}else if (drection=="DOWN" || drection == "RAD_DOWN")
|
||||
{
|
||||
shuttertimes=Number(this.ShutterTime[1]);
|
||||
|
||||
@ -176,22 +324,22 @@ export default {
|
||||
var weave=coeffweave1*i*i*i+coeffweave2*i*i+coeffweave3*i+coeffweave4;
|
||||
dataforshow.push([weave,datatoshow.data[i]]);
|
||||
}
|
||||
if (drection=="UP")
|
||||
if (drection=="UP" || drection == "RAD_UP")
|
||||
{
|
||||
this.dataup=datatoshow;
|
||||
this.datainfoup.infolist=[];
|
||||
this.datainfoup.hasrecive=true;
|
||||
this.datainfoup.infolist.push({key:"intertime",value:datatoshow.shutter_time});
|
||||
this.datainfoup.infolist.push({key:"序号",value:datatoshow.index});
|
||||
this.datainfoup.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
// this.datainfoup.infolist.push({key:"序号",value:datatoshow.index});
|
||||
// this.datainfoup.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
this.Senddatatoother(dataforshow,0);
|
||||
}else if (drection=="DOWN"){
|
||||
}else if (drection=="DOWN" || drection == "RAD_DOWN"){
|
||||
this.datadown=datatoshow;
|
||||
this.datainfodown.hasrecive=true;
|
||||
this.datainfodown.infolist=[];
|
||||
this.datainfodown.infolist.push({key:"intertime",value:datatoshow.shutter_time});
|
||||
this.datainfodown.infolist.push({key:"序号",value:datatoshow.index});
|
||||
this.datainfodown.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
// this.datainfodown.infolist.push({key:"序号",value:datatoshow.index});
|
||||
// this.datainfodown.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
this.Senddatatoother(dataforshow,1);
|
||||
}
|
||||
if (drection=="DARK"){
|
||||
@ -199,8 +347,8 @@ export default {
|
||||
this.datainfoup.infolist=[];
|
||||
this.datainfoup.hasrecive=true;
|
||||
this.datainfoup.infolist.push({key:"intertime",value:datatoshow.shutter_time});
|
||||
this.datainfoup.infolist.push({key:"序号",value:datatoshow.index});
|
||||
this.datainfoup.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
//this.datainfoup.infolist.push({key:"序号",value:datatoshow.index});
|
||||
// this.datainfoup.infolist.push({key:"方向",value:datatoshow.direction});
|
||||
this.Senddatatoother(dataforshow,0);
|
||||
}
|
||||
|
||||
@ -302,8 +450,8 @@ export default {
|
||||
this.datainfoup.hasrecive=true;
|
||||
|
||||
this.datainfoup.infolist.push({key:"intertime",value:datatoshowup.shutter_time});
|
||||
this.datainfoup.infolist.push({key:"序号",value:datatoshowup.index});
|
||||
this.datainfoup.infolist.push({key:"方向",value:datatoshowup.direction});
|
||||
// this.datainfoup.infolist.push({key:"序号",value:datatoshowup.index});
|
||||
// this.datainfoup.infolist.push({key:"方向",value:datatoshowup.direction});
|
||||
//this.datainfoup.data.push({key:"温度",value:dataforshowup.temperature[0]});
|
||||
|
||||
// this.datainfoup.data.push("序号",dataforshowup.index);
|
||||
@ -339,8 +487,8 @@ export default {
|
||||
this.datainfodown.hasrecive=true;
|
||||
this.datainfodown.infolist=[];
|
||||
this.datainfodown.infolist.push({key:"intertime",value:datatoshowdown.shutter_time});
|
||||
this.datainfodown.infolist.push({key:"序号",value:datatoshowdown.index});
|
||||
this.datainfodown.infolist.push({key:"方向",value:datatoshowdown.direction});
|
||||
// this.datainfodown.infolist.push({key:"序号",value:datatoshowdown.index});
|
||||
// this.datainfodown.infolist.push({key:"方向",value:datatoshowdown.direction});
|
||||
//this.datainfodown.data.push("序号",datatoshowdown.index);
|
||||
//this.datainfodown.data.push("方向",datatoshowdown.direction);
|
||||
//this.datainfodown.data.push("温度",datatoshowdown.temperature[0]);
|
||||
@ -387,6 +535,23 @@ export default {
|
||||
}
|
||||
let json=JSON.parse(message.content);
|
||||
this.Devinfo=json;
|
||||
if (typeof(this.Devinfo.sensor_type)==undefined)
|
||||
{
|
||||
this.Devinfo.sensor_type="IRIS-IS11";
|
||||
}
|
||||
|
||||
if (this.Devinfo.sensor_type=="JZ-IS11")
|
||||
{
|
||||
this.UPStr="DN"
|
||||
EventBus.emit('setplotname',{up:"DN"});
|
||||
|
||||
|
||||
|
||||
}else
|
||||
{
|
||||
EventBus.emit('setplotname',{up:"UP",down:"DOWN"});
|
||||
}
|
||||
this.datainfoup.header=this.UPStr
|
||||
|
||||
//获取波长系数
|
||||
let coeffweave1=this.Devinfo.bochangxishu.a0;
|
||||
@ -430,9 +595,9 @@ export default {
|
||||
}
|
||||
this.devinfoshow.infolist=[];
|
||||
this.devinfoshow.infolist.push({key:"设备名称",value:this.Devinfo.name});
|
||||
this.devinfoshow.infolist.push({key:"设备序列号",value:this.Devinfo.SerilNumber});
|
||||
this.devinfoshow.infolist.push({key:"采集模式",value:this.Devinfo.Caji_mode});
|
||||
this.devinfoshow.infolist.push({key:"数据类型",value:this.Devinfo.Datatype});
|
||||
// this.devinfoshow.infolist.push({key:"设备序列号",value:this.Devinfo.SerilNumber});
|
||||
//this.devinfoshow.infolist.push({key:"采集模式",value:this.Devinfo.Caji_mode});
|
||||
// this.devinfoshow.infolist.push({key:"数据类型",value:this.Devinfo.Datatype});
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -27,6 +27,14 @@ export default {
|
||||
return {
|
||||
msg: 'Welcome to Your Vue.js App',
|
||||
modal:false,
|
||||
DCbutton:{
|
||||
state:"init",
|
||||
|
||||
},
|
||||
WRbutton:{
|
||||
state:"init",
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
},
|
||||
@ -42,13 +50,28 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
window.addEventListener("keydown",this.handlekeydown)
|
||||
EventBus.on('SetMenubutton',this.setbutton);
|
||||
},
|
||||
methods: {
|
||||
setbutton(command){
|
||||
if (command.name == "DC"){
|
||||
this.DCbutton.state = command.state;
|
||||
}
|
||||
if (command.name == "WR"){
|
||||
this.WRbutton.state = command.state;
|
||||
}
|
||||
|
||||
},
|
||||
|
||||
showbox(){
|
||||
EventBus.emit('showbox',"hello","提示11")
|
||||
},
|
||||
|
||||
onmenuclick(type, name) {
|
||||
|
||||
|
||||
|
||||
|
||||
console.log("menu " + name + " click");
|
||||
let command = {
|
||||
name: name,
|
||||
@ -107,13 +130,13 @@ export default {
|
||||
</BNavItemDropdown>
|
||||
|
||||
<!-- <!– Navbar dropdowns –>-->
|
||||
<!-- <BNavItemDropdown text="窗口" right>-->
|
||||
<BNavItemDropdown text="窗口" right>
|
||||
|
||||
<!-- <BDropdownItem @click="showbox">EN</BDropdownItem>-->
|
||||
<!-- <BDropdownItem >ES</BDropdownItem>-->
|
||||
<!-- <BDropdownItem href="#">RU</BDropdownItem>-->
|
||||
<!-- <BDropdownItem href="#">FA</BDropdownItem>-->
|
||||
<!-- </BNavItemDropdown>-->
|
||||
</BNavItemDropdown>
|
||||
|
||||
<BNavItemDropdown text="设置" right>
|
||||
<BDropdownItem @click="onmenuclick('Set','Workmode')">工作模式</BDropdownItem>
|
||||
@ -121,6 +144,13 @@ export default {
|
||||
<BDropdownItem @click="onmenuclick('Set','Weavelenth')">波长系数</BDropdownItem>
|
||||
<BDropdownItem @click="onmenuclick('Set','Calibrate')">定标</BDropdownItem>
|
||||
</BNavItemDropdown>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<!-- <Teleport to="body">-->
|
||||
<!-- <div class="toast-container position-fixed " style="top:0px;right: 0px;width: 300px" >-->
|
||||
<!-- <BToast v-model="active" variant="info" interval="10" value="100" progress-props="{-->
|
||||
@ -136,11 +166,13 @@ export default {
|
||||
<!-- <BButton @click="active = !active">Toggle</BButton>-->
|
||||
</BNavbarNav>
|
||||
<div class="btgroup">
|
||||
<b-button variant="secondary" pill class="siglebt" @click="onmenuclick('Work','OPT')">OPT</b-button>
|
||||
<b-button :variant='DCbutton.state=="OK"?"success":"secondary"' pill class="siglebt" @click=" onmenuclick('Work','DC') ">DC</b-button>
|
||||
|
||||
<b-button :variant='WRbutton.state=="OK"?"success":"secondary"' pill class="siglebt" @click="onmenuclick('Work','WR')">WR</b-button>
|
||||
<b-button variant="secondary" pill class="siglebt" disabled @click="onmenuclick('Work','Rad')">Rad</b-button>
|
||||
<b-button variant="secondary" pill class="siglebt" @click="onmenuclick('Work','Save')">Save</b-button>
|
||||
|
||||
<b-button variant="secondary" pill class="siglebt">DC</b-button>
|
||||
<b-button variant="secondary" pill class="siglebt">Rad</b-button>
|
||||
<b-button variant="secondary" pill class="siglebt">WR</b-button>
|
||||
<b-button variant="secondary" pill class="siglebt">OPT</b-button>
|
||||
</div>
|
||||
</BNavbar>
|
||||
</template>
|
||||
|
@ -5,6 +5,7 @@ import * as echarts from "echarts";
|
||||
import EventBus from "../../eventBus.js";
|
||||
import {dialog, fs} from "@tauri-apps/api";
|
||||
import {invoke} from "@tauri-apps/api/tauri";
|
||||
import SerilporDefine from "../serportdefine.js";
|
||||
export default {
|
||||
name: "SetCalibrate",
|
||||
data(){
|
||||
@ -39,6 +40,21 @@ export default {
|
||||
// this.initChart();
|
||||
},
|
||||
methods: {
|
||||
|
||||
updateCalifile(){
|
||||
let aa=invoke("sendcalibratetodev",{
|
||||
gain:this.upGain.gain,
|
||||
shutter:this.upGain.shutter_time,
|
||||
direction:SerilporDefine.Derection.Up
|
||||
});
|
||||
console.log(aa);
|
||||
let aa1=invoke("sendcalibratetodev",{
|
||||
gain:this.downGain.gain,
|
||||
shutter:this.downGain.shutter_time,
|
||||
direction:SerilporDefine.Derection.Down
|
||||
});
|
||||
console.log(aa1);
|
||||
},
|
||||
async readFileAndParse() {
|
||||
|
||||
var options= {
|
||||
@ -246,7 +262,7 @@ export default {
|
||||
let coeffweave3=this.Devinfo.bochangxishu.a2;
|
||||
let coeffweave4=this.Devinfo.bochangxishu.a3;
|
||||
if (dire == "UP") {
|
||||
var data = await SerialportMethod.Get_Date_on_Derction(dire,this.shutter_time_up,false,Number(this.caijicishu[0]))
|
||||
var data = await SerialportMethod.Get_Date_on_Derction(dire,this.shutter_time_up,true,Number(this.caijicishu[0]))
|
||||
this.DataUP=data;
|
||||
this.DataUP.value_lable=0
|
||||
//获取波长系数
|
||||
@ -265,7 +281,7 @@ export default {
|
||||
// console.log(dataforshow);
|
||||
}else if(dire=="DOWN")
|
||||
{
|
||||
var data = await SerialportMethod.Get_Date_on_Derction(dire,this.shutter_time_down,false,Number(this.caijicishu[0]))
|
||||
var data = await SerialportMethod.Get_Date_on_Derction(dire,this.shutter_time_down,true,Number(this.caijicishu[0]))
|
||||
this.DataDown=data;
|
||||
this.DataDown.value_lable=0
|
||||
//获取波长系数
|
||||
@ -371,18 +387,20 @@ export default {
|
||||
async SaveGaindata(){
|
||||
if(this.upGain.shutter_time!=0)
|
||||
{
|
||||
await invoke("savecalibratefile",{
|
||||
console.log(this.upGain.gain);
|
||||
let data={
|
||||
gain:this.upGain.gain,
|
||||
shutter:this.upGain.shutter_time,
|
||||
direction:true,
|
||||
filepath:"./calibratefile/upgain.bin"
|
||||
});
|
||||
await invoke("sendcalibratetodev",{
|
||||
gain:this.upGain.gain,
|
||||
shutter:this.upGain.shutter_time,
|
||||
direction:true
|
||||
}
|
||||
await invoke("savecalibratefile",data);
|
||||
// await invoke("sendcalibratetodev",{
|
||||
// gain:this.upGain.gain,
|
||||
// shutter:this.upGain.shutter_time,
|
||||
// direction:true
|
||||
|
||||
});
|
||||
// });
|
||||
}
|
||||
|
||||
if(this.downGain.shutter_time!=0)
|
||||
@ -432,7 +450,32 @@ export default {
|
||||
let lampup=lampData[i]*UpLabel/lampLabel;
|
||||
let lampdown=lampData[i]*DownLabel/lampLabel;
|
||||
let gainup=lampup/upDn;
|
||||
//判断upDN是否为0 如果是0 则gainup为前一个值 如果是第一个 则为1
|
||||
|
||||
if (upDn==0)
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
gainup=1;
|
||||
}else{
|
||||
gainup=gainofup[i-1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
let gaindown=lampdown/downDn;
|
||||
//判断downDn是否为0 如果是0 则gainup为前一个值 如果是第一个 则为1
|
||||
if (downDn==0)
|
||||
{
|
||||
if (i==0)
|
||||
{
|
||||
gaindown=1;
|
||||
}else{
|
||||
gaindown=gainofdown[i-1];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
gainofup.push(gainup);
|
||||
gainofdown.push(gaindown);
|
||||
@ -554,7 +597,7 @@ export default {
|
||||
<b-button @click="updataName" style="position:absolute;left: 20px ">导入已有文件</b-button>
|
||||
<b-button @click="Start_Comput_Coeff()" style="position:absolute; left: 150px ">计算</b-button>
|
||||
<b style="position:absolute; left: 250px;border: #0f0f0f 1px solid; margin: auto">adsfsdsadfsdf</b>
|
||||
<b-button @click="updataName" style="position:absolute;right: 20px ">设置</b-button>
|
||||
<b-button @click="updateCalifile" style="position:absolute;right: 20px ">设置</b-button>
|
||||
</p>
|
||||
</template>
|
||||
|
||||
|
@ -20,7 +20,8 @@ const SerilporDefine = {
|
||||
ALLRadiance:0x10,
|
||||
UpAndDownRadiance:0x11,
|
||||
UpRadiance:0x12,
|
||||
DownRadiance:0x13
|
||||
DownRadiance:0x13,
|
||||
Ref:0x14
|
||||
},
|
||||
}
|
||||
export default SerilporDefine;
|
||||
|
@ -22,9 +22,11 @@ export default {
|
||||
ChongCaiyanginterval: 0.2,
|
||||
},
|
||||
caijiavgNumber:100,
|
||||
lastcaijiavgNumber:100,
|
||||
autoremovedark: true,
|
||||
caijidirection: "UP",
|
||||
ShutterTime: [100, 100],
|
||||
lastshuttime: 100,
|
||||
cajitimes: 5,
|
||||
cajitimesjiange:0,
|
||||
methodslist: [],
|
||||
@ -36,15 +38,19 @@ export default {
|
||||
nowNumber: 0,
|
||||
Filename: "Plot",
|
||||
pathofdir: "./data",
|
||||
sensor_typeforset: "IRIS-IS11",
|
||||
Devinfo: {
|
||||
SerilNumber: "",
|
||||
Version: "0000",
|
||||
name: "暂无",
|
||||
Caji_mode: "连续采集",
|
||||
return_mode: "返回模式",
|
||||
Datatype: "DN"
|
||||
Datatype: "DN",
|
||||
sensor_type:"IRIS-IS11"
|
||||
|
||||
},
|
||||
UPStr: "UP",
|
||||
DOWNStr: "DOWN",
|
||||
Datainfoshow: {
|
||||
header: "数据信息",
|
||||
infolist: []
|
||||
@ -62,7 +68,9 @@ export default {
|
||||
header: "DOWN",
|
||||
infolist: []
|
||||
},
|
||||
|
||||
buttoncolor:{
|
||||
opencombutton:"light"
|
||||
},
|
||||
|
||||
devinfoshow: {
|
||||
header: "设备信息",
|
||||
@ -73,6 +81,12 @@ export default {
|
||||
},
|
||||
cssme: {
|
||||
comportvariant: "info",
|
||||
},
|
||||
continuecaiji: false,
|
||||
Dispatcher:{
|
||||
isenable:false,
|
||||
begin:"00:00",
|
||||
end:"23:59",
|
||||
}
|
||||
}
|
||||
},
|
||||
@ -84,11 +98,23 @@ export default {
|
||||
if (typeof(configdata.Filename)!="undefined")
|
||||
this.Filename=configdata.Filename
|
||||
if (typeof(configdata.caijiavgNumber)!="undefined")
|
||||
this.caijiavgNumber=configdata.caijiavgNumber
|
||||
{
|
||||
this.caijiavgNumber=configdata.caijiavgNumber
|
||||
this.lastcaijiavgNumber=configdata.caijiavgNumber
|
||||
}
|
||||
|
||||
if (typeof(configdata.useSG)!="undefined")
|
||||
this.dataprocessconfig.useSG=configdata.useSG
|
||||
if (typeof(configdata.usehighpass)!="undefined")
|
||||
this.dataprocessconfig.usehighpass=configdata.usehighpass
|
||||
if (typeof(configdata.Dispatcher.isenable)!="undefined")
|
||||
this.Dispatcher.isenable=configdata.Dispatcher.isenable
|
||||
if (typeof(configdata.Dispatcher.begin)!="undefined")
|
||||
this.Dispatcher.begin=configdata.Dispatcher.begin
|
||||
if (typeof(configdata.Dispatcher.end)!="undefined")
|
||||
this.Dispatcher.end=configdata.Dispatcher.end
|
||||
|
||||
|
||||
var ports = this.listSerialPorts();
|
||||
// let btn=document.getElementById("closecomeside");
|
||||
// btn.disabled=true;
|
||||
@ -99,11 +125,16 @@ export default {
|
||||
window.addEventListener("keydown", this.handlekeydown)
|
||||
EventBus.on("updatamaindevinfo", this.GetSenSorInfo);
|
||||
EventBus.on("konamiactive",this.setspectralmode);
|
||||
EventBus.on("Get_Dev_Info",this.get_dev_info)
|
||||
EventBus.on("Get_Dev_Info",this.get_dev_info);
|
||||
EventBus.on("LetSiderDo",this.letmedosomething);
|
||||
},
|
||||
methods: {
|
||||
...Siderleftmethode,
|
||||
...siderleftSerilportMethod
|
||||
...siderleftSerilportMethod,
|
||||
addOption() {
|
||||
this.options.push({label: this.inputValue, value: this.inputValue}),
|
||||
this.inputValue = ''
|
||||
}
|
||||
},
|
||||
setup(props, context) {
|
||||
const optionName = ref('')
|
||||
@ -137,6 +168,14 @@ export default {
|
||||
|
||||
<BAccordion class="bAccordionme" size="sm" >
|
||||
<BAccordionItem title="高级设置" v-show="isSpecialmodeshow">
|
||||
<!-- 设备切换 a-select -->
|
||||
<b-input-group prepend="设备切换" size="sm" style="width: 100%">
|
||||
<b-form-select v-model="sensor_typeforset" style="padding-right: 8px" :update="onDevchange()">
|
||||
<b-form-select-option value="IRIS-IS11">高光谱传感器</b-form-select-option>
|
||||
<b-form-select-option value="JZ-IS11">IS11</b-form-select-option>
|
||||
</b-form-select>
|
||||
</b-input-group>
|
||||
|
||||
<!-- <b-input-group prepend="平均次数" size="sm" style="width: 100%">-->
|
||||
<!-- <b-form-input type="number" v-model="caijiavgNumber"></b-form-input>-->
|
||||
<!-- <b-input-group-append>-->
|
||||
@ -148,7 +187,7 @@ export default {
|
||||
<!-- <div style="margin: auto; margin-left: 10px;"> HighPass<input type="checkbox" v-model="dataprocessconfig.usehighpass" ></div>-->
|
||||
<!-- </b-input-group>-->
|
||||
<b-input-group prepend="平均次数" size="sm" style="width: 100%">
|
||||
<b-form-input type="number" v-model="caijiavgNumber"></b-form-input>
|
||||
<b-form-input type="number" v-model="caijiavgNumber" :change="onshuttimechange(ShutterTime[0])"></b-form-input>
|
||||
<b-input-group-append>
|
||||
|
||||
</b-input-group-append>
|
||||
@ -159,6 +198,20 @@ export default {
|
||||
<!-- <div style="margin: auto; margin-left: 10px;"><input type="checkbox" v-model="dataprocessconfig.useSG" ></div>
|
||||
<div style="margin: auto; margin-left: 10px;"><input type="checkbox" v-model="dataprocessconfig.usehighpass" ></div> -->
|
||||
</b-input-group>
|
||||
<b-input-group prepend="开始时间" size="sm">
|
||||
<b-form-input type="time" v-model="Dispatcher.begin" :disabled="!Dispatcher.isenable"></b-form-input>
|
||||
<b-input-group-append>
|
||||
<div style="margin: auto; margin-left: 10px;"><input type="checkbox" v-model="Dispatcher.isenable" ></div>
|
||||
</b-input-group-append>
|
||||
|
||||
</b-input-group>
|
||||
<b-input-group prepend="结束时间" size="sm">
|
||||
<b-form-input type="time" v-model="Dispatcher.end" :disabled="!Dispatcher.isenable"></b-form-input>
|
||||
|
||||
</b-input-group>
|
||||
|
||||
|
||||
|
||||
<b-button @click="saveconfig" variant="light" size="sm">保存</b-button>
|
||||
</BAccordionItem>
|
||||
<BAccordionItem title="控制" visible >
|
||||
@ -171,11 +224,12 @@ export default {
|
||||
</b-button>
|
||||
</b-input-group-prepend>
|
||||
<b-form-input v-model="ShutterTime[0]" type="text" :disabled="iscollecting || !SerialInfo.isopen"
|
||||
v-show="caijidirection!='DOWN'"></b-form-input>
|
||||
v-show="caijidirection!='DOWN'" :change="onshuttimechange(ShutterTime[0])"></b-form-input>
|
||||
<b-form-input v-model="ShutterTime[1]" type="text" :disabled="iscollecting || !SerialInfo.isopen"
|
||||
v-show="caijidirection=='DOWN'||caijidirection=='ALL'"></b-form-input>
|
||||
v-show="caijidirection=='DOWN'||caijidirection=='ALL'" ></b-form-input>
|
||||
|
||||
</b-input-group>
|
||||
|
||||
<b-input-group style="margin-bottom: 2px;width: 100%;margin-left: auto;margin-right: auto" size="sm">
|
||||
|
||||
|
||||
@ -194,10 +248,13 @@ export default {
|
||||
<b-form-select v-model="caijidirection" v-if="Devinfo.work_mode=='advanced_mode'"
|
||||
:disabled="iscollecting || !SerialInfo.isopen"
|
||||
style="padding-right: 8px">
|
||||
<b-form-select-option value="UP">UP </b-form-select-option>
|
||||
<b-form-select-option value="DOWN">DOWN</b-form-select-option>
|
||||
<b-form-select-option value="DARK">DARK</b-form-select-option>
|
||||
<b-form-select-option value="ALL">ALL</b-form-select-option>
|
||||
<b-form-select-option value="UP">{{ UPStr }} </b-form-select-option>
|
||||
<b-form-select-option value="DOWN" v-if="Devinfo.sensor_type=='IRIS-IS11'" >{{ DOWNStr }}</b-form-select-option>
|
||||
<b-form-select-option value="DARK" v-if="Devinfo.sensor_type=='IRIS-IS11'">DARK</b-form-select-option>
|
||||
<b-form-select-option value="ALL" v-if="Devinfo.sensor_type=='IRIS-IS11'">ALL</b-form-select-option>
|
||||
<b-form-select-option value="RAD_UP" v-if="Devinfo.sensor_type=='IRIS-IS11'">RAD_UP</b-form-select-option>
|
||||
<b-form-select-option value="RAD_DOWN" v-if="Devinfo.sensor_type=='IRIS-IS11'">RAD_DOWN</b-form-select-option>
|
||||
<b-form-select-option value="REF" v-if="Devinfo.sensor_type=='IRIS-IS11'">REF</b-form-select-option>
|
||||
|
||||
</b-form-select>
|
||||
<b-input-group-prepend is-text style="padding: 0px;padding-right: 6px;padding-left: 10px" v-if="Devinfo.work_mode=='advanced_mode'" >
|
||||
@ -211,42 +268,79 @@ export default {
|
||||
<b-input-group-prepend>
|
||||
<b-button @click="ContinueCelect(cajitimes)" :disabled="iscollecting || !SerialInfo.isopen"
|
||||
style="min-width:80px">
|
||||
保存数据
|
||||
采集数据
|
||||
<!-- 连续采集-->
|
||||
</b-button>
|
||||
</b-input-group-prepend>
|
||||
|
||||
<b-form-input v-model="cajitimes" type="number" :disabled="iscollecting || !SerialInfo.isopen"></b-form-input>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</b-input-group>
|
||||
<b-input-group append="秒" size="sm">
|
||||
|
||||
<b-input-group style="margin-bottom: 2px;width: 100%;margin-left: auto;margin-right: auto;align-items: center;" size="sm" >
|
||||
|
||||
<b-button @click="ContinueCelect(-1)" :disabled="iscollecting || !SerialInfo.isopen"
|
||||
style="min-width:80%;margin: auto;" v-show="!continuecaiji">
|
||||
连续保存
|
||||
<!-- 连续采集-->
|
||||
</b-button>
|
||||
<b-button @click="ContinueCelect(-1)" :disabled=" !SerialInfo.isopen"
|
||||
style="min-width:80%;margin: auto;" v-show="continuecaiji">
|
||||
停止保存
|
||||
<!-- 连续采集-->
|
||||
</b-button>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
</b-input-group>
|
||||
|
||||
|
||||
<b-input-group append="秒" size="sm" style="margin-bottom: 5px">
|
||||
<b-input-group-prepend style="margin-bottom: 2px;width: 100%;margin-left: auto;margin-right: auto">
|
||||
<b-input-group-text style="min-width:80px">保存间隔</b-input-group-text>
|
||||
</b-input-group-prepend>
|
||||
<b-form-input type="number" v-model="cajitimesjiange" :disabled="iscollecting || !SerialInfo.isopen"></b-form-input>
|
||||
</b-input-group>
|
||||
|
||||
</BAccordionItem>
|
||||
<BAccordionItem title="保存配置" >
|
||||
<!-- </BAccordionItem>
|
||||
<BAccordionItem title="保存配置" > -->
|
||||
<div>
|
||||
<!-- <b-button @click="closemain" id="closecome" variant="light" >退出</b-button>-->
|
||||
<b-input-group prepend="保存名称" size="sm" style="width: 100%">
|
||||
<b-form-input type="text" v-model="Filename"></b-form-input>
|
||||
<b-input-group size="sm" style="margin-bottom: 5px">
|
||||
<b-input-group-text style="min-width:80px">重 采 样</b-input-group-text>
|
||||
<b-form-input type="number" max="10" min="0.05" step="0.05" v-model="outputconfig.ChongCaiyanginterval"></b-form-input>
|
||||
<b-input-group-append>
|
||||
<input type="checkbox" style="margin: 10px" v-model="outputconfig.isChongCaiyang"/>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
<b-input-group prepend="保存路径" size="sm">
|
||||
<!-- <b-button @click="closemain" id="closecome" variant="light" >退出</b-button>-->
|
||||
<b-input-group size="sm" style="width: 100% ;margin-bottom: 5px" >
|
||||
<b-input-group-text style="min-width:80px">保存名称</b-input-group-text>
|
||||
<b-form-input type="text" v-model="Filename" :update="filenamechange()"></b-form-input>
|
||||
<div></div>
|
||||
<b-input-group-append>
|
||||
<div style="width: 30px;margin-top: 5px;">
|
||||
{{ nowNumber }}
|
||||
</div>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
|
||||
|
||||
<b-input-group size="sm">
|
||||
<b-input-group-text style="min-width:80px">保存路径</b-input-group-text>
|
||||
<b-form-input type="text" v-model="Pathtosave"></b-form-input>
|
||||
<b-input-group-append>
|
||||
<b-button @click="choosesavepath">...</b-button>
|
||||
</b-input-group-append>
|
||||
</b-input-group>
|
||||
<b-input-group prepend="重 采 样 " size="sm">
|
||||
<b-form-input type="number" max="10" min="0.05" step="0.05" v-model="outputconfig.ChongCaiyanginterval"></b-form-input>
|
||||
<b-input-group-append>
|
||||
<input type="checkbox" style="margin: 10px" v-model="outputconfig.isChongCaiyang"/>
|
||||
</b-input-group-append>
|
||||
|
||||
|
||||
</b-input-group>
|
||||
|
||||
|
||||
|
||||
</div>
|
||||
@ -267,14 +361,18 @@ export default {
|
||||
|
||||
<BDropdown dropup :text="Comname" :variant="cssme.comportvariant" class="me-2" size="sm"
|
||||
style="max-width: 30%; --bs-dropdown-min-width: 30%;font-size: xx-small" id="selectitem">
|
||||
<BFormInput v-model="inputValue" @keydown.enter.prevent="addOption" @click.stop size="sm"
|
||||
placeholder="手动输入" style="font-size: xx-small; margin-bottom: 5px;" />
|
||||
|
||||
|
||||
<BDropdownItem v-for="item in options" @click="Comname=item.value" style=" --bs-dropdown-min-width: 10px;"
|
||||
variant="success" size="sm">
|
||||
{{ item.label }}
|
||||
{{ item.label }}
|
||||
</BDropdownItem>
|
||||
</BDropdown>
|
||||
|
||||
|
||||
<BButton @click="initserialport" id="opencom" variant="light" size="sm"
|
||||
<BButton @click="initserialport" id="opencom" :variant="buttoncolor.opencombutton" size="sm"
|
||||
style="font-size: xx-small;max-width: 30%;">打开串口
|
||||
</BButton>
|
||||
|
||||
|
@ -4,6 +4,7 @@ import * as echarts from "echarts";
|
||||
import {exit} from "@tauri-apps/api/process";
|
||||
import EventBus from "../eventBus.js";
|
||||
import eventBus from "../eventBus.js";
|
||||
import { en } from "element-plus/es/locales.mjs";
|
||||
|
||||
export default {
|
||||
|
||||
@ -15,11 +16,15 @@ export default {
|
||||
configdata.caijiavgNumber=this.caijiavgNumber;
|
||||
configdata.useSG=this.dataprocessconfig.useSG;
|
||||
configdata.usehighpass=this.dataprocessconfig.usehighpass;
|
||||
configdata.Dispatcher=this.Dispatcher;
|
||||
fs.writeFile("config.json", JSON.stringify(configdata));
|
||||
EventBus.emit('showbox', {title: "系统", body: "保存配置成功",interval:10});
|
||||
this.isSpecialmodeshow=false;
|
||||
this.isSpecialmodeshow=true;
|
||||
},
|
||||
async filenamechange(){
|
||||
var maxn=await this.findmaxNinpath(this.pathofdir);
|
||||
this.Pathtosave=this.pathofdir+"/"+this.Filename+this.nowNumber+".csv";
|
||||
},
|
||||
|
||||
async choosesavepath(){
|
||||
// var path = require('path');
|
||||
// var dialog = require('@electron/remote').dialog;
|
||||
@ -56,6 +61,87 @@ export default {
|
||||
URL.revokeObjectURL(blob);
|
||||
},
|
||||
async ContinueCelect(times){
|
||||
if(times==-1) {
|
||||
this.continuecaiji=!this.continuecaiji;
|
||||
if (this.continuecaiji==false)
|
||||
{
|
||||
EventBus.emit('showbox', {title: "系统", body: "采集将在当前数据采集完成后停止",interval:10});
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (this.continuecaiji) {
|
||||
while (this.continuecaiji) {
|
||||
|
||||
//获取当前时间
|
||||
let isuseDispatcher=this.Dispatcher.isenable;
|
||||
if (isuseDispatcher)
|
||||
{
|
||||
|
||||
let datenow=new Date();
|
||||
let hour=datenow.getHours();
|
||||
let datanownumber=hour*60+datenow.getMinutes();
|
||||
let begintimestr=this.Dispatcher.begin;
|
||||
let endtimestr=this.Dispatcher.end;
|
||||
let begintime=Number(begintimestr.split(":")[0])*60+Number(begintimestr.split(":")[1]);
|
||||
let endtime=Number(endtimestr.split(":")[0])*60+Number(endtimestr.split(":")[1]);
|
||||
|
||||
if (datanownumber>endtime||datanownumber<begintime)
|
||||
{
|
||||
|
||||
|
||||
await delay(1000);
|
||||
let dataforprocess={
|
||||
percent:100,
|
||||
info:"不在采集时间段内"
|
||||
}
|
||||
EventBus.emit('setprogressbar',dataforprocess);
|
||||
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
await this.GetoneData("",Number(this.caijiavgNumber));
|
||||
var aa={code:"Space"}
|
||||
await this.handlekeydown(aa);
|
||||
await delay(50);
|
||||
// if (this.cajitimesjiange>0)
|
||||
// await delay(this.cajitimesjiange*1000-50);
|
||||
//等待期间每一秒检查一次是否停止
|
||||
let temp=0;
|
||||
this.iscollecting=true;
|
||||
while(temp<this.cajitimesjiange&&this.continuecaiji)
|
||||
{
|
||||
await delay(1000);
|
||||
let dataforprocess={
|
||||
percent:temp/this.cajitimesjiange*100,
|
||||
info:"等待下次采集"
|
||||
}
|
||||
EventBus.emit('setprogressbar',dataforprocess);
|
||||
temp++;
|
||||
}
|
||||
this.iscollecting=false;
|
||||
|
||||
}
|
||||
|
||||
let dataforprocess={
|
||||
percent:100,
|
||||
info:""
|
||||
}
|
||||
EventBus.emit('setprogressbar',dataforprocess);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
for (var i=0;i<times;i++)
|
||||
{
|
||||
|
||||
@ -66,8 +152,19 @@ export default {
|
||||
}
|
||||
await this.handlekeydown(aa);
|
||||
await delay(50);
|
||||
if (this.cajitimesjiange>0)
|
||||
await delay(this.cajitimesjiange*1000-50);
|
||||
// if (this.cajitimesjiange>0)
|
||||
// await delay(this.cajitimesjiange*1000-50);
|
||||
let temp=0;
|
||||
while(temp<this.cajitimesjiange)
|
||||
{
|
||||
await delay(1000);
|
||||
let dataforprocess={
|
||||
percent:temp/this.cajitimesjiange*100,
|
||||
info:"等待下次采集"
|
||||
}
|
||||
EventBus.emit('setprogressbar',dataforprocess);
|
||||
temp++;
|
||||
}
|
||||
}
|
||||
EventBus.emit('showbox', {title: "系统", body: "采集"+times+"次数据完成",interval:10});
|
||||
|
||||
@ -98,6 +195,11 @@ export default {
|
||||
var strcsv=""
|
||||
var strchogncaiyang="";
|
||||
var xValues = []
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
for (var i=0;i<lenthofdataup;i++)
|
||||
{
|
||||
var weave=coeffweave1*i*i*i+coeffweave2*i*i+coeffweave3*i+coeffweave4;
|
||||
@ -114,9 +216,41 @@ export default {
|
||||
{
|
||||
var dataup=this.dataup;
|
||||
var datadown=this.datadown;
|
||||
var dateup=(this.dataup.year+2000)+"-"+this.dataup.month+"-"+this.dataup.day+" "+this.dataup.hour+":"+this.dataup.minute+":"+this.dataup.second;
|
||||
strcsv+="Date_up,"+dateup+"\r\n";
|
||||
|
||||
|
||||
var date=(this.datadown.year+2000)+"-"+this.datadown.month+"-"+this.datadown.day+" "+this.datadown.hour+":"+this.datadown.minute+":"+this.datadown.second;
|
||||
strcsv+="Date_down,"+date+"\r\n";
|
||||
if(typeof this.dataup.temprature!="undefined")
|
||||
{
|
||||
let temperaturestrup="Temperature_up,"
|
||||
+this.dataup.temprature[0]+","+this.dataup.temprature[1]+","
|
||||
+this.dataup.temprature[2]+","+this.dataup.temprature[3]+","
|
||||
+this.dataup.temprature[4]+","+this.dataup.temprature[5]+","
|
||||
+this.dataup.temprature[6]+","+this.dataup.temprature[7]+"\r\n";
|
||||
strcsv+=temperaturestrup;
|
||||
}
|
||||
if(typeof this.datadown.temprature!="undefined")
|
||||
{
|
||||
let temperaturesdown="Temperature_down,"
|
||||
+this.datadown.temprature[0]+","+this.datadown.temprature[1]+","
|
||||
+this.datadown.temprature[2]+","+this.datadown.temprature[3]+","
|
||||
+this.datadown.temprature[4]+","+this.datadown.temprature[5]+","
|
||||
+this.datadown.temprature[6]+","+this.datadown.temprature[7]+"\r\n";
|
||||
strcsv+=temperaturesdown;
|
||||
let datatype="DataType,"+this.dataup.datatype+"\r\n";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
strcsv+="Weavelenth,upDN,downDN,upshutter,"+dataup.shutter_time
|
||||
+",downshutter,"+datadown.shutter_time+",index"+dataup.index+"\r\n";
|
||||
strchogncaiyang="Weavelenth,upDN,downDN,upshutter,"+dataup.shutter_time+",downshutter,"+datadown.shutter_time+",index"+dataup.index+"\r\n";
|
||||
+",downshutter,"+datadown.shutter_time+",index,"+dataup.index+"\r\n";
|
||||
strchogncaiyang="Weavelenth,upDN,downDN,upshutter,"+dataup.shutter_time+",downshutter,"+datadown.shutter_time+",index,"+dataup.index+"\r\n";
|
||||
var lenthofdataup=dataup.data.length;
|
||||
for (var i=0;i<lenthofdataup;i++)
|
||||
{
|
||||
@ -145,21 +279,41 @@ export default {
|
||||
var datatosave={};
|
||||
if (this.caijidirection=="UP")
|
||||
{
|
||||
datatosave=this.dataup;
|
||||
strcsv+="Weavelenth,upDN,upshutter,"+this.dataup.shutter_time+",index"+this.dataup.index+"\r\n";
|
||||
strchogncaiyang=strcsv;
|
||||
|
||||
datatosave=this.dataup;
|
||||
if (this.Devinfo.sensor_type=="IRIS-IS11")
|
||||
strcsv+="Weavelenth,upDN,upshutter,"+this.dataup.shutter_time+",index,"+this.dataup.index+"\r\n";
|
||||
else
|
||||
strcsv+="Weavelenth,"+this.UPStr+",upshutter,"+this.dataup.shutter_time+",index,"+this.dataup.index+"\r\n";;
|
||||
strchogncaiyang=strcsv;
|
||||
|
||||
}else if (this.caijidirection=="DOWN") {
|
||||
datatosave=this.datadown;
|
||||
strcsv+="Weavelenth,downDN,downshutter,"+this.datadown.shutter_time+",index"+this.datadown.index+"\r\n";
|
||||
strcsv+="Weavelenth,downDN,downshutter,"+this.datadown.shutter_time+",index,"+this.datadown.index+"\r\n";
|
||||
strchogncaiyang=strcsv;
|
||||
|
||||
} else if (this.caijidirection=="DARK") {
|
||||
datatosave=this.dataup;
|
||||
strcsv+="Weavelenth,darkDN,darkshutter,"+this.dataup.shutter_time+",index"+this.dataup.index+"\r\n";
|
||||
strcsv+="Weavelenth,darkDN,darkshutter,"+this.dataup.shutter_time+",index,"+this.dataup.index+"\r\n";
|
||||
strchogncaiyang=strcsv;
|
||||
}
|
||||
let date=(datatosave.year+2000)+"-"+datatosave.month+"-"+datatosave.day+" "+datatosave.hour+":"+datatosave.minute+":"+datatosave.second;
|
||||
let strcsv1="Date,"+date+"\r\n";
|
||||
if (typeof datatosave.temprature!="undefined")
|
||||
{
|
||||
let temperaturestr="Temperature,"
|
||||
+datatosave.temprature[0]+","+datatosave.temprature[1]+","
|
||||
+datatosave.temprature[2]+","+datatosave.temprature[3]+","
|
||||
+datatosave.temprature[4]+","+datatosave.temprature[5]+","
|
||||
+datatosave.temprature[6]+","+datatosave.temprature[7]+"\r\n";
|
||||
strcsv1+=temperaturestr;
|
||||
}
|
||||
strcsv=strcsv1+strcsv;
|
||||
strchogncaiyang=strcsv1+strchogncaiyang;
|
||||
|
||||
|
||||
|
||||
|
||||
var lenthofdataup=datatosave.data.length;
|
||||
for (var i=0;i<lenthofdataup;i++)
|
||||
{
|
||||
@ -194,13 +348,20 @@ export default {
|
||||
|
||||
if(this.Devinfo.work_mode=="advanced_mode")
|
||||
{
|
||||
let filepath="";
|
||||
if (this.outputconfig.isChongCaiyang)
|
||||
{
|
||||
await fs.writeFile(this.pathofdir+"/"+this.Filename+this.nowNumber+"_"+this.caijidirection+"_chongcaiyang.csv", strchogncaiyang)
|
||||
}
|
||||
|
||||
await fs.writeFile(this.pathofdir+"/"+this.Filename+this.nowNumber+"_"+this.caijidirection+".csv", strcsv);
|
||||
eventBus.emit('showbox', {title: "系统", body: "保存数据 "+ this.pathofdir+"/"+this.Filename+this.nowNumber+"_"+this.caijidirection+".csv OK",interval:10});
|
||||
if(this.Devinfo.sensor_type=="IRIS-IS11")
|
||||
{
|
||||
filepath=this.pathofdir+"/"+this.Filename+this.nowNumber+"_"+this.caijidirection+".csv";
|
||||
}else{
|
||||
filepath=this.Pathtosave;
|
||||
}
|
||||
|
||||
await fs.writeFile( filepath, strcsv);
|
||||
eventBus.emit('showbox', {title: "系统", body: "保存数据 "+ filepath+" OK",interval:10});
|
||||
}else
|
||||
{
|
||||
await fs.writeFile(this.Pathtosave, strcsv);
|
||||
@ -256,8 +417,8 @@ export default {
|
||||
|
||||
|
||||
async findmaxNinpath(directoryPath){
|
||||
|
||||
//
|
||||
if(directoryPath=="") return
|
||||
|
||||
//判断文件夹是否存在
|
||||
let isexits=await fs.exists(directoryPath);
|
||||
if (!isexits) {
|
||||
@ -265,6 +426,7 @@ export default {
|
||||
await fs.createDir(directoryPath);
|
||||
|
||||
}
|
||||
let fileName = this.Filename;
|
||||
// 以同步模式读取目录下的所有文件名
|
||||
const files = await fs.readDir(directoryPath);
|
||||
|
||||
@ -272,7 +434,7 @@ export default {
|
||||
const filteredFiles = files.filter(file => {
|
||||
|
||||
// console.log(file)
|
||||
var aa = file.path.startsWith(directoryPath + "\\" + this.Filename);
|
||||
var aa = file.path.startsWith(directoryPath + "\\" + fileName);
|
||||
var bb = file.path.endsWith('.csv');
|
||||
return aa && bb;
|
||||
}
|
||||
@ -281,14 +443,18 @@ export default {
|
||||
);
|
||||
|
||||
|
||||
|
||||
// 提取文件名中的N值
|
||||
const NValues = filteredFiles.map(file => {
|
||||
const match = file.name.match(new RegExp(`^${ this.Filename}(\\d+)\\.csv$`));
|
||||
// const match = file.name.match(new RegExp(`^${ fileName}(\\d+)\\.csv$`));
|
||||
const match = file.name.match(new RegExp(`^${fileName}(\\d+)(_(UP|DOWN))?\\.csv$`));
|
||||
|
||||
return match ? parseInt(match[1]) : null;
|
||||
}).filter(value => value !== null);
|
||||
|
||||
var maxN = Math.max(...NValues);
|
||||
this.nowNumber=maxN+1;
|
||||
|
||||
|
||||
if (NValues.length === 0) {
|
||||
// 如果没有匹配的文件,则返回-1
|
||||
maxN=0;
|
||||
@ -296,6 +462,7 @@ export default {
|
||||
|
||||
}
|
||||
// 找到最大的N值
|
||||
|
||||
this.Pathtosave=this.pathofdir+"\\"+this.Filename+this.nowNumber+".csv";
|
||||
return new Promise((resolve, reject) => {return maxN});
|
||||
},
|
||||
|
Reference in New Issue
Block a user