Commit fc2463c3 authored by mikf's avatar mikf

added ci

parent e16d1b5d
Pipeline #7808 failed with stage
in 34 seconds
build_and_test-win32:
stage:
build
script:
- c:/Anaconda3/envs/pyHawc2/python.exe ci.py win32
artifacts:
paths:
- src/Win32/Release/generator_servo.dll
tags:
- CPAV_old_PC
except:
- tags
build_and_test-x64:
stage:
build
script:
- c:/Anaconda3/envs/pyHawc2/python.exe ci.py x64
artifacts:
paths:
- src/x64/Release/generator_servo_64.dll
tags:
- CPAV_old_PC
except:
- tags
build_test_deploy-win32:
stage:
build
script:
- c:/Anaconda3/envs/pyHawc2/python.exe ci.py win32 push
tags:
- CPAV_old_PC
only:
- tags
build_test_deploy-x64:
stage:
build
script:
- c:/Anaconda3/envs/pyHawc2/python.exe ci.py x64 push
tags:
- CPAV_old_PC
only:
- tags
\ No newline at end of file
import pytest
import sys
import os
import subprocess
"""
python ci.py <platform> [<configuration>] [push]
"""
if __name__ == '__main__':
module = 'generator_servo'
sln = 'src/generator_servo.sln'
dll_lst = ['src/%s/%s/generator_servo%s.dll']
binary_folder = 'control-%s'
def run(cmd):
print(cmd)
if os.system(cmd):
raise Exception("'%s' failed" % cmd)
def run_git_cmd(cmd):
git_repo_path = os.getcwd()
if not os.path.isdir(os.path.join(git_repo_path, ".git")):
raise Warning("'%s' does not appear to be a Git repository." % git_repo_path)
try:
process = subprocess.Popen(cmd,
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
universal_newlines=True,
cwd=os.path.abspath(git_repo_path))
stdout, stderr = process.communicate()
if process.returncode != 0:
raise EnvironmentError("%s\n%s" % (stdout, stderr))
return stdout.strip()
except EnvironmentError as e:
raise e
raise Warning("unable to run git")
platform = sys.argv[1]
if len(sys.argv) == 3 and sys.argv[2].lower() != 'push':
conf = sys.argv[2]
else:
conf = 'Release'
push = sys.argv[-1] == 'push'
ext = ['', '_64'][platform.lower() == 'x64']
binary_folder = binary_folder%platform
print("Run ci")
print("- Platform: %s" % platform)
print("- Solution file: %s" % (sln))
for dll in dll_lst:
print("- dll: " + dll % (platform, conf, ext))
print("-" * 20)
run('devenv %s /rebuild "%s|%s"' % (sln, conf, platform))
#res = pytest.main(['.'])
#if res:
# sys.exit(res)
run("git clone -b master --depth 1 git@gitlab.windenergy.dtu.dk:OpenLAC/control-binary/%s.git" % binary_folder)
tag = "%-12s"%run_git_cmd("git describe --tags")
message = run_git_cmd("git tag -n99 %s"%tag).replace(tag, "").strip()
date = run_git_cmd('git log -1 --format=%%ai --tags %s'%tag)[:10].strip()
name = run_git_cmd('git log -1 --format="%%an" --tags %s'%tag).strip()
with open('%s/changelog.txt'%binary_folder,'a') as fid:
info = " ".join([tag, date, name, module])
message = ("\n"+" "*60).join([l.strip() for l in message.split("\n")])
fid.write("%-60s%s\n"%(info[:58], message))
for dll in dll_lst:
run("%s %s/update_module.py %s" % (sys.executable, binary_folder, dll%(platform, conf, ext)))
if push:
run("%s %s/update_module.py push" % (sys.executable, binary_folder))
......@@ -3,7 +3,6 @@ module generator_servo_mod
contains
!**************************************************************************************************
subroutine init_generator_servo(array1,array2)
use write_version_mod
implicit none
!DEC$ IF .NOT. DEFINED(__LINUX__)
!DEC$ ATTRIBUTES DLLEXPORT, C, ALIAS:'init_generator_servo'::init_generator_servo
......@@ -21,8 +20,6 @@ module generator_servo_mod
!
! Output array2 contains nothing
!
call write_textversion
write(6, *) 'Gen. torque Servo ' //trim(adjustl(TextVersion))// ' loaded...'
! Save parameters
lowpass2ordergen%f0 = array1(1)*2.0_mk*pi
lowpass2ordergen%zeta = array1(2)
......@@ -193,3 +190,14 @@ module generator_servo_mod
end subroutine update_generator_servo
!**************************************************************************************************
end module generator_servo_mod
subroutine version(s)
use buildinfo
implicit none
!DEC$ ATTRIBUTES DLLEXPORT, ALIAS:'version' :: version
!DEC$ ATTRIBUTES STDCALL :: version
!DEC$ ATTRIBUTES REFERENCE:: s
character*255 :: s
type (tbuildinfo) :: binfo
call buildInfo_initialise(binfo)
s = binfo%git_tag
end subroutine
\ No newline at end of file

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28307.539
MinimumVisualStudioVersion = 10.0.40219.1
Project("{6989167D-11E4-40FE-8C1A-2192A86A7E90}") = "generator_servo", "generator_servo.vfproj", "{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Debug|x64.ActiveCfg = Debug|x64
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Debug|x64.Build.0 = Debug|x64
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Debug|x86.ActiveCfg = Debug|Win32
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Debug|x86.Build.0 = Debug|Win32
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Release|x64.ActiveCfg = Release|x64
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Release|x64.Build.0 = Release|x64
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Release|x86.ActiveCfg = Release|Win32
{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {3A5C9696-7FA7-47C3-8BD7-08B75F8D035B}
EndGlobalSection
EndGlobal
<?xml version="1.0" encoding="UTF-8"?>
<VisualStudioProject ProjectType="typeDynamicLibrary" ProjectCreator="Intel Fortran" Keyword="Dll" Version="11.0" ProjectIdGuid="{C3DAC6E4-340E-4105-9CC3-D1560C1EDDD8}">
<Platforms>
<Platform Name="Win32"/></Platforms>
<Platform Name="Win32"/>
<Platform Name="x64"/></Platforms>
<Configurations>
<Configuration Name="Debug|Win32" OutputDirectory="..\$(ConfigurationName)" ConfigurationType="typeDynamicLibrary">
<Configuration Name="Debug|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" ConfigurationType="typeDynamicLibrary">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" WarnInterfaces="true" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" GenerateDebugInformation="true" SubSystem="subSystemWindows" LinkDLL="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFPreBuildEventTool" CommandLine="version.bat"/>
<Tool Name="VFPostBuildEventTool" CommandLine="del &quot;$(ProjectDir)$(OutDir)\version.res&quot;"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="Release|Win32" OutputDirectory="..\$(ConfigurationName)" DeleteExtensionsOnClean="*.cod;*__genmod.*;*.obj;*.mod;*.pdb;*.asm;*.lst;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;*.lib;$(TargetPath);*.htm;$(IntDir)" ConfigurationType="typeDynamicLibrary">
<Configuration Name="Release|Win32" OutputDirectory="$(PlatformName)\$(ConfigurationName)" IntermediateDirectory="$(PlatformName)\$(ConfigurationName)" DeleteExtensionsOnClean="*.cod;*__genmod.*;*.obj;*.mod;*.pdb;*.asm;*.lst;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;*.lib;$(TargetPath);*.htm;$(IntDir)" ConfigurationType="typeDynamicLibrary">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true" ManifestFile="$(IntDir).intermediate.manifest" SubSystem="subSystemWindows" LinkDLL="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool"/>
<Tool Name="VFPostBuildEventTool"/>
<Tool Name="VFPreBuildEventTool" CommandLine="version.bat"/>
<Tool Name="VFPostBuildEventTool" CommandLine="del &quot;$(ProjectDir)$(OutDir)\version.res&quot;"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true" ResourceFile="$(IntDir).embed.manifest.res"/></Configuration>
<Configuration Name="Debug|x64" TargetName="$(ProjectName)_64" ConfigurationType="typeDynamicLibrary">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true" DebugInformationFormat="debugEnabled" Optimization="optimizeDisabled" WarnInterfaces="true" Traceback="true" BoundsCheck="true" RuntimeLibrary="rtMultiThreadedDebugDLL"/>
<Tool Name="VFLinkerTool" LinkIncremental="linkIncrementalNo" SuppressStartupBanner="true" GenerateDebugInformation="true" SubSystem="subSystemWindows" LinkDLL="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool" CommandLine="version.bat"/>
<Tool Name="VFPostBuildEventTool" CommandLine="del &quot;$(ProjectDir)$(OutDir)\version.res&quot;"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true"/></Configuration>
<Configuration Name="Release|x64" TargetName="$(ProjectName)_64" DeleteExtensionsOnClean="*.cod;*__genmod.*;*.obj;*.mod;*.pdb;*.asm;*.lst;*.map;*.dyn;*.dpi;*.tmp;*.log;*.ilk;*.exe;*.lib;$(TargetPath);*.htm;$(IntDir)" ConfigurationType="typeDynamicLibrary">
<Tool Name="VFFortranCompilerTool" SuppressStartupBanner="true"/>
<Tool Name="VFLinkerTool" SuppressStartupBanner="true" ManifestFile="$(IntDir).intermediate.manifest" SubSystem="subSystemWindows" LinkDLL="true"/>
<Tool Name="VFResourceCompilerTool"/>
<Tool Name="VFMidlTool" SuppressStartupBanner="true" TargetEnvironment="midlTargetAMD64"/>
<Tool Name="VFCustomBuildTool"/>
<Tool Name="VFPreLinkEventTool"/>
<Tool Name="VFPreBuildEventTool" CommandLine="version.bat"/>
<Tool Name="VFPostBuildEventTool" CommandLine="del &quot;$(ProjectDir)$(OutDir)\version.res&quot;"/>
<Tool Name="VFManifestTool" SuppressStartupBanner="true" ResourceFile="$(IntDir).embed.manifest.res"/></Configuration></Configurations>
<Files>
<Filter Name="Header Files" Filter="fi;fd"/>
<Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"/>
<Filter Name="Resource Files" Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe">
<File RelativePath=".\version.rc"/></Filter>
<Filter Name="Source Files" Filter="f90;for;f;fpp;ftn;def;odl;idl">
<File RelativePath=".\BuildInfo.f90"/>
<File RelativePath=".\generator_servo.f90"/>
<File RelativePath=".\generator_servo_fcns.f90"/>
<File RelativePath="..\misc_mod.f90"/>
<File RelativePath="..\write_version.f90"/></Filter></Files>
<File RelativePath=".\misc_mod.f90"/></Filter></Files>
<Globals/></VisualStudioProject>
module misc_mod
!
! Module where filters and the corresponding types are defined.
!
implicit none
! Constants
integer, parameter :: mk = kind(1.0d0)
real(mk) pi, degrad, raddeg
parameter(pi = 3.14159265358979_mk, degrad = 0.01745329251994_mk, raddeg = 57.295779513093144_mk)
! Types
! First order filter
type Tfirstordervar
real(mk) tau, x1, x1_old, y1, y1_old
integer::stepno1=0
end type Tfirstordervar
! Second order low pass filter filter
type Tlowpass2order
real(mk) zeta, f0, x1, x2, x1_old, x2_old, y1, y2, y1_old, y2_old
integer::stepno1=0
end type Tlowpass2order
! Second order notch filter
type Tnotch2order
real(mk) :: zeta1 = 0.1_mk
real(mk) :: zeta2 = 0.001_mk
real(mk) f0, x1, x2, x1_old, x2_old, y1, y2, y1_old, y2_old
integer::stepno1=0
end type Tnotch2order
! Second order band-pass filter
type Tbandpassfilt
real(mk) :: zeta = 0.02_mk
real(mk) :: tau = 0.0_mk
real(mk) f0, x1, x2, x1_old, x2_old, y1, y2, y1_old, y2_old
integer::stepno1=0
end type Tbandpassfilt
! Time delay
type Ttdelay
real(mk) xz(40)
real(mk) xz_old(40)
integer :: stepno1 = 0
end type Ttdelay
contains
!**************************************************************************************************
function lowpass1orderfilt(dt, stepno, filt, x)
! First order low-pass filter.
integer stepno
real(mk) lowpass1orderfilt, dt, x, y, a1, b1, b0, tau
type(Tfirstordervar) filt
! Step
if ((stepno .eq. 1) .and. (stepno .gt. filt%stepno1)) then
filt%x1_old = x
filt%y1_old = x
y=x
else
if (stepno .gt. filt%stepno1) then
filt%x1_old = filt%x1
filt%y1_old = filt%y1
endif
tau = filt%tau
a1 = (2.0_mk*tau - dt) / (2.0_mk*tau + dt)
b0 = dt / (2.0_mk*tau + dt)
b1 = b0
y = a1*filt%y1_old + b0*x + b1*filt%x1_old
endif
! Save previous values
filt%x1 = x
filt%y1 = y
filt%stepno1 = stepno
! Output
lowpass1orderfilt = y
return
end function lowpass1orderfilt
!**************************************************************************************************
function lowpass2orderfilt(dt, stepno, filt, x)
! Second order low-pass filter.
real(mk) lowpass2orderfilt(2), dt, x
integer stepno
type(Tlowpass2order) filt
! local vars
real(mk) y, f0, zeta, a1, a2, b0, b1, b2, denom
! Step
if ((stepno .eq. 1) .and. (stepno .gt. filt%stepno1)) then
filt%x1 = x
filt%x2 = x
filt%x1_old = filt%x1
filt%x2_old = filt%x2
filt%y1 = x
filt%y2 = x
filt%y1_old = filt%y1
filt%y2_old = filt%y2
y=x
else
if (stepno .gt. filt%stepno1) then
filt%x1_old = filt%x1
filt%x2_old = filt%x2
filt%y1_old = filt%y1
filt%y2_old = filt%y2
endif
f0 = filt%f0
zeta = filt%zeta
denom = 3.0_mk + 6.0_mk*zeta*pi*f0*dt + 4.0_mk*pi**2*f0**2*dt**2
a1 = (6.0_mk - 4.0_mk*pi**2*f0**2*dt**2)/denom
a2 = (-3.0_mk + 6.0_mk*zeta*pi*f0*dt - 4.0_mk*pi**2*f0**2*dt**2)/denom
b0 = 4.0_mk*pi**2*f0**2*dt**2/denom
b1 = b0
b2 = b0
y = a1*filt%y1_old + a2*filt%y2_old + b0*x + b1*filt%x1_old + b2*filt%x2_old
endif
! Save previous values
filt%x2 = filt%x1_old
filt%x1 = x
filt%y2 = filt%y1_old
filt%y1 = y
filt%stepno1=stepno
! Output
lowpass2orderfilt(1) = y
lowpass2orderfilt(2) = (y - filt%y2_old)/dt
return
end function lowpass2orderfilt
!**************************************************************************************************
function notch2orderfilt(dt,stepno,filt,x)
! Second order notch filter.
real(mk) notch2orderfilt,dt,x
integer stepno
type(Tnotch2order) filt
! local vars
real(mk) y, f0, zeta1, zeta2, a1, a2, b0, b1, b2, denom
! Step
if ((stepno .eq. 1) .and. (stepno .gt. filt%stepno1)) then
filt%x1 = x
filt%x2 = x
filt%x1_old = filt%x1
filt%x2_old = filt%x2
filt%y1 = x
filt%y2 = x
filt%y1_old = filt%y1
filt%y2_old = filt%y2
y = x
else
if (stepno .gt. filt%stepno1) then
filt%x1_old = filt%x1
filt%x2_old = filt%x2
filt%y1_old = filt%y1
filt%y2_old = filt%y2
endif
f0 = filt%f0
zeta1 = filt%zeta1
zeta2 = filt%zeta2
denom = 3.0_mk + 6.0_mk*zeta1*pi*f0*dt + 4.0_mk*pi**2*f0**2*dt**2
a1 = ( 6.0_mk - 4.0_mk*pi**2*f0**2*dt**2)/denom
a2 = (-3.0_mk + 6.0_mk*zeta1*pi*f0*dt - 4.0_mk*pi**2*f0**2*dt**2)/denom
b0 = ( 3.0_mk + 6.0_mk*zeta2*pi*f0*dt + 4.0_mk*pi**2*f0**2*dt**2)/denom
b1 = (-6.0_mk + 4.0_mk*pi**2*f0**2*dt**2)/denom
b2 = ( 3.0_mk - 6.0_mk*zeta2*pi*f0*dt + 4.0_mk*pi**2*f0**2*dt**2)/denom
y = a1*filt%y1_old + a2*filt%y2_old + b0*x + b1*filt%x1_old + b2*filt%x2_old
endif
! Save previous values
filt%x2 = filt%x1_old
filt%x1 = x
filt%y2 = filt%y1_old
filt%y1 = y
filt%stepno1 = stepno
! Output
notch2orderfilt = y
return
end function notch2orderfilt
!**************************************************************************************************
function bandpassfilt(dt, stepno, filt, x)
! Second order band-pass filter.
real(mk) bandpassfilt, dt, x
integer stepno
type(Tbandpassfilt) filt
! local vars
real(mk) y,f0,zeta,tau,a1,a2,b0,b1,b2,denom
! Step
if ((stepno .eq. 1) .and. (stepno .gt. filt%stepno1)) then
filt%x1 = x
filt%x2 = x
filt%x1_old = filt%x1
filt%x2_old = filt%x2
filt%y1 = x
filt%y2 = x
filt%y1_old = filt%y1
filt%y2_old = filt%y2
y = x
else
if (stepno .gt. filt%stepno1) then
filt%x1_old = filt%x1
filt%x2_old = filt%x2
filt%y1_old = filt%y1
filt%y2_old = filt%y2
endif
f0 = filt%f0
zeta = filt%zeta
tau = filt%tau
denom = 3.0_mk + 6.0_mk*zeta*pi*f0*dt + 4.0_mk*pi**2*f0**2*dt**2
a1 = -(-6.0_mk + 4.0_mk*pi**2*f0**2*dt**2)/denom
a2 = -( 3.0_mk - 6.0_mk*zeta*pi*f0*dt + 4.0_mk*pi**2*f0**2*dt**2)/denom
b0 = -(-6.0_mk*zeta*pi*f0*dt - 12.0_mk*zeta*pi*f0*tau)/denom
b1 = -24.0_mk*zeta*pi*f0*tau/denom
b2 = -( 6.0_mk*zeta*pi*f0*dt - 12.0_mk*zeta*pi*f0*tau)/denom
y = a1*filt%y1_old + a2*filt%y2_old + b0*x + b1*filt%x1_old + b2*filt%x2_old
endif
! Save previous values
filt%x2 = filt%x1_old
filt%x1 = x
filt%y2 = filt%y1_old
filt%y1 = y
filt%stepno1 = stepno
! Output
bandpassfilt = y
return
end function bandpassfilt
!**************************************************************************************************
function timedelay(dt, stepno, filt, Td, x)
! Time delay.
integer stepno, n, k
real(mk) x, timedelay, dt, Td
type(Ttdelay) filt
n = nint(Td/dt)
! Step
if ((stepno .eq. 1)) then
do k = 1, 40
filt%xz(k) = x
end do
endif
if (stepno .gt. filt%stepno1) then
filt%xz_old = filt%xz
endif
do k = 40, 2, -1
filt%xz(k) = filt%xz_old(k - 1)
end do
filt%xz(1) = x
! Output
if (Td .eq. 0.0_mk) then
timedelay = x
else
timedelay = filt%xz(n)
endif
filt%stepno1 = stepno
return
end function timedelay
!**************************************************************************************************
end module misc_mod
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment