diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ab848d9 --- /dev/null +++ b/.gitignore @@ -0,0 +1,330 @@ +# ---> VisualStudio +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.userosscache +*.sln.docstates + +# User-specific files (MonoDevelop/Xamarin Studio) +*.userprefs + +# Build results +[Dd]ebug/ +[Dd]ebugPublic/ +[Rr]elease/ +[Rr]eleases/ +x64/ +x86/ +build/ +bld/ +[Bb]in/ +[Oo]bj/ + +# Visual Studio 2015 cache/options directory +.vs/ +# Uncomment if you have tasks that create the project's static files in wwwroot +#wwwroot/ + +# MSTest test Results +[Tt]est[Rr]esult*/ +[Bb]uild[Ll]og.* + +# NUNIT +*.VisualState.xml +TestResult.xml + +# Build Results of an ATL Project +[Dd]ebugPS/ +[Rr]eleasePS/ +dlldata.c + +# DNX +project.lock.json +artifacts/ + +*_i.c +*_p.c +*_i.h +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.tmp_proj +*.log +*.vspscc +*.vssscc +.builds +*.pidb +*.svclog +*.scc + +# Chutzpah Test files +_Chutzpah* + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf +*.cachefile + +# Visual Studio profiler +*.psess +*.vsp +*.vspx +*.sap + +# TFS 2012 Local Workspace +$tf/ + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper*/ +*.[Rr]e[Ss]harper +*.DotSettings.user + +# JustCode is a .NET coding add-in +.JustCode + +# TeamCity is a build add-in +_TeamCity* + +# DotCover is a Code Coverage Tool +*.dotCover + +# NCrunch +_NCrunch_* +.*crunch*.local.xml +nCrunchTemp_* + +# MightyMoose +*.mm.* +AutoTest.Net/ + +# Web workbench (sass) +.sass-cache/ + +# Installshield output folder +[Ee]xpress/ + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish/ + +# Publish Web Output +*.[Pp]ublish.xml +*.azurePubxml +# TODO: Comment the next line if you want to checkin your web deploy settings +# but database connection strings (with potential passwords) will be unencrypted +*.pubxml +*.publishproj + +# NuGet Packages +*.nupkg +# The packages folder can be ignored because of Package Restore +**/packages/* +# except build/, which is used as an MSBuild target. +!**/packages/build/ +# Uncomment if necessary however generally it will be regenerated when needed +#!**/packages/repositories.config + +# Windows Azure Build Output +csx/ +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Visual Studio cache files +# files ending in .cache can be ignored +*.[Cc]ache +# but keep track of directories ending in .cache +!*.[Cc]ache/ + +# Others +ClientBin/ +[Ss]tyle[Cc]op.* +~$* +*~ +*.dbmdl +*.dbproj.schemaview +*.pfx +*.publishsettings +node_modules/ +orleans.codegen.cs + +# RIA/Silverlight projects +Generated_Code/ + +# Backup & report files from converting an old project file +# to a newer Visual Studio version. Backup files are not needed, +# because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML +UpgradeLog*.htm + +# SQL Server files +*.mdf +*.ldf + +# Business Intelligence projects +*.rdl.data +*.bim.layout +*.bim_*.settings + +# Microsoft Fakes +FakesAssemblies/ + +# Node.js Tools for Visual Studio +.ntvs_analysis.dat + +# Visual Studio 6 build log +*.plg + +# Visual Studio 6 workspace options file +*.opt + +# Visual Studio LightSwitch build output +**/*.HTMLClient/GeneratedArtifacts +**/*.DesktopClient/GeneratedArtifacts +**/*.DesktopClient/ModelManifest.xml +**/*.Server/GeneratedArtifacts +**/*.Server/ModelManifest.xml +_Pvt_Extensions + +# ---> C Sharp +# Build Folders (you can keep bin if you'd like, to store dlls and pdbs) +[Bb]in/ +[Oo]bj/ + +# mstest test results +TestResults + +## Ignore Visual Studio temporary files, build results, and +## files generated by popular Visual Studio add-ons. + +# User-specific files +*.suo +*.user +*.sln.docstates + +# Build results +[Dd]ebug/ +[Rr]elease/ +x64/ +*_i.c +*_p.c +*.ilk +*.meta +*.obj +*.pch +*.pdb +*.pgc +*.pgd +*.rsp +*.sbr +*.tlb +*.tli +*.tlh +*.tmp +*.log +*.vspscc +*.vssscc +.builds + +# Visual C++ cache files +ipch/ +*.aps +*.ncb +*.opensdf +*.sdf + +# Visual Studio profiler +*.psess +*.vsp +*.vspx + +# Guidance Automation Toolkit +*.gpState + +# ReSharper is a .NET coding add-in +_ReSharper* + +# NCrunch +*.ncrunch* +.*crunch*.local.xml + +# Installshield output folder +[Ee]xpress + +# DocProject is a documentation generator add-in +DocProject/buildhelp/ +DocProject/Help/*.HxT +DocProject/Help/*.HxC +DocProject/Help/*.hhc +DocProject/Help/*.hhk +DocProject/Help/*.hhp +DocProject/Help/Html2 +DocProject/Help/html + +# Click-Once directory +publish + +# Publish Web Output +*.Publish.xml + +# NuGet Packages Directory +packages + +# Windows Azure Build Output +csx +*.build.csdef + +# Windows Store app package directory +AppPackages/ + +# Others +[Bb]in +[Oo]bj +sql +TestResults +[Tt]est[Rr]esult* +*.Cache +ClientBin +[Ss]tyle[Cc]op.* +~$* +*.dbmdl +Generated_Code #added for RIA/Silverlight projects + +# Backup & report files from converting an old project file to a newer +# Visual Studio version. Backup files are not needed, because we have git ;-) +_UpgradeReport_Files/ +Backup*/ +UpgradeLog*.XML + +.ionide/symbolCache.db diff --git a/Effector.Plugin.StoneCut.Naked.sln b/Effector.Plugin.StoneCut.Naked.sln new file mode 100644 index 0000000..81c7be5 --- /dev/null +++ b/Effector.Plugin.StoneCut.Naked.sln @@ -0,0 +1,51 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.Interface", "..\Effector\Effector.Plugin.Interface\Effector.Plugin.Interface.vbproj", "{7D14D864-2BDC-4785-80F4-320164C2D5E4}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.StoneCut", "Effector.Plugin.StoneCut\Effector.Plugin.StoneCut.vbproj", "{7C77F537-8235-40AB-B24A-4E71CFB96D2C}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x64.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x64.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x86.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|Any CPU.Build.0 = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x64.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x64.Build.0 = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x86.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x86.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x64.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x64.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x86.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x86.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|Any CPU.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9D87F62-BDA1-4B0C-BE15-C43A682829E8} + EndGlobalSection +EndGlobal diff --git a/Effector.Plugin.StoneCut.sln b/Effector.Plugin.StoneCut.sln new file mode 100644 index 0000000..07047bc --- /dev/null +++ b/Effector.Plugin.StoneCut.sln @@ -0,0 +1,68 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Main", "..\Effector.Main\Effector.Main\Effector.Main.vbproj", "{38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.Interface", "..\Effector.Main\Effector.Plugin.Interface\Effector.Plugin.Interface.vbproj", "{7D14D864-2BDC-4785-80F4-320164C2D5E4}" +EndProject +Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "Effector.Plugin.StoneCut", "Effector.Plugin.StoneCut\Effector.Plugin.StoneCut.vbproj", "{7C77F537-8235-40AB-B24A-4E71CFB96D2C}" + ProjectSection(ProjectDependencies) = postProject + {7D14D864-2BDC-4785-80F4-320164C2D5E4} = {7D14D864-2BDC-4785-80F4-320164C2D5E4} + EndProjectSection +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Debug|x86 = Debug|x86 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|Any CPU.ActiveCfg = Debug|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|Any CPU.Build.0 = Debug|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x64.ActiveCfg = Debug|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x64.Build.0 = Debug|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x86.ActiveCfg = Debug|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Debug|x86.Build.0 = Debug|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|Any CPU.ActiveCfg = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|Any CPU.Build.0 = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x64.ActiveCfg = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x64.Build.0 = Release|x64 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x86.ActiveCfg = Release|x86 + {38BEE4BF-9238-459F-AF89-4DD94C4FD0DA}.Release|x86.Build.0 = Release|x86 + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x64.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x64.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x86.ActiveCfg = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Debug|x86.Build.0 = Debug|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|Any CPU.Build.0 = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x64.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x64.Build.0 = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x86.ActiveCfg = Release|Any CPU + {7D14D864-2BDC-4785-80F4-320164C2D5E4}.Release|x86.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x64.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x64.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x86.ActiveCfg = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Debug|x86.Build.0 = Debug|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|Any CPU.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x64.Build.0 = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.ActiveCfg = Release|Any CPU + {7C77F537-8235-40AB-B24A-4E71CFB96D2C}.Release|x86.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F9D87F62-BDA1-4B0C-BE15-C43A682829E8} + EndGlobalSection +EndGlobal diff --git a/Effector.Plugin.StoneCut/Constants/ConstGen.vb b/Effector.Plugin.StoneCut/Constants/ConstGen.vb new file mode 100644 index 0000000..7cc6083 --- /dev/null +++ b/Effector.Plugin.StoneCut/Constants/ConstGen.vb @@ -0,0 +1,66 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2017 +'---------------------------------------------------------------------------- +' File : ConstGen.vb Data : 08.05.24 Versione : 2.6e1 +' Contenuto : Modulo costanti generali. +' +' +' +' Modifiche : 08.05.24 ES Creazione modulo. +' +' +'---------------------------------------------------------------------------- + +Public Module ConstGen + + ' File con direttorio radice dei dati + Public Const DAT_FILE_NAME As String = "DataRoot.Ini" + Public Const S_DATA As String = "Data" + Public Const K_DATAROOT As String = "DataRoot" + + '' File con dati di licenza + 'Public Const LIC_FILE_NAME As String = "EgtBEAMWALL.lic" + 'Public Const S_LICENCE As String = "Licence" + 'Public Const K_LOCKID As String = "LockId" + 'Public Const K_KEY As String = "Key" + + + ' Abilitazioni licenza + Public Enum KEY_OPT As UInteger + SUPERVISOR = 1 + End Enum + + ' Sottodirettorio di configurazione + Public Const CONF_DIR As String = "Config" + ' Sottodirettorio delle risorse + Public Const RES_DIR As String = "Resources" + ' Sottodirettorio script + Public Const SCRIPT_DIR As String = "Script" + ' Sottodirettorio temporaneo + Public Const TEMP_DIR As String = "Temp" + '' Sottodirettorio per Cam automatico + 'Public Const PROJS_DIR As String = "Projs" + '' Sottodirettorio per Csv automatico + 'Public Const PRODS_DIR As String = "Prods" + '' Sottodirettorio per Macro + 'Public Const MACRO_DIR As String = "Macro" + '' Sottodirettorio per Magazzino + 'Public Const WAREHOUSE_DIR As String = "Warehouse" + '' Sottodirettorio per lavorazioni travi + 'Public Const BEAM_DIR As String = "Beam" + '' Sottodirettorio per lavorazioni pareti + 'Public Const WALL_DIR As String = "Wall" + '' Sottodirettorio di default per il salvataggio con nome + 'Public Const SAVE_DFL_NAMEDIR As String = "MyProjects" + '' Sottodirettorio di default per le macchine + 'Public Const MACHINES_DFL_DIR As String = "Machines" + '' Sottodirettorio di default per toolmakers + 'Public Const TOOLMAKERS_DFL_DIR As String = "ToolMakers" + '' Nome file Lua con le funzioni di attrezzaggio + 'Public Const SETUP_LUA As String = "SetUp.lua" + '' Nome eseguibile per stampa + 'Public Const ZEBRAPRINTER_EXE As String = "ZebraPrinterUtilitiesD32.exe" + '' Sottodirettorio di default per macro + 'Public Const MACRO_DFL_DIR As String = "Macro" + +End Module diff --git a/Effector.Plugin.StoneCut/Constants/ConstIni.vb b/Effector.Plugin.StoneCut/Constants/ConstIni.vb new file mode 100644 index 0000000..193c51b --- /dev/null +++ b/Effector.Plugin.StoneCut/Constants/ConstIni.vb @@ -0,0 +1,56 @@ +'---------------------------------------------------------------------------- +' EgalTech 2015-2024 +'---------------------------------------------------------------------------- +' File : ConstIni.vb Data : 08.05.24 Versione : 2.6e1 +' Contenuto : Modulo costanti sezione e chiavi per file Ini. +' +' +' +' Modifiche : 08.05.24 ES Creazione modulo. +' +' +'---------------------------------------------------------------------------- +Module ConstIni + + Public Const INI_FILE_NAME As String = "Effector.Plugin.StoneCut.ini" + + Public Const S_GENERAL As String = "General" + Public Const K_CAMEXEPATH As String = "CAMExePath" + Public Const K_DOORCREATOREXEPATH As String = "DoorCreatorExePath" + Public Const K_BACKUPDIR As String = "BackupDir" + Public Const K_RESOURCESDIR As String = "ResourcesDir" + Public Const K_DDFDIR As String = "DDFDir" + Public Const K_DDTDIR As String = "DDTDir" + Public Const K_GENDDFDIR As String = "GenDDFDir" + Public Const K_CSV As String = "CSV" + Public Const K_ISCSVOUTPUTENABLED As String = "IsCSVOutputEnabled" + Public Const K_CSVOUTPUTPATH As String = "CSVOutputPath" + Public Const K_LASTCSVDIR As String = "LastCsvDir" + + Public Const S_CSV As String = "CSV" + Public Const K_DDFNAME As String = "DDFName" + Public Const K_QUANTITY As String = "Quantity" + Public Const K_HEIGHT As String = "Height" + Public Const K_WIDTH As String = "Width" + Public Const K_THICKNESS As String = "Thickness" + Public Const K_SWING As String = "Swing" + Public Const K_PHASE As String = "Phase" + Public Const K_STATE As String = "State" + Public Const K_PROGRAMSENT As String = "ProgramSent" + Public Const K_PROGRAMSTART As String = "ProgramStart" + Public Const K_PROGRAMEND As String = "ProgramEnd" + Public Const K_MANUALADDEDDOORNAME As String = "ManualAddedDoorName" + Public Const K_DELIMITER As String = "Delimiter" + + Public Const S_DEBUG As String = "Debug" + Public Const K_VARIABLELIST As String = "VariableList" + Public Const K_VARIABLEONDRAW As String = "VariableOnDraw" + Public Const K_MACHINECOMMANDS As String = "MachineCommands" + Public Const K_DOORCIRCLIST As String = "DoorCircList" + Public Const K_DOORPRESENCE As String = "DoorPresence" + Public Const K_DOORINDEX As String = "DoorIndex" + + Public Const S_NC As String = "NC" + Public Const K_NC_SIMULATE As String = "NcSimulate" + +End Module diff --git a/Effector.Plugin.StoneCut/DoorListPage/DoorListPageV.xaml b/Effector.Plugin.StoneCut/DoorListPage/DoorListPageV.xaml new file mode 100644 index 0000000..78f60f2 --- /dev/null +++ b/Effector.Plugin.StoneCut/DoorListPage/DoorListPageV.xaml @@ -0,0 +1,272 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Effector.Plugin.StoneCut/DoorListPage/DoorListPageV.xaml.vb b/Effector.Plugin.StoneCut/DoorListPage/DoorListPageV.xaml.vb new file mode 100644 index 0000000..7330597 --- /dev/null +++ b/Effector.Plugin.StoneCut/DoorListPage/DoorListPageV.xaml.vb @@ -0,0 +1,13 @@ +Public Class DoorListPageV + + ' funzione che impedisce di editare le righe che sono gia' in produzione + Private Sub DoorList_BeginningEdit(sender As Object, e As DataGridBeginningEditEventArgs) + 'If IsNothing(e.Row) Then Return + 'Dim RowVM As Door = DirectCast(e.Row.DataContext, Door) + '' se in produzione impedisco modifica dei parametri + 'If RowVM.nState >= Door.PartProgramStates.READY_FOR_PRODUCTION Then + ' e.Cancel = True + 'End If + End Sub + +End Class diff --git a/Effector.Plugin.StoneCut/DoorListPage/DoorListPageVM.vb b/Effector.Plugin.StoneCut/DoorListPage/DoorListPageVM.vb new file mode 100644 index 0000000..b7ca7fc --- /dev/null +++ b/Effector.Plugin.StoneCut/DoorListPage/DoorListPageVM.vb @@ -0,0 +1,921 @@ +Imports System.Collections.ObjectModel +Imports System.IO +Imports Newtonsoft.Json +Imports System.Windows.Threading +Imports System.Text.RegularExpressions +Imports System.Security.Cryptography +Imports Newtonsoft.Json.Linq +Imports Effector.Plugin.StoneCut.Door +Imports System.Globalization +Imports System.Diagnostics +Imports Effector.Plugin.Lib + +Public Class DoorListPageVM + Inherits VMBase + + Private m_BackupTimer As New DispatcherTimer + Private m_WriteCSVTimer As New DispatcherTimer + Private m_RefreshGraphicsTimer As New DispatcherTimer + Private m_ExecProcessManager As ExecProcessManager + + Private m_ReadPartProgramFolderTimer As New DispatcherTimer + Private m_sPartProgramFolderPath As String + + Private m_DoorList As New ObservableCollection(Of Door) + + Private m_bResetList As Boolean = False + Public ReadOnly Property bResetList As Boolean + Get + Return m_bResetList + End Get + End Property + Friend Sub ResetResetList() + m_bResetList = False + End Sub + + Public ReadOnly Property DoorList As ObservableCollection(Of Door) + Get + Return m_DoorList + End Get + End Property + Private m_SelDoor As Door + Public Property SelDoor As Door + Get + Return m_SelDoor + End Get + Set(value As Door) + m_SelDoor = value + End Set + End Property + + Private m_DDTList As New ObservableCollection(Of String) + Public ReadOnly Property DDTList As ObservableCollection(Of String) + Get + Return m_DDTList + End Get + End Property + + Private m_ManualAddedDoorName As String = "Manual" + Public ReadOnly Property ManualAddedDoorName As String + Get + Return m_ManualAddedDoorName + End Get + End Property + + Private m_bExecButton_IsEnabled As Boolean = True + Public ReadOnly Property bExecButton_IsEnabled As Boolean + Get + Return m_bExecButton_IsEnabled + End Get + End Property + Private Sub SetExecButtonIsEnabled(bValue As Boolean) + m_bExecButton_IsEnabled = bValue + NotifyPropertyChanged(NameOf(bExecButton_IsEnabled)) + End Sub + Private m_nModifyIndex As Integer = 0 + Private m_nBackupindex As Integer = 0 + Private m_bWritingBackup As Boolean = False + + Private m_sCSVOutDirPath As String = "" + + Private m_nExecIncrement As Integer = 0 + Private m_nExecutedArgsCount As Integer = 0 + Public ReadOnly Property dExecPercentage As Double + Get + If m_bCreatingDdfs Then + Return 5 / m_nTotCreatingDdf * m_nCurrCreatingDdf + End If + If IsNothing(m_ExecProcessManager) Then Return 0 + Dim dExecIncrement As Double = If(m_ExecProcessManager.nArgsInQueue = 0, 0, Math.Min(28, m_nExecIncrement) / 34) + Return (m_ExecProcessManager.nExecutedArgsCounter + dExecIncrement) / (m_ExecProcessManager.nExecutedArgsCounter + m_ExecProcessManager.nArgsInQueue) * 100 + End Get + End Property + + Public ReadOnly Property sExecPercentage As String + Get + Return DoubleToString(dExecPercentage, 1) & "%" + End Get + End Property + + Public ReadOnly Property ExecPercentage_Visibility As Visibility + Get + Return If((Not IsNothing(m_ExecProcessManager) AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.RUNNING) OrElse m_bCreatingDdfs, Visibility.Visible, Visibility.Collapsed) + End Get + End Property + + Private m_bCreatingDdfs As Boolean + Private m_nTotCreatingDdf As Integer + Private m_nCurrCreatingDdf As Integer + + ' Definizione comandi + Private m_cmdProduce As ICommand + Private m_cmdProduceAll As ICommand + Private m_cmdResetProductionQueue As ICommand + Private m_cmdMoveUp As ICommand + Private m_cmdMoveDown As ICommand + Private m_cmdNotProduce As ICommand + Private m_cmdCopy As ICommand + ' Private m_cmdMultipleCopy As ICommand + Private m_cmdDelete As ICommand + Private m_cmdDeleteAll As ICommand + +#Region "CONSTRUCTOR" + + Sub New() + ' imposto riferimento in Map + Map.SetRefDoorListPageVM(Me) + ' leggo backup + Dim sBackupDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, "BackupDir", "", sBackupDirPath) + Dim sBackupFilePath As String = sBackupDirPath & "\Backup.json" + Read(sBackupFilePath) + m_BackupTimer.Interval = New TimeSpan(0, 0, 1) + AddHandler m_BackupTimer.Tick, AddressOf BackupTimer_Tick + m_WriteCSVTimer.Interval = New TimeSpan(0, 1, 0) + AddHandler m_WriteCSVTimer.Tick, AddressOf WriteCSVTimer_Tick + m_RefreshGraphicsTimer.Interval = New TimeSpan(0, 0, 1) + AddHandler m_RefreshGraphicsTimer.Tick, AddressOf RefreshGraphicsTimer_Tick + m_BackupTimer.Start() + ' verifico path salvataggio CSV + Dim bStartWriteCSV As Boolean = False + If GetPluginPrivateProfileInt(S_GENERAL, K_ISCSVOUTPUTENABLED, 0) = 1 Then + bStartWriteCSV = True + If GetPluginPrivateProfileString(S_GENERAL, K_CSVOUTPUTPATH, "", m_sCSVOutDirPath) = 0 Then + bStartWriteCSV = False + MessageBox.Show("Path di salvataggio CSV non impostata! Impossibile creare file CSV!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error) + End If + If bStartWriteCSV AndAlso Not Directory.Exists(m_sCSVOutDirPath) Then + bStartWriteCSV = False + MessageBox.Show("Path di salvataggio CSV impostata non esiste! Impossibile creare file CSV!", "Errore!", MessageBoxButton.OK, MessageBoxImage.Error) + End If + If bStartWriteCSV Then + m_WriteCSVTimer.Start() + End If + End If + m_RefreshGraphicsTimer.Start() + + ' leggo path cartella dei partprogram + GetPluginPrivateProfileString(S_GENERAL, "PartProgramFolder", "", m_sPartProgramFolderPath) + If Not Directory.Exists(m_sPartProgramFolderPath) Then + MessageBox.Show("Folder not found! Folder path not configured correctly") + End If + ' avvio timer di copia file + AddHandler m_ReadPartProgramFolderTimer.Tick, AddressOf ReadPartProgramFolderTimer_Tick + m_ReadPartProgramFolderTimer.Interval = TimeSpan.FromSeconds(1) + m_ReadPartProgramFolderTimer.Start() + End Sub +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Private Sub ReadPartProgramFolderTimer_Tick(sender As Object, e As EventArgs) + Dim FileList() As String = Directory.GetFiles(m_sPartProgramFolderPath) + If FileList.Count = 0 Then Return + ' copio file e li metto in lista + Dim sPartProgramDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, "PartProgramDir", "", sPartProgramDirPath) + For nFileIndex = 0 To FileList.Count - 1 + Dim bFileMove As Boolean = False + + Dim sNewFilePath As String = sPartProgramDirPath & "\" & Path.GetFileName(FileList(nFileIndex)) + Try + File.Move(FileList(nFileIndex), sNewFilePath) + bFileMove = True + Catch ex As Exception + MessageBox.Show("Impossible loading file " & FileList(0)) + End Try + If bFileMove Then + Dim CurrFileInfo As New FileInfo(sNewFilePath) + Dim CurrFileLength As Double = CDbl(CurrFileInfo.Length) + Dim CurrFileLines = File.ReadLines(sNewFilePath).Take(10).ToList() + Dim nId As Integer = 0 + Dim nTable As Integer = 0 + For nLineIndex = 0 To CurrFileLines.Count - 1 + Dim IdMatch As Match = Regex.Match(CurrFileLines(nLineIndex), ".*\(ID=(\d+)\)") + If Not IsNothing(IdMatch) AndAlso Not String.IsNullOrWhiteSpace(IdMatch.Value) Then + Integer.TryParse(IdMatch.Groups(1).Value, nId) + End If + Dim TableMatch As Match = Regex.Match(CurrFileLines(nLineIndex), ".*\(TABLE=(\d+)\)") + If Not IsNothing(TableMatch) AndAlso Not String.IsNullOrWhiteSpace(TableMatch.Value) Then + Integer.TryParse(TableMatch.Groups(1).Value, nTable) + End If + If nId <> 0 AndAlso nTable <> 0 Then Exit For + Next + m_DoorList.Add(New Door(nId, Path.GetFileName(FileList(nFileIndex)), nTable, CurrFileLength)) + End If + Next + WriteBackup() + End Sub + + Public Sub Read(FilePath As String) + If Not File.Exists(FilePath) Then Return + Dim sReadedFile As String = File.ReadAllText(FilePath) + Dim JsonDoorList As List(Of JsonDoor) = JsonConvert.DeserializeObject(Of List(Of JsonDoor))(sReadedFile) + JsonDoorList = JsonDoorList.OrderBy(Of Integer)(Function(x) x.nListIndex).ToList() + + Dim TempDoorList As ObservableCollection(Of Door) = New ObservableCollection(Of Door)((From JsonDoor In JsonDoorList + Select New Door(JsonDoor)).ToList()) + 'For Each CurrDoor In TempDoorList + ' If CurrDoor.nState >= Door.PartProgramStates.READY_FOR_PRODUCTION AndAlso CurrDoor.nState < Door.PartProgramStates.MACHINE_1_END Then + ' CurrDoor.SetState(Door.PartProgramStates.VERIFIED, False) + ' End If + 'Next + 'WriteBackup() + m_DoorList = TempDoorList + End Sub + + Public Sub Write(FilePath As String) + Dim JsonDoorList As New List(Of JsonDoor) + For nDoorIndex As Integer = 0 To m_DoorList.Count - 1 + JsonDoorList.Add(New JsonDoor(nDoorIndex, m_DoorList(nDoorIndex))) + Next + Dim JsonFromWindow As String = JsonConvert.SerializeObject(JsonDoorList, Formatting.Indented) + If File.Exists(FilePath) Then + Dim sBackupFilePath As String = Path.ChangeExtension(FilePath, ".bck") + If File.Exists(sBackupFilePath) Then + Try + File.Delete(sBackupFilePath) + Catch ex As Exception + Map.refSupervisorFunction.PlgOutLog("Error! Impossible deleting backup file!") + End Try + End If + Try + File.Move(FilePath, sBackupFilePath) + Catch ex As Exception + Map.refSupervisorFunction.PlgOutLog("Error! Impossible renaming backup file!") + End Try + End If + File.WriteAllText(FilePath, JsonFromWindow) + End Sub + + Private Sub WriteBackupCmd() + If m_bWritingBackup Then Return + m_bWritingBackup = True + m_nBackupindex = m_nModifyIndex + Dim sBackupDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, K_BACKUPDIR, "", sBackupDirPath) + Dim sBackupFilePath As String = sBackupDirPath & "\Backup.json" + Write(sBackupFilePath) + m_bWritingBackup = False + End Sub + + Friend Sub WriteBackup() + m_nModifyIndex += 1 + End Sub + + Private Sub BackupTimer_Tick(sender As Object, e As EventArgs) + If m_nBackupindex < m_nModifyIndex Then + WriteBackupCmd() + End If + End Sub + + Private Sub WriteCSVTimer_Tick(sender As Object, e As EventArgs) + 'SaveCSV() + End Sub + + Private Sub RefreshGraphicsTimer_Tick(sender As Object, e As EventArgs) + 'If IsNothing(m_ExecProcessManager) Then Return + '' ciclo su coda risultati + 'Dim ArgumentsResult As ProcessArgsResult = m_ExecProcessManager.ArgumentsResultDequeue + 'While Not IsNothing(ArgumentsResult) + ' ' aggiorno risultato sulla porta + ' Dim CurrRequestDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = ArgumentsResult.ProcessArgs.nId) + ' If Not IsNothing(CurrRequestDoor) Then + ' CurrRequestDoor.SetState(If(ArgumentsResult.nResult = 0, Door.PartProgramStates.VERIFIED, Door.PartProgramStates.VERIFICATION_FAILED)) + ' ' elimino file generati + ' Dim sGenDDFDirPath As String = "" + ' GetPluginPrivateProfileString(S_GENERAL, K_GENDDFDIR, "", sGenDDFDirPath) + ' Dim sDoorFileName As String = Path.GetFileNameWithoutExtension(CurrRequestDoor.sFileName) & "_" & CurrRequestDoor.nId + ' Try + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".tok") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.tok") + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".cnc") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_a.cnc") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_b.cnc") + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.cnc") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2_a.cnc") + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".html") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.html") + ' 'If ArgumentsResult.nResult = 0 Then + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".log") + ' 'End If + ' ''File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".nge") + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".nge") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".sest") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.sest") + ' 'Dim SestFiles() As String = System.IO.Directory.GetFiles(sGenDDFDirPath & "\", sDoorFileName & "*.sest") + ' 'For Each FilePath In SestFiles + ' ' File.Delete(FilePath) + ' 'Next + ' ''File.Delete(sGenDDFDirPath & "\" & CurrRequestDoor.sDDFName & ".txt") + ' File.Delete(sGenDDFDirPath & "\" & sDoorFileName & ".txt") + ' 'File.Delete(sGenDDFDirPath & "\" & sDoorFileName & "_2.txt") + ' Catch ex As Exception + + ' End Try + ' End If + ' ' verifico se ci sono altre porte dello stesso tipo da aggiornare + ' If m_AssociationList.ContainsKey(CurrRequestDoor.nId) Then + ' Dim SameDoorList As List(Of Integer) = m_AssociationList(CurrRequestDoor.nId) + ' For Each CurrDoorId In SameDoorList + ' Dim CurrDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nId = CurrDoorId) + ' If Not IsNothing(CurrDoor) Then + ' If CopyGenDdfFile(CurrRequestDoor, CurrDoor) Then + ' CurrDoor.SetState(If(ArgumentsResult.nResult = 0, Door.PartProgramStates.VERIFIED, Door.PartProgramStates.VERIFICATION_FAILED)) + ' End If + ' End If + ' Next + ' End If + ' WriteBackup() + ' ArgumentsResult = m_ExecProcessManager.ArgumentsResultDequeue + 'End While + '' aggiorno grafica + 'If m_nExecutedArgsCount <> m_ExecProcessManager.nExecutedArgsCounter Then + ' m_nExecutedArgsCount = m_ExecProcessManager.nExecutedArgsCounter + ' m_nExecIncrement = 0 + 'ElseIf m_ExecProcessManager.nCalculatingProcesses > 0 Then + ' m_nExecIncrement += 1 + 'End If + 'If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.RUNNING Then + ' NotifyPropertyChanged(NameOf(dExecPercentage)) + ' NotifyPropertyChanged(NameOf(sExecPercentage)) + 'End If + 'If Not bExecButton_IsEnabled AndAlso m_ExecProcessManager.ExecutionThreadStatus = ExecProcessManager.ExecutionThreadStatuses.STOPPED Then + ' SetExecButtonIsEnabled(True) + 'End If + 'NotifyPropertyChanged(NameOf(ExecPercentage_Visibility)) + End Sub + + Friend Function GetNextDoor() As Door + Dim NextDoor As Door = m_DoorList.FirstOrDefault(Function(x) x.nState = Door.PartProgramStates.READY_FOR_PRODUCTION) + If Not IsNothing(NextDoor) Then + Map.refSupervisorFunction.PlgOutLog("GetNextDoor: door " & NextDoor.nId & " sent to NC") + NextDoor.SetState(Door.PartProgramStates.SENT_TO_NC) + WriteBackup() + End If + Return NextDoor + End Function + + Friend Function NewDoorId() As Integer + Dim nId As Integer = 1 + If m_DoorList.Count > 0 Then + Dim nMaxId As Integer = m_DoorList.Max(Of Integer)(Function(x) x.nId) + nId = nMaxId + 1 + End If + Return nId + End Function + + Friend Sub ResetStateAfterReset() + 'For Each Door In m_DoorList + ' If Door.nState > Door.PartProgramStates.VERIFIED AndAlso Door.nState < Door.PartProgramStates.MACHINE_1_END Then + ' Door.SetState(Door.PartProgramStates.VERIFIED, False) + ' End If + 'Next + End Sub + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "Copy" + + Public ReadOnly Property Copy_Command As ICommand + Get + If m_cmdCopy Is Nothing Then + m_cmdCopy = New Command(AddressOf CopyCmd) + End If + Return m_cmdCopy + End Get + End Property + + Public Sub CopyCmd(CurrDoor As Door) + If IsNothing(CurrDoor) Then Return + Dim nId As Integer = NewDoorId() + Dim CopyDoor As Door = CurrDoor.Copy(nId) + If Not IsNothing(CopyDoor) Then + m_DoorList.Add(CurrDoor.Copy(nId)) + End If + End Sub + + +#End Region ' CopyDoor + +#Region "MoveUp" + + Public ReadOnly Property MoveUp_Command As ICommand + Get + If m_cmdMoveUp Is Nothing Then + m_cmdMoveUp = New Command(AddressOf MoveUp) + End If + Return m_cmdMoveUp + End Get + End Property + + Public Sub MoveUp(CurrDoor As Object) + If IsNothing(CurrDoor) Then Return + Dim nOldIndex As Integer = m_DoorList.IndexOf(CurrDoor) + If nOldIndex = 0 Then Return + If m_DoorList(nOldIndex - 1).nState >= Door.PartProgramStates.READY_FOR_PRODUCTION Then Return + m_DoorList.Move(nOldIndex, nOldIndex - 1) + WriteBackup() + End Sub + +#End Region ' MoveUp + +#Region "MoveDown" + + Public ReadOnly Property MoveDown_Command As ICommand + Get + If m_cmdMoveDown Is Nothing Then + m_cmdMoveDown = New Command(AddressOf MoveDown) + End If + Return m_cmdMoveDown + End Get + End Property + + Public Sub MoveDown(CurrDoor As Door) + If IsNothing(CurrDoor) OrElse CurrDoor.nState >= Door.PartProgramStates.READY_FOR_PRODUCTION Then Return + Dim nOldIndex As Integer = m_DoorList.IndexOf(CurrDoor) + If nOldIndex = m_DoorList.Count - 1 Then Return + m_DoorList.Move(nOldIndex, nOldIndex + 1) + WriteBackup() + End Sub + +#End Region ' MoveDown + +#Region "Delete" + + Public ReadOnly Property Delete_Command As ICommand + Get + If m_cmdDelete Is Nothing Then + m_cmdDelete = New Command(AddressOf Delete) + End If + Return m_cmdDelete + End Get + End Property + + Public Sub Delete(CurrDoor As Door) + If m_DoorList.Count = 0 OrElse IsNothing(CurrDoor) Then Return + Dim bReset As Boolean = True + 'If Not LuaGetGlobVar("bReset", bReset) OrElse Not bReset Then + ' If (SelDoor.nState >= Door.PartProgramStates.READY_FOR_PRODUCTION AndAlso SelDoor.nState < Door.PartProgramStates.MACHINE_1_END) Then Return + 'End If + If MessageBox.Show("Sei sicuro di voler cancellare la porta selezionata?", "Avviso", MessageBoxButton.YesNo, MessageBoxImage.Warning) = MessageBoxResult.Yes Then + ' cancello file + Dim sPartProgramDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, "PartProgramDir", "", sPartProgramDirPath) + Try + File.Delete(sPartProgramDirPath & "\" & CurrDoor.sFileName) + Catch ex As Exception + + End Try + m_DoorList.Remove(SelDoor) + WriteBackup() + End If + End Sub + +#End Region ' Delete + +#Region "DeleteAll" + + Public ReadOnly Property DeleteAll_Command As ICommand + Get + If m_cmdDeleteAll Is Nothing Then + m_cmdDeleteAll = New Command(AddressOf DeleteAll) + End If + Return m_cmdDeleteAll + End Get + End Property + + Public Sub DeleteAll() + If m_DoorList.Count = 0 Then Return + Dim bReset As Boolean = True + 'If Not LuaGetGlobVar("bReset", bReset) OrElse Not bReset Then + ' MessageBox.Show("Impossibile cancellare tutte le porte!" & Environment.NewLine & "La macchina deve essere in stato Reset per poter cancellare tutte le porte!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning) + ' Return + 'End If + '' verifico che tutte le porte siano in stato prodotto o da non produrre + 'Dim bAllProduced As Boolean = True + 'For Each CsvDoor In m_DoorList + ' If CsvDoor.nState <> PartProgramStates.MACHINE_1_END AndAlso CsvDoor.nState <> PartProgramStates.PRODUCED AndAlso CsvDoor.nState <> PartProgramStates.NOTPRODUCE AndAlso CsvDoor.nState <> PartProgramStates.VERIFICATION_FAILED AndAlso CsvDoor.nState <> PartProgramStates.VERIFIED Then + ' bAllProduced = False + ' End If + 'Next + 'If Not bAllProduced Then + ' MessageBox.Show("Impossibile cancellare tutte le porte!" & Environment.NewLine & "Per cancellare tutte le porte, devono essere tutte non in lavorazione!", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning) + ' Return + 'End If + If MessageBox.Show("Sei sicuro di voler cancellare tutte le porte?", "Info", MessageBoxButton.YesNo, MessageBoxImage.Information) = MessageBoxResult.Yes Then + For PartProgramIndex = m_DoorList.Count - 1 To 0 Step -1 + ' cancello file + Dim sPartProgramDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, "PartProgramDir", "", sPartProgramDirPath) + Try + File.Delete(sPartProgramDirPath & "\" & m_DoorList(PartProgramIndex).sFileName) + Catch ex As Exception + + End Try + m_DoorList.RemoveAt(PartProgramIndex) + Next + WriteBackup() + '' cancello backup lua per ripartire pulito + 'Try + ' Dim sBackupDirPath As String = "" + ' GetPluginPrivateProfileString(S_GENERAL, K_BACKUPDIR, "", sBackupDirPath) + ' Dim sLuaBackupFilePath As String = sBackupDirPath & "\LuaBackup.json" + ' File.Delete(sLuaBackupFilePath) + 'Catch ex As Exception + ' Map.refSupervisorFunction.PlgOutLog("Fallita cancellazione del file LuaBackup!") + 'End Try + End If + End Sub + +#End Region ' DeleteAll + +#Region "Produce" + + Public ReadOnly Property Produce_Command As ICommand + Get + If m_cmdProduce Is Nothing Then + m_cmdProduce = New Command(AddressOf Produce) + End If + Return m_cmdProduce + End Get + End Property + + Public Sub Produce(CurrDoor As Door) + ProduceDoor(CurrDoor) + WriteBackup() + End Sub + + Public Sub ProduceDoor(DoorToProduce As Door, Optional bWriteBackup As Boolean = True) + If IsNothing(DoorToProduce) Then Return + ' la sposto dopo l'ultima da produrre + Dim nNewIndex As Integer = m_DoorList.IndexOf(m_DoorList.FirstOrDefault(Function(x) x.nState < Door.PartProgramStates.READY_FOR_PRODUCTION)) + Dim nOldIndex As Integer = m_DoorList.IndexOf(DoorToProduce) + m_DoorList.Move(nOldIndex, nNewIndex) + DoorToProduce.SetState(Door.PartProgramStates.READY_FOR_PRODUCTION, bWriteBackup) + End Sub + +#End Region ' Produce + +#Region "ProduceAll" + + Public ReadOnly Property ProduceAll_Command As ICommand + Get + If m_cmdProduceAll Is Nothing Then + m_cmdProduceAll = New Command(AddressOf ProduceAll) + End If + Return m_cmdProduceAll + End Get + End Property + + Public Sub ProduceAll() + If m_DoorList.Count = 0 Then Return + For nDoorIndex = 0 To m_DoorList.Count - 1 + Dim CurrDoor As Door = m_DoorList(nDoorIndex) + If CurrDoor.nState <> Door.PartProgramStates.MACHINE_START AndAlso CurrDoor.nState <> Door.PartProgramStates.PRODUCED Then + ProduceDoor(CurrDoor, False) + End If + Next + WriteBackup() + End Sub + +#End Region ' ProduceAll + +#Region "ResetProductionQueue" + + Public ReadOnly Property ResetProductionQueue_Command As ICommand + Get + If m_cmdResetProductionQueue Is Nothing Then + m_cmdResetProductionQueue = New Command(AddressOf ResetProductionQueueCmd) + End If + Return m_cmdResetProductionQueue + End Get + End Property + + Public Sub ResetProductionQueueCmd() + ResetProductionQueue() + WriteBackup() + End Sub + + Public Sub ResetProductionQueue() + For Each Door In m_DoorList + If Door.nState = Door.PartProgramStates.READY_FOR_PRODUCTION OrElse Door.nState = Door.PartProgramStates.SENT_TO_NC Then + Door.SetState(Door.PartProgramStates.NULL) + End If + Next + m_bResetList = True + End Sub + +#End Region ' ResetProductionQueue + +#End Region ' COMMANDS + +End Class + +Public Class Door + Inherits VMBase + + Public Enum SWINGTYPE As Integer + UNDEFINED = 0 + RIGHT = 1 + LEFT = 2 + End Enum + + Private Shared m_refWriteBackup As Action + + Public Enum PartProgramStates As Integer + NULL = 0 + READY_FOR_PRODUCTION = 1 + SENT_TO_NC = 2 + MACHINE_START = 3 + PRODUCED = 4 + NOTPRODUCE = 10 + End Enum + + Private m_nId As Integer + Public ReadOnly Property nId As Integer + Get + Return m_nId + End Get + End Property + + Private m_sFileName As String + Public Property sFileName As String + Get + Return m_sFileName + End Get + Set(value As String) + m_sFileName = value + End Set + End Property + Public ReadOnly Property sFileNameWithoutExtension As String + Get + Return If(String.IsNullOrWhiteSpace(m_sFileName), "", Path.GetFileNameWithoutExtension(m_sFileName)) + End Get + End Property + + Private m_nTable As Integer + Public ReadOnly Property nTable As Integer + Get + Return m_nTable + End Get + End Property + + Private m_dFileDimension As Double + Public ReadOnly Property dFileDimension As Double + Get + Return m_dFileDimension + End Get + End Property + Public ReadOnly Property sFileDimension As String + Get + Return DoubleToString(m_dFileDimension / 1000, 2) & "Kb" + End Get + End Property + + Private m_nState As PartProgramStates = PartProgramStates.NULL + Public ReadOnly Property nState As PartProgramStates + Get + Return m_nState + End Get + End Property + Friend Sub SetState(value As PartProgramStates, Optional bWriteBackup As Boolean = True, Optional bUpdate As Boolean = True) + m_nState = value + If bWriteBackup Then Map.refDoorListPageVM.WriteBackup() + If bUpdate Then + NotifyPropertyChanged(NameOf(nState)) + NotifyPropertyChanged(NameOf(Background)) + End If + End Sub + +#Region "Statistics" + + Private m_dtMachiningStart As DateTime = DateTime.MinValue + Friend ReadOnly Property dtMachiningStart As DateTime + Get + Return m_dtMachiningStart + End Get + End Property + Public ReadOnly Property sMachiningStart As String + Get + Return ConvertDateTimeToString(m_dtMachiningStart) + End Get + End Property + Friend Sub SetMachiningStart(dtMachiningStart As DateTime) + m_dtMachiningStart = dtMachiningStart + NotifyPropertyChanged(NameOf(sMachiningStart)) + End Sub + 'Friend Sub SetMachiningStart(Machining1Start As Long) + ' m_dtMachiningStart = New DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).AddSeconds(Machining1Start).ToLocalTime() + ' NotifyPropertyChanged(NameOf(sMachiningStart)) + 'End Sub + + Private m_dtMachiningEnd As DateTime = DateTime.MinValue + Friend ReadOnly Property dtMachiningEnd As DateTime + Get + Return m_dtMachiningEnd + End Get + End Property + Public ReadOnly Property sMachiningEnd As String + Get + Return ConvertDateTimeToString(m_dtMachiningEnd) + End Get + End Property + Friend Sub SetMachiningEnd(dtMachiningEnd As DateTime) + m_dtMachiningEnd = dtMachiningEnd + NotifyPropertyChanged(NameOf(sMachiningEnd)) + NotifyPropertyChanged(NameOf(sMachiningTime)) + End Sub + + Public ReadOnly Property sMachiningTime As String + Get + If m_dtMachiningStart = DateTime.MinValue OrElse m_dtMachiningEnd = DateTime.MinValue Then Return String.Format("{0:c}", TimeSpan.Zero) + Return String.Format("{0:c}", (m_dtMachiningEnd - m_dtMachiningStart)) + End Get + End Property + +#End Region ' Statistics + + Public ReadOnly Property Background As SolidColorBrush + Get + Select Case m_nState + Case PartProgramStates.NULL + Return Application.Current.FindResource("Omag_LightGray") + Case PartProgramStates.READY_FOR_PRODUCTION + Return Dictionary.Effector_LightBlue_Status + Case PartProgramStates.NOTPRODUCE + Return Dictionary.Effector_Yellow_Status + Case PartProgramStates.MACHINE_START + Return Dictionary.Effector_Blue_Status + Case PartProgramStates.PRODUCED + Return Dictionary.Effector_Gray_Status + Case Else + Return Brushes.LightGray + End Select + End Get + End Property + + Public ReadOnly Property Foreground As SolidColorBrush + Get + Select Case m_nState + Case PartProgramStates.NULL + Return Brushes.White + Case PartProgramStates.NOTPRODUCE + Return Dictionary.Effector_Yellow_Status + Case PartProgramStates.MACHINE_START + Return Dictionary.Effector_Blue_Status + Case PartProgramStates.PRODUCED + Return Dictionary.Effector_Gray_Status + Case Else + Return Brushes.White + End Select + End Get + End Property + + ' Definizione comandi + Private m_cmdMoveUp As ICommand + Private m_cmdMoveDown As ICommand + Private m_cmdNotProduce As ICommand + Private m_cmdCopyDoor As ICommand + 'Private m_cmdMultipleCopyDoor As ICommand + Private m_cmdDelete As ICommand + +#Region "CONSTRUCTOR" + + Sub New(nId As Integer, sFileName As String, nTable As Integer, dFileDimension As Double) + m_nId = nId + m_sFileName = sFileName + m_nTable = nTable + m_dFileDimension = dFileDimension + End Sub + + Sub New(JsonDoor As JsonDoor) + m_nId = JsonDoor.nId + m_sFileName = JsonDoor.sFileName + m_nTable = JsonDoor.nTable + m_dFileDimension = JsonDoor.dFileDimension + End Sub + +#End Region ' CONSTRUCTOR + +#Region "METHODS" + + Friend Function Copy(nId As Integer) As Door + Dim sPartProgramDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, "PartProgramDir", "", sPartProgramDirPath) + Dim nCopyIndex As Integer = 1 + Dim sFileExtension As String = Path.GetExtension(m_sFileName) + Dim sFileName As String = Path.GetFileNameWithoutExtension(m_sFileName) + While File.Exists(sPartProgramDirPath & "\" & sFileName & "_" & nCopyIndex & sFileExtension) + nCopyIndex += 1 + End While + Dim bFileCopy As Boolean = False + Try + File.Copy(sPartProgramDirPath & "\" & m_sFileName, sPartProgramDirPath & "\" & sFileName & "_" & nCopyIndex & sFileExtension) + bFileCopy = True + Catch ex As Exception + + End Try + If bFileCopy Then + Return New Door(nId, sFileName & "_" & nCopyIndex & sFileExtension, m_nTable, m_dFileDimension) + Else Return Nothing + End If + End Function + +#End Region ' METHODS + +#Region "COMMANDS" + +#Region "NotProduce" + + Public ReadOnly Property NotProduce_Command As ICommand + Get + If m_cmdNotProduce Is Nothing Then + m_cmdNotProduce = New Command(AddressOf NotProduce) + End If + Return m_cmdNotProduce + End Get + End Property + + Public Sub NotProduce() + SetState(If(nState = Door.PartProgramStates.NULL, Door.PartProgramStates.NOTPRODUCE, Door.PartProgramStates.NULL)) + End Sub + +#End Region ' NotProduceDoor + +#End Region ' COMMANDS + +End Class + +Public Class CustomerParameter + + Private m_sHeader As String + Public ReadOnly Property sHeader As String + Get + Return m_sHeader + End Get + End Property + + Private m_sValue As String + Public ReadOnly Property sValue As String + Get + Return m_sValue + End Get + End Property + Friend Sub SetValue(value As String) + m_sValue = value + End Sub + + Sub New(sHeader As String, sValue As String) + m_sHeader = sHeader + m_sValue = sValue + End Sub + +End Class + +Public Class StateToSelColorConverter + Implements IValueConverter + + Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert + If Not TypeOf value Is PartProgramStates Then Return Brushes.Aqua + 'Select Case value + ' Case PartProgramStates.LOADED_FROM_CSV + ' Return Dictionary.Effector_White_SelStatus + ' Case PartProgramStates.VERIFIED + ' Return Dictionary.Effector_Green_SelStatus + ' Case PartProgramStates.VERIFICATION_FAILED + ' Return Dictionary.Effector_Red_SelStatus + ' Case PartProgramStates.SKIPPED, PartProgramStates.NOTPRODUCE + ' Return Dictionary.Effector_Yellow_SelStatus + ' Case PartProgramStates.READY_FOR_PRODUCTION, PartProgramStates.ON_LOAD_STATION + ' Return Dictionary.Effector_LightBlue_SelStatus + ' Case PartProgramStates.MACHINE_1_START + ' Return Dictionary.Effector_Blue_SelStatus + ' Case PartProgramStates.MACHINE_1_END, PartProgramStates.PRODUCED + ' Return Dictionary.Effector_Gray_SelStatus + ' Case Else + ' Return Dictionary.Effector_White_SelStatus + 'End Select + End Function + + Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack + Throw New NotImplementedException() + End Function + +End Class + +Public Class DDTListToBooleanConverter + Implements IValueConverter + + Public Function Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert + If Not TypeOf value Is ObservableCollection(Of String) Then Return False + Return DirectCast(value, ObservableCollection(Of String)).Count = 0 + End Function + + Public Function ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack + Throw New NotImplementedException() + End Function + +End Class \ No newline at end of file diff --git a/Effector.Plugin.StoneCut/Effector.Plugin.StoneCut.vbproj b/Effector.Plugin.StoneCut/Effector.Plugin.StoneCut.vbproj new file mode 100644 index 0000000..91c4196 --- /dev/null +++ b/Effector.Plugin.StoneCut/Effector.Plugin.StoneCut.vbproj @@ -0,0 +1,228 @@ + + + + Debug + AnyCPU + {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{F184B08F-C81C-45F6-A57F-5ABD9991F28F} + Effector.Plugin.StoneCut + Effector.Plugin.StoneCut + Library + v4.7.2 + Custom + true + {7C77F537-8235-40AB-B24A-4E71CFB96D2C} + + + + + true + full + true + true + true + bin\Debug\ + Effector.Plugin.StoneCut.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + pdbonly + false + false + true + false + true + bin\Release\ + Effector.Plugin.StoneCut.xml + 41999,42016,42017,42018,42019,42020,42021,42022,42032,42036,42314 + + + On + + + Binary + + + Off + + + On + + + + ..\..\Effector.Main\Effector.Plugin.Interface\bin\Debug\Effector.Plugin.Interface.dll + + + ..\..\Effector.Plugin.Lib\Effector.Plugin.Lib\bin\Debug\Effector.Plugin.Lib.dll + + + ..\..\..\EgwWPFBaseLib\EgwWPFBaseLib\bin\Debug\EgwWPFBaseLib.dll + + + ..\packages\KeraLua.1.4.1\lib\net46\KeraLua.dll + + + ..\packages\Newtonsoft.Json.13.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + 4.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + DoorListPageV.xaml + + + + FiveLakesUI.xaml + + + + + + + MachinePageV.xaml + + + + MainMenuV.xaml + + + + RestartWndV.xaml + + + + StatisticsPageV.xaml + + + + Dictionary.xaml + + + Code + + + True + True + Resources.resx + + + True + Settings.settings + True + + + + + VbMyResourcesResXFileCodeGenerator + Resources.Designer.vb + My.Resources + + + SettingsSingleFileGenerator + Settings.Designer.vb + + + + + + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + Designer + MSBuild:Compile + + + + + + + + + + + + + + + + + + + + + + + + + + + powershell.exe -ExecutionPolicy Unrestricted -NoProfile -NonInteractive -File $(ProjectDir)\pre-build.ps1 -ProjectDir $(ProjectDir) -ProjectPath $(ProjectPath) + + + copy $(TargetPath) c:\EgtData\Effector\Plugin\Effector.Plugin.StoneCut\Effector.Plugin.StoneCut.dll + + + + + + This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + \ No newline at end of file diff --git a/Effector.Plugin.StoneCut/FiveLakesUI.xaml b/Effector.Plugin.StoneCut/FiveLakesUI.xaml new file mode 100644 index 0000000..45cdceb --- /dev/null +++ b/Effector.Plugin.StoneCut/FiveLakesUI.xaml @@ -0,0 +1,7 @@ + + + diff --git a/Effector.Plugin.StoneCut/FiveLakesUI.xaml.vb b/Effector.Plugin.StoneCut/FiveLakesUI.xaml.vb new file mode 100644 index 0000000..7af1406 --- /dev/null +++ b/Effector.Plugin.StoneCut/FiveLakesUI.xaml.vb @@ -0,0 +1,31 @@ +Imports System.ComponentModel.Composition +Imports Effector.Plugin.Interface + + + +Public Class FiveLakesUI + Implements IPluginControl + + + Private m_FiveLakesUIVM As FiveLakesUIVM + + + Sub New(Host As IHost) + ' This call is required by the designer. + InitializeComponent() + '' Add any initialization after the InitializeComponent() call. + m_FiveLakesUIVM = Me.DataContext + 'Me.DataContext = m_FiveLakesUIVM + AddHandler Me.Loaded, AddressOf FiveLakesUIV_Loaded + Map.SetRefSupervisorFunction(Host) + End Sub + + 'Private Sub Button1_Click(sender As Object, e As RoutedEventArgs) Handles Button1.Click + ' 'TextBlockTest.Text = Host.PluginTestInfo + 'End Sub + + Private Sub FiveLakesUIV_Loaded(sender As Object, e As RoutedEventArgs) + m_FiveLakesUIVM.SetTextTest("Prova 1!!") + End Sub + +End Class diff --git a/Effector.Plugin.StoneCut/FiveLakesUIVM.vb b/Effector.Plugin.StoneCut/FiveLakesUIVM.vb new file mode 100644 index 0000000..52943ab --- /dev/null +++ b/Effector.Plugin.StoneCut/FiveLakesUIVM.vb @@ -0,0 +1,61 @@ +Imports System.ComponentModel.Composition +Imports Effector.Plugin.Interface +Imports Effector.Plugin.Lib + +Public Class FiveLakesUIVM + Inherits VMBase + + Public Enum Pages As Integer + DOOR_LIST = 0 + MACHINE_STATUS = 1 + STATISTICS = 2 + End Enum + + Private m_sDataRoot As String + Private m_sConfigDir As String + Private m_sIniFile As String + Private m_sResourcesRoot As String + + Private m_SelPage As Pages + Public Property SelPage As Integer + Get + Return m_SelPage + End Get + Set(value As Integer) + m_SelPage = value + End Set + End Property + Friend Sub SetSelPage(nPage As Pages) + m_SelPage = nPage + NotifyPropertyChanged(NameOf(SelPage)) + End Sub + + Private m_TextTest As String + Public ReadOnly Property TextTest As String + Get + Return m_TextTest + End Get + End Property + Friend Sub SetTextTest(sValue As String) + m_TextTest = sValue + NotifyPropertyChanged(NameOf(TextTest)) + End Sub + + Sub New() + ' Creo riferimento a questa classe in Map + Map.BeginInit(Me) + ' Impostazione path radice per i dati + m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory + If GetPrivateProfileString(S_DATA, K_DATAROOT, "", m_sDataRoot, m_sDataRoot & "\" & DAT_FILE_NAME) = 0 Then + m_sDataRoot = System.AppDomain.CurrentDomain.BaseDirectory + End If + m_sDataRoot &= "\" & "Plugin\Effector.Plugin.StoneCut" + ' Impostazione direttorio di configurazione + m_sConfigDir = m_sDataRoot & "\" & CONF_DIR + ' Impostazione path Ini file + PluginIniFile.SetIniFile(m_sConfigDir & "\" & INI_FILE_NAME) + ' Impostazione path resources dir + m_sResourcesRoot = m_sDataRoot & "\" & RES_DIR + End Sub + +End Class diff --git a/Effector.Plugin.StoneCut/LUA/LuaManager.vb b/Effector.Plugin.StoneCut/LUA/LuaManager.vb new file mode 100644 index 0000000..32eff9c --- /dev/null +++ b/Effector.Plugin.StoneCut/LUA/LuaManager.vb @@ -0,0 +1,17 @@ +Imports System.ComponentModel.Composition +Imports Effector.Plugin.Interface +Imports KeraLua + + + +Public Class LuaManager + Implements IPluginLuaManager + + Private state As Lua + + Public Function PlgInit(state As Object) As Boolean Implements IPluginLuaManager.PlgInit + SetState(state) + Return LuaInstallGeneral(state) + End Function + +End Class diff --git a/Effector.Plugin.StoneCut/LUA/Lua_Aux.vb b/Effector.Plugin.StoneCut/LUA/Lua_Aux.vb new file mode 100644 index 0000000..bd2e7b5 --- /dev/null +++ b/Effector.Plugin.StoneCut/LUA/Lua_Aux.vb @@ -0,0 +1,686 @@ +Imports KeraLua + +Public Module Lua_Aux + + Private m_State As Lua + Friend Sub SetState(state As Lua) + m_State = state + End Sub + + Friend Function LuaClearStack(state As Lua) + Dim nIndex As Integer = state.GetTop() + If nIndex > 0 Then + state.Pop(nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef bValue As Boolean) + If Not LuaGetParam(state, nIndex, bValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef nValue As Integer) + If Not LuaGetParam(state, nIndex, nValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef lValue As Long) + If Not LuaGetParam(state, nIndex, lValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef dValue As Double) + If Not LuaGetParam(state, nIndex, dValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaCheckParam(state As Lua, nIndex As Integer, ByRef sValue As String) + If Not LuaGetParam(state, nIndex, sValue) Then + Return state.Error(" Invalid Parameter # " & nIndex) + End If + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef bValue As Boolean) As Boolean + If Not state.IsBoolean(nIndex) Then Return False + bValue = state.ToBoolean(nIndex) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef nValue As Integer) As Boolean + If Not state.IsNumber(nIndex) Then Return False + nValue = Math.Round(state.ToNumber(nIndex)) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef lValue As Long) As Boolean + If Not state.IsNumber(nIndex) Then Return False + lValue = state.ToInteger(nIndex) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef dValue As Double) As Boolean + If Not state.IsNumber(nIndex) Then Return False + dValue = state.ToNumber(nIndex) + Return True + End Function + + Friend Function LuaGetParam(state As Lua, nIndex As Integer, ByRef sValue As String) As Boolean + If Not state.IsString(nIndex) Then Return False + sValue = state.ToString(nIndex) + Return True + End Function + + Friend Function LuaSetParam(state As Lua) As Boolean + Try + state.PushNil() + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef bValue As Boolean) As Boolean + Try + state.PushBoolean(bValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef nValue As Integer) As Boolean + Try + state.PushInteger(nValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef lValue As Long) As Boolean + Try + state.PushInteger(lValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef dValue As Double) As Boolean + Try + state.PushNumber(dValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaSetParam(state As Lua, ByRef sValue As String) As Boolean + Try + state.PushString(sValue) + Catch ex As Exception + Return False + End Try + Return True + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef bValue As Boolean) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, bValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef nValue As Integer) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, nValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef lValue As Long) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, lValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef dValue As Double) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, dValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef sValue As String) As Boolean + If Not state.IsTable(nIndex) Then Return False + state.GetField(nIndex, sVarName) + Dim bResult As Boolean = LuaGetParam(state, -1, sValue) + state.Pop(1) + Return bResult + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef bValue As Boolean) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, bValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + state.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + state.RawGetInteger(-1, nTableIndex) + Else + state.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, bValue) + state.Pop(sParams.Count - 1) + Return bResult + End If + End Function + Friend Function LuaGetGlobVar(ByRef sName As String, ByRef bValue As Boolean) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + m_State.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(m_State, -1, bValue) + m_State.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + m_State.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + m_State.RawGetInteger(-1, nTableIndex) + Else + m_State.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, bValue) + m_State.Pop(sParams.Count - 1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef nValue As Integer) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, nValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + state.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + state.RawGetInteger(-1, nTableIndex) + Else + state.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, nValue) + state.Pop(sParams.Count - 1) + Return bResult + End If + End Function + Friend Function LuaGetGlobVar(ByRef sName As String, ByRef nValue As Integer) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + m_State.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(m_State, -1, nValue) + m_State.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + m_State.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + m_State.RawGetInteger(-1, nTableIndex) + Else + m_State.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, nValue) + m_State.Pop(sParams.Count - 1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef lValue As Long) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, lValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + state.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + state.RawGetInteger(-1, nTableIndex) + Else + state.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, lValue) + state.Pop(sParams.Count - 1) + Return bResult + End If + End Function + Friend Function LuaGetGlobVar(ByRef sName As String, ByRef lValue As Long) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + m_State.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(m_State, -1, lValue) + m_State.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + m_State.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + m_State.RawGetInteger(-1, nTableIndex) + Else + m_State.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, lValue) + m_State.Pop(sParams.Count - 1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef dValue As Double) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, dValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + state.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + state.RawGetInteger(-1, nTableIndex) + Else + state.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, dValue) + state.Pop(sParams.Count - 1) + Return bResult + End If + End Function + Friend Function LuaGetGlobVar(ByRef sName As String, ByRef dValue As Double) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + m_State.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(m_State, -1, dValue) + m_State.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + m_State.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + m_State.RawGetInteger(-1, nTableIndex) + Else + m_State.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, dValue) + m_State.Pop(sParams.Count - 1) + Return bResult + End If + End Function + + Friend Function LuaGetGlobVar(state As Lua, ByRef sName As String, ByRef sValue As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + state.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(state, -1, sValue) + state.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + state.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + state.RawGetInteger(-1, nTableIndex) + Else + state.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(state, -1, sVarName, sValue) + state.Pop(sParams.Count - 1) + Return bResult + End If + End Function + Friend Function LuaGetGlobVar(ByRef sName As String, ByRef sValue As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + m_State.GetGlobal(sName) + Dim bResult As Boolean = LuaGetParam(m_State, -1, sValue) + m_State.Pop(1) + Return bResult + Else + Dim sTableName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + m_State.GetGlobal(sTableName) + For nParamIndex As Integer = 1 To sParams.Count - 2 + Dim nTableIndex As Integer = -1 + If Integer.TryParse(sParams(nParamIndex), nTableIndex) Then + m_State.RawGetInteger(-1, nTableIndex) + Else + m_State.GetField(-1, sParams(nParamIndex)) + End If + Next + Dim sVarName As String = sParams(sParams.Count - 1) + Dim bResult As Boolean = LuaGetTabFieldParam(m_State, -1, sVarName, sValue) + m_State.Pop(sParams.Count - 1) + Return bResult + End If + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef bValue As Boolean) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, bValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef nValue As Integer) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, nValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef dValue As Double) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, dValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetTabFieldParam(state As Lua, nIndex As Integer, sVarName As String, ByRef sValue As String) As Boolean + If Not state.IsTable(nIndex) Then Return False + If Not LuaSetParam(state, sValue) Then Return False + Dim nPos As Integer = (If(nIndex > 0, nIndex, nIndex - 1)) + state.SetField(nPos, sVarName) + Return True + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef bValue As Boolean) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, bValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, bValue) + state.Pop(1) + Return bResult + End If + End Function + Friend Function LuaSetGlobVar(ByRef sName As String, ByRef bValue As Boolean) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(m_State, bValue) Then Return False + m_State.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + m_State.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, bValue) + m_State.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef nValue As Integer) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, nValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, nValue) + state.Pop(1) + Return bResult + End If + End Function + Friend Function LuaSetGlobVar(ByRef sName As String, ByRef nValue As Integer) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(m_State, nValue) Then Return False + m_State.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + m_State.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, nValue) + m_State.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef dValue As Double) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, dValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, dValue) + state.Pop(1) + Return bResult + End If + End Function + Friend Function LuaSetGlobVar(ByRef sName As String, ByRef dValue As Double) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(m_State, dValue) Then Return False + m_State.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + m_State.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, dValue) + m_State.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaSetGlobVar(state As Lua, ByRef sName As String, ByRef sValue As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state, sValue) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName, sValue) + state.Pop(1) + Return bResult + End If + End Function + Friend Function LuaSetGlobVar(ByRef sName As String, ByRef sValue As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(m_State, sValue) Then Return False + m_State.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + m_State.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName, sValue) + m_State.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaResetGlobVar(state As Lua, ByRef sName As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(state) Then Return False + state.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + state.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(state, -1, sVarName) + state.Pop(1) + Return bResult + End If + End Function + Friend Function LuaResetGlobVar(ByRef sName As String) As Boolean + ' se variabile standard + If Not sName.Contains("."c) Then + If Not LuaSetParam(m_State) Then Return False + m_State.SetGlobal(sName) + Return True + ' altrimenti campo di tabella + Else + Dim sTableName As String = "", sVarName As String = "" + Dim sParams() As String = sName.Split("."c) + sTableName = sParams(0) + sVarName = sParams(1) + m_State.GetGlobal(sTableName) + Dim bResult As Boolean = LuaSetTabFieldParam(m_State, -1, sVarName) + m_State.Pop(1) + Return bResult + End If + End Function + + Friend Function LuaCreateGlobTable(state As Lua, ByRef sName As String) As Boolean + Try + state.NewTable() + state.SetGlobal(sName) + Catch ex As Exception + Return False + End Try + Return True + End Function + Friend Function LuaCreateGlobTable(ByRef sName As String) As Boolean + Try + m_State.NewTable() + m_State.SetGlobal(sName) + Catch ex As Exception + Return False + End Try + Return True + End Function + +End Module diff --git a/Effector.Plugin.StoneCut/LUA/Lua_General.vb b/Effector.Plugin.StoneCut/LUA/Lua_General.vb new file mode 100644 index 0000000..d59ca34 --- /dev/null +++ b/Effector.Plugin.StoneCut/LUA/Lua_General.vb @@ -0,0 +1,214 @@ +Imports System.IO +Imports KeraLua +Imports Effector.Plugin.Lib + +Public Module Lua_General + + Friend func_PlgGetNumberFromIni As LuaFunction = AddressOf Lua_PlgGetNumberFromIni + Friend func_PlgGetStringFromIni As LuaFunction = AddressOf Lua_PlgGetStringFromIni + Friend func_PlgWriteStringToIni As LuaFunction = AddressOf Lua_PlgWriteStringToIni + 'Friend func_PlgExecProcess As LuaFunction = AddressOf Lua_PlgExecProcess + 'Friend func_PlgExecProcessAsync As LuaFunction = AddressOf Lua_PlgExecProcessAsync + 'Friend func_PlgCheckExecProcessAsync As LuaFunction = AddressOf Lua_PlgCheckExecProcessAsync + Friend func_PlgSetChangeState As LuaFunction = AddressOf Lua_PlgSetChangeState + Friend func_PlgGetNextDoor As LuaFunction = AddressOf Lua_PlgGetNextDoor + 'Friend func_PlgOpenRestartWnd As LuaFunction = AddressOf Lua_PlgOpenRestartWnd + Friend func_PlgMessageWnd As LuaFunction = AddressOf Lua_PlgMessageWnd + Friend func_PlgListReset As LuaFunction = AddressOf Lua_PlgListReset + Friend func_PlgMachineReset As LuaFunction = AddressOf Lua_PlgMachineReset + + Private Function Lua_PlgGetNumberFromIni(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + ' 4 parametri: sSec, sKey, dDef + Dim sSec As String = "" + Dim sKey As String = "" + Dim dDef As Integer = 0 + LuaCheckParam(state, 1, sSec) + LuaCheckParam(state, 2, sKey) + LuaCheckParam(state, 3, dDef) + LuaClearStack(state) + Dim dResult As Double = GetPluginPrivateProfileDouble(sSec, sKey, dDef) + ' restituisco il risultato + LuaSetParam(state, dResult) + Return 1 + End Function + + Private Function Lua_PlgGetStringFromIni(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + ' 4 parametri: sSec, sKey, sDef + Dim sSec As String = "" + Dim sKey As String = "" + Dim sDef As String = 0 + LuaCheckParam(state, 1, sSec) + LuaCheckParam(state, 2, sKey) + LuaCheckParam(state, 3, sDef) + LuaClearStack(state) + Dim sResult As String = "" + GetPluginPrivateProfileString(sSec, sKey, sDef, sResult) + ' restituisco il risultato + LuaSetParam(state, sResult) + Return 1 + End Function + + Private Function Lua_PlgWriteStringToIni(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + ' 4 parametri: sSec, sKey, sVal + Dim sSec As String = "" + Dim sKey As String = "" + Dim sVal As Integer = 0 + LuaCheckParam(state, 1, sSec) + LuaCheckParam(state, 2, sKey) + LuaCheckParam(state, 3, sVal) + LuaClearStack(state) + Dim bResult As Boolean = WritePluginPrivateProfileString(sSec, sKey, sVal) + ' restituisco il risultato + LuaSetParam(state, bResult) + Return 1 + End Function + + 'Private Function Lua_PlgExecProcess(ByVal p As IntPtr) As Integer + ' Dim state = Lua.FromIntPtr(p) + ' Dim sDDFName As String = "" + ' LuaCheckParam(state, 1, sDDFName) + ' LuaClearStack(state) + ' If Map.refDoorListPageVM.ExecCAMProcess(sDDFName) Then + ' state.PushBoolean(True) + ' Return 1 + ' Else + ' Return 0 + ' End If + 'End Function + + 'Private Function Lua_PlgExecProcessAsync(ByVal p As IntPtr) As Integer + ' Dim state = Lua.FromIntPtr(p) + ' Dim sDDFName As String = "" + ' LuaCheckParam(state, 1, sDDFName) + ' LuaClearStack(state) + ' If Map.refDoorListPageVM.ExecCAMProcessAsync(sDDFName) Then + ' state.PushBoolean(True) + ' Return 1 + ' Else + ' Return 0 + ' End If + 'End Function + + 'Private Function Lua_PlgCheckExecProcessAsync(ByVal p As IntPtr) As Integer + ' Dim state = Lua.FromIntPtr(p) + ' LuaClearStack(state) + ' Dim bHasExited As Boolean = False + ' Dim nExitCode As Integer = -1 + ' If Map.refSupervisorFunction.PlgCheckExecProcessAsync(bHasExited, nExitCode) Then + ' state.PushBoolean(bHasExited) + ' state.PushInteger(nExitCode) + ' Return 2 + ' Else + ' Return 0 + ' End If + 'End Function + + Private Function Lua_PlgGetNextDoor(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + LuaClearStack(state) + Dim NextDoor As Door = Map.refDoorListPageVM.GetNextDoor() + If Not IsNothing(NextDoor) Then + Dim sPartProgramDirPath As String = "" + GetPluginPrivateProfileString(S_GENERAL, "PartProgramDir", "", sPartProgramDirPath) + ' restituisco il risultato + LuaSetParam(state, NextDoor.nId) + LuaSetParam(state, sPartProgramDirPath & "\" & NextDoor.sFileName) + Return 2 + End If + Return 0 + End Function + + 'Private Function Lua_PlgOpenRestartWnd(ByVal p As IntPtr) As Integer + ' Dim state = Lua.FromIntPtr(p) + ' LuaClearStack(state) + ' Dim RestartWnd As New RestartWndV(Application.Current.MainWindow, New RestartWndVM()) + ' RestartWnd.ShowDialog() + ' Return 0 + 'End Function + + Private Function Lua_PlgMessageWnd(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + Dim sMsg As String = "" + LuaCheckParam(state, 1, sMsg) + LuaClearStack(state) + MessageBox.Show(sMsg, "", MessageBoxButton.OK) + Return 0 + End Function + + Private Function Lua_PlgMachineReset(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + Dim nMachineIndex As Integer = 1 + LuaGetParam(state, 1, nMachineIndex) + LuaClearStack(state) + Map.refDoorListPageVM.ResetProductionQueue() + 'Map.refDoorListPageVM.ResetStateAfterReset() + Map.refDoorListPageVM.WriteBackup() + Return 0 + End Function + + Private Function Lua_PlgListReset(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + LuaClearStack(state) + If Map.refDoorListPageVM.bResetList Then + Map.refDoorListPageVM.ResetResetList() + state.PushBoolean(True) + Return 1 + Else + Return 0 + End If + End Function + + + Private Function Lua_PlgSetChangeState(ByVal p As IntPtr) As Integer + Dim state = Lua.FromIntPtr(p) + Dim nState As Integer = 0 + LuaGetParam(state, 1, nState) + LuaClearStack(state) + If nState = 1 Then + Dim CurrDoor As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nState = Door.PartProgramStates.SENT_TO_NC) + If Not IsNothing(CurrDoor) Then + Dim Now As DateTime = DateTime.Now + ' verifico se fine precedente impostata + Dim nIndex As Integer = Map.refDoorListPageVM.DoorList.IndexOf(CurrDoor) + If nIndex > 0 Then + Dim PrevDoor As Door = Map.refDoorListPageVM.DoorList(nIndex - 1) + If Not IsNothing(PrevDoor) AndAlso PrevDoor.nState = Door.PartProgramStates.MACHINE_START Then + PrevDoor.SetState(Door.PartProgramStates.PRODUCED) + PrevDoor.SetMachiningEnd(Now - TimeSpan.FromSeconds(1)) + End If + End If + CurrDoor.SetState(Door.PartProgramStates.MACHINE_START) + CurrDoor.SetMachiningStart(Now) + End If + ElseIf nState = 2 Then + Dim CurrDoor As Door = Map.refDoorListPageVM.DoorList.FirstOrDefault(Function(x) x.nState = Door.PartProgramStates.MACHINE_START) + If Not IsNothing(CurrDoor) Then + CurrDoor.SetState(Door.PartProgramStates.PRODUCED) + CurrDoor.SetMachiningEnd(DateTime.Now()) + End If + End If + Map.refDoorListPageVM.WriteBackup() + Return 0 + End Function + + Friend Function LuaInstallGeneral(state As Lua) As Boolean + If IsNothing(state) Then Return False + state.Register("PlgGetNumberFromIni", func_PlgGetNumberFromIni) + state.Register("PlgGetStringFromIni", func_PlgGetStringFromIni) + state.Register("PlgWriteStringToIni", func_PlgWriteStringToIni) + 'state.Register("PlgExecProcess", func_PlgExecProcess) + 'state.Register("PlgExecProcessAsync", func_PlgExecProcessAsync) + 'state.Register("PlgCheckExecProcessAsync", func_PlgCheckExecProcessAsync) + state.Register("PlgGetNextDoor", func_PlgGetNextDoor) + 'state.Register("PlgOpenRestartWnd", func_PlgOpenRestartWnd) + state.Register("PlgMessageWnd", func_PlgMessageWnd) + state.Register("PlgSetChangeState", func_PlgSetChangeState) + state.Register("PlgListReset", func_PlgListReset) + state.Register("PlgMachineReset", func_PlgMachineReset) + Return True + End Function + +End Module diff --git a/Effector.Plugin.StoneCut/MachinePage/MachinePageV.xaml b/Effector.Plugin.StoneCut/MachinePage/MachinePageV.xaml new file mode 100644 index 0000000..50de9be --- /dev/null +++ b/Effector.Plugin.StoneCut/MachinePage/MachinePageV.xaml @@ -0,0 +1,656 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +