⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cunchu.sql

📁 使用SQLserver采用贝塞尔函数低通滤波对读入的数据进行谐波分析
💻 SQL
📖 第 1 页 / 共 2 页
字号:
					WHERE RowNo = @i_loop_m and k = @k;
				--得到电压直流分量 VDqk[m]=Yv[m][1]
				UPDATE @VDqk SET valu =	(SELECT col2 from Yv where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
				--得到电流直流分量 IDqk[m]=Yi[m][1]
				UPDATE @IDqk SET valu =	(SELECT col2 from Yi where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
			END


			IF @SampleNumber = 3
			BEGIN
				--Uv[m][2] = vDq[m]
				UPDATE Uv SET col3 = @vDq WHERE RowNo = @i_loop_m and k = @k;	--col3对应Uv的第2列,i_loop_m对应第m行
				--Ui[m][2] = iDq[m]
				UPDATE Ui SET col3 = @iDq WHERE RowNo = @i_loop_m and k = @k;
				--Yv[m][2] = a20*Uv[m][2]+a21*Uv[m][1]+a22*Uv[m][0]-b21*Yv[m][1]-b22*Yv[m][0]
				UPDATE Yv SET col3 = @a20*@vDq + @a21*(select col2 from Uv where RowNo = @i_loop_m and k = @k)
					+ @a22*(select col1 from Uv where RowNo = @i_loop_m and k = @k) - @b21*(select col2 from Yv where RowNo = @i_loop_m and k = @k)
					- @b22*(select col1 from Yv where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--Yi[m][2] = a20*Ui[m][2]+a21*Ui[m][1]+a22*Ui[m][0]-b21*Yi[m][1]-b22*Yi[m][0]
				UPDATE Yi SET col3 = @a20*@iDq + @a21*(select col2 from Ui where RowNo = @i_loop_m and k = @k)
					+ @a22*(select col1 from Ui where RowNo = @i_loop_m and k = @k) - @b21*(select col2 from Yi where RowNo = @i_loop_m and k = @k)
					- @b22*(select col1 from Yi where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--VDqk[m]=Yv[m][2]	得到电压直流分量
				UPDATE @VDqk SET valu =	(SELECT col3 from Yv where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
				--IDqk[m]=Yi[m][2]	得到电流直流分量
				UPDATE @IDqk SET valu =	(SELECT col3 from Yi where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
			END

			IF @SampleNumber = 4
			BEGIN
				--Uv[m][3] = vDq[m]
				UPDATE Uv SET col4 = @vDq WHERE RowNo = @i_loop_m and k = @k;	--col4对应Uv的第3列,i_loop_m对应第m行
				--Ui[m][3] = iDq[m]
				UPDATE Ui SET col4 = @iDq WHERE RowNo = @i_loop_m and k = @k;
				--Yv[m][3] = a30*Uv[m][3]+a31*Uv[m][2]+a32*Uv[m][1]+a33*Uv[m][0]-b31*Yv[m][2]-b32*Yv[m][1]-b33*Yv[m][0]
				UPDATE Yv SET col4 = @a30*@vDq + @a31*(select col3 from Uv where RowNo = @i_loop_m and k = @k)
					+ @a32*(select col2 from Uv where RowNo = @i_loop_m and k = @k) + @a33*(select col1 from Uv where RowNo = @i_loop_m and k = @k)
					- @b31*(select col3 from Yv where RowNo = @i_loop_m and k = @k) - @b32*(select col2 from Yv where RowNo = @i_loop_m and k = @k)
					- @b33*(select col1 from Yv where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--Yi[m][3] = a30*Ui[m][3]+a31*Ui[m][2]+a32*Ui[m][1]+a33*Ui[m][0]-b31*Yi[m][2]-b32*Yi[m][1]-b33*Yi[m][0]
				UPDATE Yi SET col4 = @a20*@iDq + @a21*(select col2 from Ui where RowNo = @i_loop_m and k = @k)
					+ @a22*(select col1 from Ui where RowNo = @i_loop_m and k = @k) - @b21*(select col2 from Yi where RowNo = @i_loop_m and k = @k)
					- @b22*(select col1 from Yi where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--VDqk[m]=Yv[m][3]	得到电压直流分量
				UPDATE @VDqk SET valu =	(SELECT col4 from Yv where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
				--IDqk[m]=Yi[m][3]	得到电流直流分量
				UPDATE @IDqk SET valu =	(SELECT col4 from Yi where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
			END

			IF @SampleNumber = 5
			BEGIN
				--Uv[m][4] = vDq[m]
				UPDATE Uv SET col5 = @vDq WHERE RowNo = @i_loop_m and k = @k;	--col5对应Uv的第4列,i_loop_m对应第m行
				--Ui[m][4] = iDq[m]
				UPDATE Ui SET col5 = @iDq WHERE RowNo = @i_loop_m and k = @k;
				--Yv[m][4] = a40*Uv[m][4]+a41*Uv[m][3]+a42*Uv[m][2]+a43*Uv[m][1]+a44*Uv[m][0]-b41*Yv[m][3]-b42*Yv[m][2]-b43*Yv[m][1]-b44*Yv[m][0]
				UPDATE Yv SET col5 = @a40*@vDq + @a41*(select col4 from Uv where RowNo = @i_loop_m and k = @k)
					+ @a42*(select col3 from Uv where RowNo = @i_loop_m and k = @k) + @a43*(select col2 from Uv where RowNo = @i_loop_m and k = @k)
					+ @a44*(select col1 from Uv where RowNo = @i_loop_m and k = @k) - @b41*(select col4 from Yv where RowNo = @i_loop_m and k = @k)
					- @b42*(select col3 from Yv where RowNo = @i_loop_m and k = @k) - @b43*(select col2 from Yv where RowNo = @i_loop_m and k = @k)
					- @b44*(select col1 from Yv where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--Yi[m][4] = a40*Ui[m][4]+a41*Ui[m][3]+a42*Ui[m][2]+a43*Ui[m][1]+a44*Ui[m][0]-b41*Yi[m][3]-b42*Yi[m][2]-b43*Yi[m][1]-b44*Yi[m][0]
				UPDATE Yi SET col5 = @a40*@iDq + @a41*(select col4 from Ui where RowNo = @i_loop_m and k = @k)
					+ @a42*(select col3 from Ui where RowNo = @i_loop_m and k = @k) + @a43*(select col2 from Ui where RowNo = @i_loop_m and k = @k)
					+ @a44*(select col1 from Ui where RowNo = @i_loop_m and k = @k) - @b41*(select col4 from Yi where RowNo = @i_loop_m and k = @k)
					- @b42*(select col3 from Yi where RowNo = @i_loop_m and k = @k) - @b43*(select col2 from Yi where RowNo = @i_loop_m and k = @k)
					- @b44*(select col1 from Yi where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--VDqk[m]=Yv[m][4]	得到电压直流分量
				UPDATE @VDqk SET valu =	(SELECT col5 from Yv where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
				--IDqk[m]=Yi[m][4]	得到电流直流分量
				UPDATE @IDqk SET valu =	(SELECT col5 from Yi where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
			END

			IF @SampleNumber > 5
			BEGIN
				--for(n=0;n<4;n++)
				--{
				--	Uv[m][n]=Uv[m][n+1];
				--	Ui[m][n]=Ui[m][n+1];
				--}
				set @i_loop_n = 0;
				WHILE (@i_loop_n < 4)
				BEGIN
					UPDATE Uv SET col1 = col2,col2 = col3,col3 = col4,col4 = col5 where RowNo = @i_loop_m and k = @k;
					UPDATE Ui SET col1 = col2,col2 = col3,col3 = col4,col4 = col5 where RowNo = @i_loop_m and k = @k;
					set @i_loop_n = @i_loop_n + 1
				END

				--Uv[m][4] = vDq[m];
				UPDATE Uv SET col5 = @vDq WHERE RowNo = @i_loop_m and k = @k;	--col5对应Uv的第4列,i_loop_m对应第m行
				--Ui[m][4] = iDq[m];
				UPDATE Ui SET col5 = @iDq WHERE RowNo = @i_loop_m and k = @k;

				--for(n=0;n<4;n++)		 
				--{
				--	Yv[m][n] = Yv[m][n+1];				 
				--	Yi[m][n] = Yi[m][n+1];				 
				--}
				set @i_loop_n = 0;
				WHILE (@i_loop_n < 4)
				BEGIN
					UPDATE Yv SET col1 = col2,col2 = col3,col3 = col4,col4 = col5 where RowNo = @i_loop_m and k = @k;
					UPDATE Yi SET col1 = col2,col2 = col3,col3 = col4,col4 = col5 where RowNo = @i_loop_m and k = @k;
					set @i_loop_n = @i_loop_n + 1
				END
				
				--Yv[m][4] = a40*Uv[m][4]+a41*Uv[m][3]+a42*Uv[m][2]+a43*Uv[m][1]+a44*Uv[m][0]-b41*Yv[m][3]-b42*Yv[m][2]-b43*Yv[m][1]-b44*Yv[m][0];
				UPDATE Yv SET col5 = @a40*@vDq + @a41*(select col4 from Uv where RowNo = @i_loop_m and k = @k)
					+ @a42*(select col3 from Uv where RowNo = @i_loop_m and k = @k) + @a43*(select col2 from Uv where RowNo = @i_loop_m and k = @k)
					+ @a44*(select col1 from Uv where RowNo = @i_loop_m and k = @k) - @b41*(select col4 from Yv where RowNo = @i_loop_m and k = @k)
					- @b42*(select col3 from Yv where RowNo = @i_loop_m and k = @k) - @b43*(select col2 from Yv where RowNo = @i_loop_m and k = @k)
					- @b44*(select col1 from Yv where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				--Yi[m][4] = a40*Ui[m][4]+a41*Ui[m][3]+a42*Ui[m][2]+a43*Ui[m][1]+a44*Ui[m][0]-b41*Yi[m][3]-b42*Yi[m][2]-b43*Yi[m][1]-b44*Yi[m][0];
				UPDATE Yi SET col5 = @a40*@iDq + @a41*(select col4 from Ui where RowNo = @i_loop_m and k = @k)
					+ @a42*(select col3 from Ui where RowNo = @i_loop_m and k = @k) + @a43*(select col2 from Ui where RowNo = @i_loop_m and k = @k)
					+ @a44*(select col1 from Ui where RowNo = @i_loop_m and k = @k) - @b41*(select col4 from Yi where RowNo = @i_loop_m and k = @k)
					- @b42*(select col3 from Yi where RowNo = @i_loop_m and k = @k) - @b43*(select col2 from Yi where RowNo = @i_loop_m and k = @k)
					- @b44*(select col1 from Yi where RowNo = @i_loop_m and k = @k)
					WHERE RowNo = @i_loop_m and k = @k;
				
				--VDqk[m]=Yv[m][4]	得到电压直流分量
				UPDATE @VDqk SET valu =	(SELECT col5 from Yv where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
				--IDqk[m]=Yi[m][4]	得到电流直流分量
				UPDATE @IDqk SET valu =	(SELECT col5 from Yi where RowNo = @i_loop_m and k = @k) where RowNo = @i_loop_m;
			END

			SET @i_loop_m = @i_loop_m + 1
		END

		--④dq转换到abc
		DECLARE @vAbc float
		DECLARE @iAbc float

		set @vAbc = (select data from @cDqAbc where rowNO = 0 and colNO = 0) * (select valu from @VDqk where rowNO = 0)
		set @vAbc = @vAbc + (select data from @cDqAbc where rowNO = 0 and colNO = 1) * (select valu from @VDqk where rowNO = 1)
		set @iAbc = (select data from @cDqAbc where rowNO = 0 and colNO = 0) * (select valu from @IDqk where rowNO = 0)
		set @iAbc = @iAbc + (select data from @cDqAbc where rowNO = 0 and colNO = 1) * (select valu from @IDqk where rowNO = 1)
		
		--⑤算有效值
		DECLARE @HUamax float
		DECLARE @HIamax float
		SET @HUamax = 0
		SET @HIamax = 0
		
		IF (@dotnumber < 64)
		BEGIN
			SET @HUamax = @HUamax + @vAbc*@vAbc*@offTime;
			SET @HIamax = @HIamax + @iAbc*@iAbc*@offTime;
			
			IF (@k = 1)
			BEGIN
				UPDATE TempData SET HV1 = @HUamax , HI1 = @HIamax
			END
			IF (@k = 2)
			BEGIN
				UPDATE TempData SET HV2 = @HUamax , HI2 = @HIamax
			END
			IF (@k = 3)
			BEGIN
				UPDATE TempData SET HV3 = @HUamax , HI3 = @HIamax
			END
			IF (@k = 4)
			BEGIN
				UPDATE TempData SET HV4 = @HUamax , HI4 = @HIamax
			END
			IF (@k = 5)
			BEGIN
				UPDATE TempData SET HV5 = @HUamax , HI5 = @HIamax
			END
			IF (@k = 6)
			BEGIN
				UPDATE TempData SET HV6 = @HUamax , HI6 = @HIamax
			END
			IF (@k = 7)
			BEGIN
				UPDATE TempData SET HV7 = @HUamax , HI7 = @HIamax
			END

		END

		delete from @cAbcDq;
		delete from @cDqAbc;
		set @k = @k + 1
	END

	UPDATE TempData SET dotnumber = dotnumber + 1 ;

END	--IF (@dotnumber = 64) else 的


GO

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -