Commit d08e0554 authored by Christoffer Ackelman's avatar Christoffer Ackelman

Added missing files from e44b37b0

parent 3f01b939
#!/bin/bash
#
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
#
wb_adm_opendb_func ()
{
#
# Command is "opendb"
#
# Arguments 1: project
# 2: username
# 3: password
# 4: database
# 5: volume
local project=$1
local username=$2
local password=$3
local database=$4
local volume=$5
echo "args: $1 $2 $3 $4 $5"
source pwrp_env.sh set project $project
if [ "$database" != "dbdirectory" ]; then
source pwrp_env.sh setdb $database
fi
wb -q "$username" "$password" $volume &
}
wb_adm_create_func ()
{
local cmd
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "create project"
#
# Arguments 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
pname=$2
bname=$3
proot=$4
source pwrp_env.sh create $@
if [ $pwrc_status -ne 0 ]; then
return $pwrc_status
fi
#source pwrp_env.sh set project $pname
#if [ $pwrc_status -ne 0 ]; then
# return $pwrc_status
#fi
#wb_cmd create volume/name=\"directory\"/ident=254.254.254.253/class=\$DirectoryVolume
fi
}
wb_adm_parse ()
{
local cmd
cmd="opendb"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_adm_opendb_func $1 $2 $3 $4 $5
return
fi
cmd="create"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_adm_create_func $@
return
fi
echo "Unknown command"
}
#set -o xtrace
wb_adm_parse $@
#set +o xtrace
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
# Create the database directory and copy en empty database to the directory.
db=$1
source pwrp_env.sh copy template $db noconfirm
if [ $? != 0 ]; then
return 1;
fi
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
# Keep the old versions of bootfiles
new_file=$1
if [ -e $new_file ]; then
let version=30
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
# wb_gcg.sh -- compile and link PLC code
#
# This compiles a file generated by wb_gcg
# and inserts it in the plc library
# It is called from the wb_gcg.c module.
let gcg__success=0
let gcg__compileerrors=1
let gcg__linkerrors=2
let gcg__archiveerror=3
let gcg__rsherror=4
#
# MyRsh returns the return status from the compile command, not from rsh
# It only works on remote unix systems, not VMS...
#
MyRsh()
{
hostname=
lflag=
nflag=
user=
case $1 in
-l)
;;
*)
hostname=$1
shift
esac
case $1 in
-l)
lflag=-l
user=$2
shift 2
esac
case $1 in
-n)
nflag=-n
shift
esac
case $hostname in
'')
hostname=$1
shift
esac
case $# in
0)
exec /usr/ucb/rlogin $lflag ${user+"$user"} "$hostname"
esac
AWK='
NR > 1 {
print prev;
prev = $0;
prev1 = $1;
prev2 = $2;
}
NR == 1 {
prev = $0;
prev1 = $1;
prev2 = $2;
}
END {
if (prev1 ~ /[0-9]*[0-9]0/)
exit(prev1 / 10);
if (prev1 == "0")
exit(prev2);
print prev;
exit(1);
}
'
exec 3>&1
if rsh "$hostname" $lflag ${user+"$user"} $nflag \
"(${*-:}); sh -c '"'echo "$0 $1" >&2'\'' $?0 "$status"' \
2>&1 >&3 3>&- | awk "$AWK" >&2 3>&-
then
gcg_status=0
else
gcg_status=1
fi
}
CompileProcess()
{
if $cc_cmd -o $pwrp_obj/${FileName}.o $pwrp_gc/${FileName}.gc
then
echo "-- Plc process compiled for $OsStr $say_debug $ObjectName"
gcg_status=$gcg__success
else
echo "** Plc process compiled with errors $OsStr $ObjectName"
gcg_status=$gcg__compileerrors
fi
if [ $Debug -eq 0 ]; then
rm $pwrp_gc/${FileName}.gc
fi
}
CompileProgram()
{
if $cc_cmd -o $pwrp_obj/plc_m${FileName}.o $pwrp_gc/plc_m${FileName}.gc
then
echo "-- Plc plcpgm compiled for $OsStr $say_debug $ObjectName"
gcg_status=$gcg__success
else
echo "** Plc plcpgm compiled with errors $OsStr $ObjectName"
gcg_status=$gcg__compileerrors
fi
if [ $Debug -eq 0 ]; then
rm $pwrp_gc/plc_m${FileName}.gc
fi
}
CompileWindow()
{
if $cc_cmd -Wall -o $pwrp_obj/plc_m${FileName}.o $pwrp_gc/plc_m${FileName}.gc
then
echo "-- Plc window compiled for $OsStr $say_debug $ObjectName"
gcg_status=$gcg__success
else
echo "** Plc window compiled with errors for $OsStr $ObjectName"
gcg_status=$gcg__compileerrors
fi
if [ $Debug -eq 0 ]; then
rm $pwrp_gc/plc_m${FileName}.gc
rm $pwrp_gc/plc_dec${FileName}.gc
rm $pwrp_gc/plc_r1r${FileName}.gc
rm $pwrp_gc/plc_r2r${FileName}.gc
rm $pwrp_gc/plc_ref${FileName}.gc
rm $pwrp_gc/plc_cod${FileName}.gc
fi
}
CompileRtNode()
{
#link option file exists and is not empty
if [ -s $pwrp_exe/$FileName.opt ]; then
echo "-- Using local option-file $FileName.opt"
ld_opt_tmp="`cat $pwrp_exe/$FileName.opt`"
ld_opt="`eval echo $ld_opt_tmp`"
else
ld_opt="`eval echo $pwr_obj/rt_io_user.o -lpwr_rt -lpwr_usbio_dummy -lpwr_usb_dummy -lpwr_pnak_dummy -lpwr_cifx_dummy -lpwr_nodave_dummy -lpwr_epl_dummy`"
fi
if $ldxx $link_debug -L/lib/thread -L$pwrp_lib -L$pwrp_cmn/x86_linux/lib -L$pwr_lib \
-o $pwrp_exe/$OutFile \
$pwr_obj/rt_plc_process.o \
$pwrp_obj/${FileName}.o \
$Libs \
$ld_opt \
$pwr_obj/pwr_msg_rt.o $pwr_obj/pwr_msg_co.o \
-lrt -lpwr_remote -lpwr_nmps -lpwr_rt -lpwr_co -lrpcsvc -lpwr_msg_dummy -lpthread -lm
then
echo "-- Plc program linked for $OsStr $say_linkdebug $OutFile"
gcg_status=$gcg__success
else
echo "** Plc program link errors for $OsStr node $FileName"
gcg_status=$gcg__linkerrors
fi
if [ -n "$pwrp_exe_target" ]; then
cp $pwrp_exe/$OutFile $pwrp_exe_target
echo "-- Plc copied to $pwrp_exe_target"
fi
}
CompileLibrary()
{
echo "-- Building archive for volume: $VolumeId"
cd $pwrp_obj
if ar -rc $pwrp_lib/$PlcLib `ls plc_m${VolumeId}*.o`
then
echo "-- Archive built for volume: $VolumeId"
gcg_status=$gcg__success
else
echo "** Error builing archive for volume: $VolumeId"
gcg_status=$gcg__archiveerror
fi
}
OsMaskToOpSys ()
{
let BitM=$1
let Idx=0
let Val=1
while [ $Val -lt $BitM ]; do
let Val=$Val*2
let Idx=$Idx+1
done
let OpSys=Idx+1
}
#
#
#
# Main
#
#
#
# Arguments
#
let Debug="$1" # 1 if debug, 0 i nodebug
let FileType="$2" # the type of file: rtnode,
# plc or window module
FileName="$3" # the name of the file to be compiled,
VolumeId="$3" # VolumeId for objects to be inserted
let OsMask="$4" # pwr_mOpSys
OutFile="$5" # the name of the generated file
PlcLib="$5" # library for filetype Program and Windoow
Libs="$6" # link libraries
ObjectName="$6" # name of object
SystemName="$7" # name of system
ProjectRoot="$8" # project root
OsMaskToOpSys $OsMask # Convert Bitmask to index
#
# Local symbols
#
let OpSys__Low=0
let OpSys_CustomBuild=1
let OpSys_PPC_LINUX=6
let OpSys_X86_LINUX=7
let OpSys_X86_64_LINUX=8
let OpSys_X86_64_MACOS=9
let OpSys_ARM_LINUX=10
let OpSys_X86_64_FREEBSD=11
let OpSys_X86_64_OPENBSD=12
let OpSys_X86_CYGWIN=13
let OpSys_ARM64_LINUX=14
let OpSys__High=15
vOpSys="custombuild,undefined,undefined,ppc_lynx,x86_lynx,ppc_linux,x86_linux,x86_64_linux,x86_64_macos,arm_linux,x86_64_freebsd,x86_64_openbsd,x86_cygwin,arm64_linux"
let FileType__Low=-1
let FileType_Process=0
let FileType_Program=1
let FileType_Window=2
let FileType_RtNode=3
let FileType_Library=4
let FileType__High=5
vFileType="Process,Program,Window,RtNode,Library"
if [ -z "$pwre_cc" ]; then
cc=gcc
else
cc=$pwre_cc
fi
if [ -z "$pwre_cxx" ]; then
cxx=g++
ldxx=g++
else
cxx=$pwre_cxx
ldxx=$pwre_cxx
fi
if [ -z "$pwre_ar" ]; then
ar=ar
else
ar=$pwre_ar
fi
local_setup="pwr_gcg_setup.sh"
if [ -e ${local_setup} ]; then
# echo "-- Local setup file used"
source ${local_setup} ${ProjectRoot} ${SystemName}
fi
if [ $Debug -eq 1 ]; then
cc_debug="-g"
link_debug="-g"
say_debug="with debug"
say_linkdebug="with debug"
else
cc_debug="-O3"
say_debug="optimized -O3"
say_linkdebug=""
fi
#
# Check OpSys
#
# Current opsys
machine=`eval uname -m`
if [ $machine = "x86_64" ]; then
CurrentOpSys=$OpSys_X86_64_LINUX
else
CurrentOpSys=$OpSys_X86_LINUX
fi
#
# Check FileType
#
if [ $FileType -le $FileType__Low ] || [ $FileType -ge $FileType__High ];
then
echo "Unknown file type: $FileType"
exit -1
fi
OsStr="`echo $vOpSys| cut -f $OpSys -d ,`"
let FileTypeIdx=$FileType+1
if [ $OpSys -eq $OpSys_PPC_LINUX ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
cc_cmd="$cc -c -x c -Wall $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
elif [ $OpSys -eq $OpSys_X86_LINUX ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
if [ $CurrentOpSys -eq $OpSys ]; then
cc_cmd="$cc -c -x c -Wall $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
elif [ $CurrentOpSys -eq $OpSys_X86_64_LINUX ]; then
# echo "-- Trying to build for x86_linux"
export pwr_exe=$pwrb_root/os_linux/hw_x86/exp/exe
export pwr_lib=$pwrb_root/os_linux/hw_x86/exp/lib
export pwr_obj=$pwrb_root/os_linux/hw_x86/exp/obj
export pwrp_exe=$pwrp_root/bld/x86_linux/exe
export pwrp_lib=$pwrp_root/bld/x86_linux/lib
export pwrp_obj=$pwrp_root/bld/x86_linux/obj
cc_cmd="$cc -c -x c -Wall -m32 -fPIC $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
ldxx="g++ -m32 -fPIC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
if [ ! -e $pwr_lib/libpwr_rt.a ]; then
echo "-- Not built for x86_linux"
exit 0;
fi
# Execute build command
Compile$FileTypeStr
exit $gcg_status
fi
elif [ $OpSys -eq $OpSys_X86_64_LINUX ]; then
pwrp_gc="$pwrp_tmp"
# Suppress all warnings, -x
if [ $CurrentOpSys -eq $OpSys ]; then
cc_cmd="$cc -c -x c -Wall $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
# Execute build command
Compile$FileTypeStr
exit $gcg_status
elif [ $CurrentOpSys -eq $OpSys_X86_LINUX ]; then
# echo "-- Trying to build for x86_64_linux"
export pwr_exe=$pwrb_root/os_linux/hw_x86_64/exp/exe
export pwr_lib=$pwrb_root/os_linux/hw_x86_64/exp/lib
export pwr_obj=$pwrb_root/os_linux/hw_x86_64/exp/obj
export pwrp_exe=$pwrp_root/bld/x86_64_linux/exe
export pwrp_lib=$pwrp_root/bld/x86_64_linux/lib
export pwrp_obj=$pwrp_root/bld/x86_64_linux/obj
cc_cmd="$cc -c -x c -Wall -m64 -fPIC $cc_debug -D_REENTRANT -DOS_LINUX -I$pwr_inc -I$pwrp_inc -I$pwrp_tmp $PWR_EXT_INC"
ldxx="g++ -m64 -fPIC"
FileTypeStr="`echo $vFileType| cut -f $FileTypeIdx -d ,`"
if [ ! -e $pwr_lib/libpwr_rt.a ]; then
echo "-- Not built for x86_64_linux"
exit 0;
fi
# Execute build command
Compile$FileTypeStr
exit $gcg_status
fi
elif [ $OpSys -eq $OpSys_CustomBuild ]; then
if [ -e $pwrp_exe/custom_build.sh ]; then
$pwrp_exe/custom_build.sh "$1" "$2" "$3" "$4" "$5" "$6" "$7" "$pwrp_root"
exit $gcg_status
else
echo "Create \$pwrp_exe/custom_build.sh to build this volume"
exit $gcg_status
fi
else
echo "Unknown operating system: $OpSys"
exit -1
fi
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
if [ -z "$pwr_foe_gre_print" ]; then
echo "Printer is not defined in env 'pwr_foe_gre_print'"
fi
echo "Printing $1"
$pwr_foe_gre_print $1
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
# Open a new terminal and start the navigator
# This procedure is started from the navigator 'Open db' method for
# DbConfig and DbTrace objects.
username=$1
password=$2
database=$3
title=$4
#set -o xtrace
if [ -z $database ]; then
echo "Database is missing"
return
fi
if [ "`eval locale -a | grep -i "^en_US.UTF-8$"`" != "" ]; then
export LC_TIME="en_US.UTF-8"
elif [ "`eval locale -a | grep -i "^en_US$"`" != "" ]; then
export LC_TIME="en_US"
fi
export LC_NUMERIC="POSIX"
echo "-- Opening volume '$database'"
wb -q "$username" "$password" $database
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
#set -o xtrace
declare -ix pwrc_status=$pwrc__success
declare -i pwrc__success=0
declare -i pwrc__dbnotfound=1
declare -i pwrc__noproj=3
declare -i pwrc__rootexist=4
declare -i pwrc__notconfigured=5
declare -i pwrc__projlistfile=6
declare -i pwrc__projalrexist=7
declare -i pwrc__basealrexist=8
declare -i pwrc__nobase=9
declare -i pwrc__projlistfileacc=10
declare -i pwrc__syntax=11
declare -i pwrc__rootacc=12
declare -i pwrc__rootcreate=13
declare -i pwrc__rootdelete=14
declare -i pwrc__dbdelete=15
declare -i pwrc__baseexist=16
declare -i pwrc__move=17
declare -i pwrc__notmysqlsrv=18
declare -i pwrc__datadir=19
declare -i pwrc__nodb=20
declare -i pwrc__notemplatedb=21
declare -i pwrc__dbalrexist=22
declare -i pwrc__copy=23
declare -i pwrc__dbcreate=24
declare -i pwrc__projnotset=25
declare -i pwrc__projnameinv=26
declare -i pwrc__mysqldbcopy=27
declare -i pwrc__mysqldbrena=28
declare -i pwrc__mysql=29
declare -i pwrc__noroot=30
wb_pl_opendb_func ()
{
#
# Command is "opendb"
#
# Arguments 1: project
# 2: username
# 3: password
# 4: database
# 5: volume
local project=$1
local username=$2
local password=$3
local database=$4
local volume=$5
echo "args: $1 $2 $3 $4 $5"
source pwrp_env.sh set project $project
#if [ "$database" != "dbdirectory" ]; then
# source pwrp_env.sh setdb $database
#fi
wb -q "$username" "$password" $volume &
}
wb_pl_check_func ()
{
cmd="move"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "check move"
#
# Arguments 2: source root
# 3: destination root
local srcroot=$2
local destroot=$3
local destdir=${destroot%/*}
if [ ! -e "$srcroot" ]; then
echo "Source root not found"
pwrc_status=$pwrc_noroot
fi
if [ -e "$destroot" ]; then
if [ ! -w "$destroot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$destroot/common" ]; then
echo "Error: destination root already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if [ ! -e "$destdir" ]; then
echo "Can't create destination root"
pwrc_status=$pwrc__rootcreate
return
else
if [ ! -w "$destdir" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
fi
fi
pwrc_status=$pwrc__success
return
fi
cmd="create"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "check move"
#
# Arguments 2: destination root
local destroot=$2
local destdir=${destroot%/*}
if [ -e "$destroot" ]; then
if [ ! -w "$destroot" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
else
if [ -e "$destroot/common" ]; then
echo "Error: destination root already exist"
pwrc_status=$pwrc__rootexist
return
fi
fi
else
if [ ! -e "$destdir" ]; then
echo "Can't create destination root"
pwrc_status=$pwrc__rootcreate
return
else
if [ ! -w "$destdir" ]; then
echo "No write access to project root"
pwrc_status=$pwrc__rootacc
return
fi
fi
fi
pwrc_status=$pwrc__success
return
fi
}
wb_pl_create_func ()
{
local cmd
cmd="project"
if [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
#
# Command is "create project"
#
# Arguments 2: project name
# 3: base name
# 4: project root
# 5: project hierarchy
# 6-: description
pname=$2
bname=$3
proot=$4
source pwrp_env.sh create $@
if [ $pwrc_status -ne 0 ]; then
return $pwrc_status
fi
#source pwrp_env.sh set project $pname
#if [ $pwrc_status -ne 0 ]; then
# return $pwrc_status
#fi
#wb_cmd create volume/name=\"directory\"/ident=254.254.254.253/class=\$DirectoryVolume
fi
}
wb_pl_parse ()
{
local cmd
cmd="opendb"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_opendb_func $1 $2 $3 $4 $5
return
fi
cmd="create"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_create_func $@
return
fi
cmd="check"
if [ -z $1 ] || [ $1 = $cmd ] || [ ${cmd#$1} != $cmd ]; then
shift
wb_pl_check_func $@
return $pwrc_status
fi
echo "Unknown command"
}
#set -o xtrace
wb_pl_parse $@
#set +o xtrace
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
declare -i pwrc__success=0
declare -i pwrc__dblocked=1
declare -i pwrc__loaddb=2
declare -i pwrc_status=$pwrc__success
snp_save_file()
{
new_file=$1
if [ -e $new_file ]; then
let version=9
while [ $version -ge 1 ]
do
old_file=$new_file.$version
old_file_ren=$new_file.$((version+1))
if [ -e $old_file ]; then
mv $old_file $old_file_ren
fi
let version=$version-1
done
old_file=$new_file.1
echo "-- Saving file $new_file -> $old_file"
mv $new_file $old_file
fi
}
#
# Get the databases in a project
#
# Arguments 1: project root
# Returns pwrc_status : 0 Success
#
#
pwrc_dblist_read()
{
local volume
local volid
local volclass
local volcnf
local volenum
local volserver
local dbfile
local db
local proot=$1
let i=0
let j=0
let k=0
pwrc_status=$pwrc__success
#set -o xtrace
if [ -n "${db_array[*]}" ]; then
unset db_array
fi
dbfile=$proot/src/db/pwrp_cnf_volumelist.dat
if [ ! -e $dbfile ]; then
echo "Can't find $dbfile"
return
fi
while read volume volid volclass volcnf volenum volserver; do
if [ -n "$volume" ] && [ "${volume:0:1}" != "!" ] && [ $volume != "$2" ]; then
if [ $volcnf == "cnf" ]; then
if [ $volclass == "ClassVolume" ]; then
if [ $volenum -eq 0 ]; then
wbl_array[$k]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
k=$k+1
elif [ $volenum -eq 1 ]; then
db_array[$i]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
i=$i+1
elif [ $volenum -eq 2 ]; then
dbms_array[$j]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
dbms_server_array[$j]=$volserver
j=$j+1
fi
else
if [ $volenum -eq 0 ]; then
db_array[$i]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
i=$i+1
elif [ $volenum -eq 1 ]; then
dbms_array[$j]=`eval echo $volume | tr "[:upper:]" "[:lower:]"`
dbms_server_array[$j]=$volserver
j=$j+1
fi
fi
fi
fi
done < $dbfile
}
action=$1
proot=$2
current_volume=$3
pwrc_dblist_read $proot $current_volume
# Check that no database is not locked
let i=0
while [ "${db_array[$i]}" != "" ]; do
echo $i Database ${db_array[$i]}
lockfile="$proot/src/db/${db_array[$((i++))]}.db.lock"
echo $lockfile
if [ -e $lockfile ]; then
echo "Database is locked..."
exit $pwrc__dblocked
fi
done
if [ $action == "create" ]; then
# Create revision files
let i=0
while [ "${db_array[$i]}" != "" ]; do
wb_cmd -v ${db_array[$i]} wb dump/nofo/out=\"$proot/src/db/${db_array[$((i++))]}.wb_rev\"
done
elif [ $action == "restore" ]; then
# Load revision files
# Rename old databases
let i=0
while [ "${db_array[$i]}" != "" ]; do
snp_save_file $pwrp_db/${db_array[$i]}.db
let $((i++))
done
while [ "${dbms_array[$i]}" != "" ]; do
dbname="pwrp_"$pwrp_projectname"__"${dbms_array[$i]}
mysqldump -h ${dbms_server_array[$i]} -upwrp $dbname > $pwrp_db/${dbms_array[$i]}.dbms/$dbname.mysqldump
mysqladmin -h ${dbms_server_array[$i]} -upwrp drop -f $dbname
snp_save_file $pwrp_db/${dbms_array[$i]}.dbms
i=$i+1
done
# Load revision files
let i=0
while [ "${db_array[$i]}" != "" ]; do
dump_file=$pwrp_db/${db_array[$i]}.wb_dmp
list_file=$pwrp_db/${db_array[$((i++))]}.lis
if wb_cmd -q wb load/nofocode/load=\"$dump_file\"/out=\"$list_file\"
then
echo "sts: ok $pwrc_status"
else
cat $list_file
pwrc_status=$pwrc__loaddb
echo "sts: no $pwrc_status"
fi
done
echo sts: $pwrc_status
exit $pwrc_status
fi
exit $pwrc__success
\ No newline at end of file
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
# Start the navigator
username=$1
password=$2
volume=$3
if [ "`eval locale -a | grep -i "^en_US.UTF-8$"`" != "" ]; then
export LC_TIME="en_US.UTF-8"
elif [ "`eval locale -a | grep -i "^en_US$"`" != "" ]; then
export LC_TIME="en_US"
fi
export LC_NUMERIC="POSIX"
wb $username $password $volume $4 $5 $6 $7
#!/bin/bash
# ProviewR Open Source Process Control.
# Copyright (C) 2005-2019 SSAB EMEA AB.
#
# This file is part of ProviewR.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 2 of
# the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with ProviewR. If not, see <http://www.gnu.org/licenses/>
#
# Linking ProviewR statically or dynamically with other modules is
# making a combined work based on ProviewR. Thus, the terms and
# conditions of the GNU General Public License cover the whole
# combination.
#
# In addition, as a special exception, the copyright holders of
# ProviewR give you permission to, from the build function in the
# ProviewR Configurator, combine ProviewR with modules generated by the
# ProviewR PLC Editor to a PLC program, regardless of the license
# terms of these modules. You may copy and distribute the resulting
# combined work under the terms of your choice, provided that every
# copy of the combined work is accompanied by a complete copy of
# the source code of ProviewR (the version used to produce the
# combined work), being distributed under the terms of the GNU
# General Public License plus this exception.
# Edit a base wb_load-file with classeditor
export pwr_exe=$pwr_eexe
export pwr_load=$pwr_eload
wb -c $1
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