Compare commits

...

2 Commits

36 changed files with 1110 additions and 144 deletions

View File

@ -20,6 +20,7 @@
<local:SubclassFilterConverter x:Key="SubclassFilterConverterosBuscarCoincidencias" <local:SubclassFilterConverter x:Key="SubclassFilterConverterosBuscarCoincidencias"
TargetType="{x:Type osExtraccion:osBuscarCoincidencias}" /> TargetType="{x:Type osExtraccion:osBuscarCoincidencias}" />
<local:SubclassFilterConverter x:Key="SubclassFilterConverterosVMMotor" TargetType="{x:Type os:osVMmotorSim}" /> <local:SubclassFilterConverter x:Key="SubclassFilterConverterosVMMotor" TargetType="{x:Type os:osVMmotorSim}" />
<local:UnsavedChangesConverter x:Key="UnsavedChangesConverter"/>
</Application.Resources> </Application.Resources>
</Application> </Application>

View File

@ -0,0 +1,668 @@
[
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Ingresos E0.0",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Ingresos Plate Group",
"Tag_extract": "E3.0\n",
"Collumn_name": "IO",
"Collumn_number": 2,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 1202
},
"Show_On_This_Page": false,
"Left": 2.0471327,
"Top": 8.451157,
"Ancho": 1.3239104,
"Alto": 0.19122289,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Ingresos Desc Italiano",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Ingresos Plate Group",
"Tag_extract": "MARCIA ASCIUGATORE\n",
"Collumn_name": "Description Italian",
"Collumn_number": 3,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 1203
},
"Show_On_This_Page": false,
"Left": 2.0339866,
"Top": 9.252491,
"Ancho": 1.3151709,
"Alto": 0.26124278,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Ingresos Desc English",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Ingresos Plate Group",
"Tag_extract": "EMERGENCY PRESSED\nELECTRICAL CABINET\n",
"Collumn_name": "Description English",
"Collumn_number": 4,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 1204
},
"Show_On_This_Page": false,
"Left": 2.0329113,
"Top": 9.509013,
"Ancho": 1.323141,
"Alto": 0.2408835,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Ingresos Card",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Ingresos Plate Group",
"Tag_extract": "A45311\n",
"Collumn_name": "Card",
"Collumn_number": 5,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 1260
},
"Show_On_This_Page": false,
"Left": 2.2931812,
"Top": 9.125617,
"Ancho": 0.3932013,
"Alto": 0.11076093,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Ingresos Pin",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Ingresos Plate Group",
"Tag_extract": "",
"Collumn_name": "Pin",
"Collumn_number": 7,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 1264
},
"Show_On_This_Page": false,
"Left": 2.6119895,
"Top": 8.204032,
"Ancho": 0.16785541,
"Alto": 0.15966734,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osBuscarCoincidencias, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Ingresos Plate Group",
"Search_rectangles": [
"200.6319122314453,815.1671752929688,137.59445190429688,161.43350219726562",
"350.22589111328125,815.4871215820312,137.59445190429688,161.43350219726562",
"499.9798583984375,815.4871215820312,137.59445190429688,161.43350219726562",
"649.7338256835938,815.4871215820312,137.59445190429688,161.43350219726562",
"799.6477661132812,815.4871215820312,137.59445190429688,161.43350219726562",
"949.2417602539062,815.4871215820312,137.59445190429688,161.43350219726562",
"1099.15576171875,815.4871215820312,137.59445190429688,161.43350219726562",
"1248.90966796875,815.4871215820312,137.59445190429688,161.43350219726562"
],
"Search_templates": false,
"Export_ocr": false,
"Opacity_oculto": 0.1,
"Show_debug_ocr": false,
"Threshold": 0.6,
"Coincidencias": 8,
"Id": {
"Value": 1201
},
"Show_On_This_Page": false,
"Left": 2.0069747,
"Top": 8.15955,
"Ancho": 1.3769451,
"Alto": 1.6148156,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Page",
"Extraer": false,
"New_Row": false,
"Tag_extract": "690\n",
"Collumn_name": "Extraccion Tags",
"Collumn_number": 1,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 1231
},
"Show_On_This_Page": false,
"Left": 13.666122,
"Top": 10.413534,
"Ancho": 0.81436056,
"Alto": 0.2296054,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png",
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Salidas A0.0",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Salidas Plate Group",
"Tag_extract": "E3.0\n",
"Collumn_name": "IO",
"Collumn_number": 2,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 63
},
"Show_On_This_Page": false,
"Left": 2.038601,
"Top": 2.4818933,
"Ancho": 1.3239104,
"Alto": 0.19122289,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Salidas Desc Italiano",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Salidas Plate Group",
"Tag_extract": "MARCIA ASCIUGATORE\n",
"Collumn_name": "Description Italian",
"Collumn_number": 3,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 64
},
"Show_On_This_Page": false,
"Left": 2.0427365,
"Top": 1.3802159,
"Ancho": 1.3151709,
"Alto": 0.26124278,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Salidas Desc English",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Salidas Plate Group",
"Tag_extract": "EMERGENCY PRESSED\nELECTRICAL CABINET\n",
"Collumn_name": "Description English",
"Collumn_number": 4,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 65
},
"Show_On_This_Page": false,
"Left": 2.0372825,
"Top": 1.6332868,
"Ancho": 1.323141,
"Alto": 0.2408835,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Salidas Card",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Salidas Plate Group",
"Tag_extract": "A45311\n",
"Collumn_name": "Card",
"Collumn_number": 5,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 66
},
"Show_On_This_Page": false,
"Left": 2.3019588,
"Top": 1.9661419,
"Ancho": 0.3932013,
"Alto": 0.11076093,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Salidas Pin",
"Extraer": false,
"New_Row": false,
"Id_Search_Templates": "Salidas Plate Group",
"Tag_extract": "",
"Collumn_name": "Pin",
"Collumn_number": 7,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 68
},
"Show_On_This_Page": false,
"Left": 2.613817,
"Top": 2.771892,
"Ancho": 0.16785541,
"Alto": 0.15966734,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osBuscarCoincidencias, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Salidas Plate Group",
"Search_rectangles": [
"200.471923828125,134.23458862304688,137.59445190429688,161.43350219726562",
"350.22589111328125,134.39459228515625,137.59445190429688,161.43350219726562",
"499.8198547363281,134.55458068847656,137.59445190429688,161.43350219726562",
"649.5738525390625,134.55458068847656,137.59445190429688,161.43350219726562",
"799.3278198242188,134.55458068847656,137.59445190429688,161.43350219726562",
"949.2417602539062,134.55458068847656,137.59445190429688,161.43350219726562",
"1098.9957275390625,134.55458068847656,137.59445190429688,161.43350219726562",
"1248.749755859375,134.55458068847656,137.59445190429688,161.43350219726562",
"1398.503662109375,134.87457275390625,137.59445190429688,161.43350219726562"
],
"Search_templates": false,
"Export_ocr": false,
"Opacity_oculto": 0.1,
"Show_debug_ocr": false,
"Threshold": 0.6,
"Coincidencias": 9,
"Id": {
"Value": 69
},
"Show_On_This_Page": false,
"Left": 2.0056293,
"Top": 1.3495445,
"Ancho": 1.3769451,
"Alto": 1.6148156,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Descrip Pagina",
"Extraer": false,
"New_Row": false,
"Tag_extract": "690\n",
"Collumn_name": "Descrip Pagina",
"Collumn_number": 1,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 70
},
"Show_On_This_Page": false,
"Left": 7.490359,
"Top": 10.734316,
"Ancho": 1.8668232,
"Alto": 0.17921503,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png",
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
},
{
"$type": "CtrEditor.ObjetosSim.Extraccion_Datos.osExtraccionTag, CtrEditor",
"AutoCreated": false,
"RemoverDesdeSimulacion": false,
"Nombre": "Comessa",
"Extraer": false,
"New_Row": false,
"Tag_extract": "690\n",
"Collumn_name": "Comessa",
"Collumn_number": 1,
"Copy_Number": 0,
"Show_Debug_Window": false,
"Opacity_oculto": 0.1,
"Id": {
"Value": 71
},
"Show_On_This_Page": false,
"Left": 11.119476,
"Top": 10.6297865,
"Ancho": 0.5749816,
"Alto": 0.14187858,
"Angulo": 0.0,
"Enable_On_All_Pages": true,
"ShowOnThisPagesList": [
"94102.80_SE00_Página_050.png",
"94102.80_SE00_Página_051.png",
"94102.80_SE00_Página_052.png",
"94102.80_SE00_Página_053.png",
"94102.80_SE00_Página_054.png",
"94102.80_SE00_Página_055.png",
"94102.80_SE00_Página_056.png",
"94102.80_SE00_Página_057.png",
"94102.80_SE00_Página_058.png",
"94102.80_SE00_Página_059.png",
"94102.80_SE00_Página_060.png",
"94102.80_SE00_Página_061.png",
"94102.80_SE00_Página_062.png",
"94102.80_SE00_Página_063.png",
"94102.80_SE00_Página_064.png",
"94102.80_SE00_Página_065.png",
"94102.80_SE00_Página_066.png",
"94102.80_SE00_Página_067.png",
"94102.80_SE00_Página_068.png",
"94102.80_SE00_Página_069.png",
"94102.80_SE00_Página_070.png",
"94102.80_SE00_Página_071.png",
"94102.80_SE00_Página_072.png",
"94102.80_SE00_Página_073.png",
"94102.80_SE00_Página_074.png",
"94102.80_SE00_Página_075.png"
],
"Cloned": false
}
]

View File

@ -0,0 +1,27 @@
using System.Windows.Data;
using System.Windows;
namespace CtrEditor
{
public class UnsavedChangesConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (value is string path)
{
var viewModel = Application.Current.MainWindow?.DataContext as MainViewModel;
if (viewModel?.HasUnsavedChanges == true)
{
return $"{path} *";
}
return path;
}
return string.Empty;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}

View File

@ -19,6 +19,8 @@ using ClosedXML.Excel;
using CtrEditor.PopUps; using CtrEditor.PopUps;
using System.Windows.Data; using System.Windows.Data;
using CommunityToolkit.Mvvm.Input; using CommunityToolkit.Mvvm.Input;
using System.Text.RegularExpressions;
using System.Collections.Specialized;
namespace CtrEditor namespace CtrEditor
@ -103,11 +105,20 @@ namespace CtrEditor
[ObservableProperty] [ObservableProperty]
private bool isSimulationRunning; private bool isSimulationRunning;
[ObservableProperty]
private bool hasUnsavedChanges;
partial void OnIsSimulationRunningChanged(bool value) partial void OnIsSimulationRunningChanged(bool value)
{ {
CommandManager.InvalidateRequerySuggested(); // Notificar que el estado de los comandos ha cambiado CommandManager.InvalidateRequerySuggested(); // Notificar que el estado de los comandos ha cambiado
} }
partial void OnHasUnsavedChangesChanged(bool value)
{
// Notificar el cambio del título indirectamente a través de directorioTrabajo
OnPropertyChanged(nameof(directorioTrabajo));
}
public string directorioTrabajo public string directorioTrabajo
{ {
get => EstadoPersistente.Instance.directorio; get => EstadoPersistente.Instance.directorio;
@ -185,12 +196,29 @@ namespace CtrEditor
{ {
if (value != null) if (value != null)
{ {
if (HasUnsavedChanges)
{
var result = MessageBox.Show("There are unsaved changes. Do you want to save them?",
"Save Changes",
MessageBoxButton.YesNoCancel);
if (result == MessageBoxResult.Cancel)
{
OnPropertyChanged(nameof(SelectedImage)); // Restore previous selection
return;
}
else if (result == MessageBoxResult.Yes)
{
SaveStateObjetosSimulables();
}
}
StopSimulation(); StopSimulation();
// SaveStateObjetosSimulables(); // Guarda el estado antes de cambiar la imagen ImageSelected?.Invoke(this, datosDeTrabajo.Imagenes[value]);
ImageSelected?.Invoke(this, datosDeTrabajo.Imagenes[value]); // Dispara el evento con la nueva ruta de imagen
LoadStateObjetosSimulables(); LoadStateObjetosSimulables();
EstadoPersistente.Instance.imagen = value; EstadoPersistente.Instance.imagen = value;
EstadoPersistente.Instance.GuardarEstado(); EstadoPersistente.Instance.GuardarEstado();
HasUnsavedChanges = false;
} }
} }
@ -246,7 +274,7 @@ namespace CtrEditor
PLCViewModel = new PLCViewModel(); PLCViewModel = new PLCViewModel();
_timerPLCUpdate = new DispatcherTimer(); _timerPLCUpdate = new DispatcherTimer();
_timerPLCUpdate.Interval = TimeSpan.FromMilliseconds(2); // ajusta el intervalo según sea necesario _timerPLCUpdate.Interval = TimeSpan.FromMilliseconds(50); // ajusta el intervalo según sea necesario
_timerPLCUpdate.Tick += OnRefreshEvent; _timerPLCUpdate.Tick += OnRefreshEvent;
InitializeTipoSimulableList(); InitializeTipoSimulableList();
@ -254,7 +282,7 @@ namespace CtrEditor
ItemDoubleClickCommand = new ParameterizedRelayCommand(ExecuteDoubleClick); ItemDoubleClickCommand = new ParameterizedRelayCommand(ExecuteDoubleClick);
_timerSimulacion = new DispatcherTimer(); _timerSimulacion = new DispatcherTimer();
_timerSimulacion.Interval = TimeSpan.FromMilliseconds(1); // ajusta el intervalo según sea necesario _timerSimulacion.Interval = TimeSpan.FromMilliseconds(10); // ajusta el intervalo según sea necesario
_timerSimulacion.Tick += OnTickSimulacion; _timerSimulacion.Tick += OnTickSimulacion;
StartSimulationCommand = new RelayCommand(StartSimulation); StartSimulationCommand = new RelayCommand(StartSimulation);
@ -280,6 +308,12 @@ namespace CtrEditor
stopwatch_Sim = new Stopwatch(); stopwatch_Sim = new Stopwatch();
stopwatch_Sim.Start(); stopwatch_Sim.Start();
ObjetosSimulables.CollectionChanged += (s, e) =>
{
if (e.Action != NotifyCollectionChangedAction.Move)
HasUnsavedChanges = true;
};
} }
private void OsListFilter_PropertyChanged(object? sender, PropertyChangedEventArgs e) private void OsListFilter_PropertyChanged(object? sender, PropertyChangedEventArgs e)
@ -328,8 +362,11 @@ namespace CtrEditor
if (NuevoOsBase != null) if (NuevoOsBase != null)
{ {
if (CrearUserControlDesdeObjetoSimulable(NuevoOsBase)) if (CrearUserControlDesdeObjetoSimulable(NuevoOsBase))
{
// Añadir el nuevo osBase a la colección de objetos simulables // Añadir el nuevo osBase a la colección de objetos simulables
ObjetosSimulables.Add(NuevoOsBase); ObjetosSimulables.Add(NuevoOsBase);
HasUnsavedChanges = true;
}
} }
return NuevoOsBase; return NuevoOsBase;
} }
@ -364,6 +401,7 @@ namespace CtrEditor
ObjetosSimulables.Remove(osObjeto); ObjetosSimulables.Remove(osObjeto);
if (osObjeto.VisualRepresentation != null) if (osObjeto.VisualRepresentation != null)
MainWindow.EliminarUserControlDelCanvas(osObjeto.VisualRepresentation); MainWindow.EliminarUserControlDelCanvas(osObjeto.VisualRepresentation);
HasUnsavedChanges = true;
} }
} }
@ -398,13 +436,16 @@ namespace CtrEditor
if (NuevoObjetoDuplicado != null) if (NuevoObjetoDuplicado != null)
{ {
NuevoObjetoDuplicado.Id.ObtenerNuevaID(); NuevoObjetoDuplicado.Id.ObtenerNuevaID();
string nombre = NuevoObjetoDuplicado.Nombre + "_" + NuevoObjetoDuplicado.Id.Value; string nombre = Regex.IsMatch(NuevoObjetoDuplicado.Nombre, @"_\d+$")
? Regex.Replace(NuevoObjetoDuplicado.Nombre, @"_\d+$", $"_{NuevoObjetoDuplicado.Id.Value}")
: NuevoObjetoDuplicado.Nombre + "_" + NuevoObjetoDuplicado.Id.Value;
NuevoObjetoDuplicado.Nombre = nombre; NuevoObjetoDuplicado.Nombre = nombre;
NuevoObjetoDuplicado.Left += OffsetX; NuevoObjetoDuplicado.Left += OffsetX;
NuevoObjetoDuplicado.Top += OffsetY; NuevoObjetoDuplicado.Top += OffsetY;
ObjetosSimulables.Add(NuevoObjetoDuplicado); ObjetosSimulables.Add(NuevoObjetoDuplicado);
CrearUserControlDesdeObjetoSimulable(NuevoObjetoDuplicado); CrearUserControlDesdeObjetoSimulable(NuevoObjetoDuplicado);
HasUnsavedChanges = true;
} }
} }
catch catch
@ -419,14 +460,27 @@ namespace CtrEditor
} }
private void EliminarUserControl() public void EliminarObjetoSeleccionado()
{ {
if (SelectedItemOsList is osBase objEliminar) if (SelectedItemOsList is osBase objEliminar)
{ {
RemoverObjetoSimulable(objEliminar); var result = MessageBox.Show($"¿Está seguro que desea eliminar el objeto '{objEliminar.Nombre}'?",
"Confirmar eliminación",
MessageBoxButton.YesNo,
MessageBoxImage.Question);
if (result == MessageBoxResult.Yes)
{
RemoverObjetoSimulable(objEliminar);
}
} }
} }
private void EliminarUserControl()
{
EliminarObjetoSeleccionado();
}
private void EliminarTodosCommand() private void EliminarTodosCommand()
{ {
@ -656,6 +710,7 @@ namespace CtrEditor
// Guarda el libro de Excel. // Guarda el libro de Excel.
workbook.SaveAs(filePath); workbook.SaveAs(filePath);
HasUnsavedChanges = false;
} }
catch (IOException ex) catch (IOException ex)
{ {
@ -724,6 +779,8 @@ namespace CtrEditor
private void OnTickSimulacion(object sender, EventArgs e) private void OnTickSimulacion(object sender, EventArgs e)
{ {
var stopwatch = Stopwatch.StartNew(); // Start measuring time
// Detener el cronómetro y obtener el tiempo transcurrido en milisegundos // Detener el cronómetro y obtener el tiempo transcurrido en milisegundos
var elapsedMilliseconds = stopwatch_Sim.Elapsed.TotalMilliseconds - stopwatch_SimModel_last; var elapsedMilliseconds = stopwatch_Sim.Elapsed.TotalMilliseconds - stopwatch_SimModel_last;
stopwatch_SimModel_last = stopwatch_Sim.Elapsed.TotalMilliseconds; stopwatch_SimModel_last = stopwatch_Sim.Elapsed.TotalMilliseconds;
@ -749,6 +806,8 @@ namespace CtrEditor
RemoverObjetoSimulable(objetoSimulable); RemoverObjetoSimulable(objetoSimulable);
} }
stopwatch.Stop(); // Stop measuring time
//Debug.WriteLine($"OnTickSimulacion execution time: {stopwatch.TotalMilliseconds} ms");
} }
private void ConnectPLC() private void ConnectPLC()
@ -768,19 +827,41 @@ namespace CtrEditor
} }
private List<osBase> objetosSimulablesLlamados = new List<osBase>();
private void OnRefreshEvent(object sender, EventArgs e) private void OnRefreshEvent(object sender, EventArgs e)
{ {
var stopwatch = Stopwatch.StartNew(); // Start measuring time
if (PLCViewModel.IsConnected) if (PLCViewModel.IsConnected)
{ {
// Detener el cronómetro y obtener el tiempo transcurrido en milisegundos // Detener el cronómetro y obtener el tiempo transcurrido en milisegundos
var elapsedMilliseconds = stopwatch_Sim.Elapsed.TotalMilliseconds - stopwatch_SimPLC_last; var elapsedMilliseconds = stopwatch_Sim.Elapsed.TotalMilliseconds - stopwatch_SimPLC_last;
stopwatch_SimPLC_last = stopwatch_Sim.Elapsed.TotalMilliseconds; stopwatch_SimPLC_last = stopwatch_Sim.Elapsed.TotalMilliseconds;
// Reiniciar el cronómetro para la próxima medición // Reiniciar el cronómetro para la próxima medición
foreach (var objetoSimulable in ObjetosSimulables) var remainingObjetosSimulables = ObjetosSimulables.Except(objetosSimulablesLlamados).ToList();
foreach (var objetoSimulable in remainingObjetosSimulables)
{
var objStopwatch = Stopwatch.StartNew();
objetoSimulable.UpdatePLC(PLCViewModel, (int)elapsedMilliseconds); objetoSimulable.UpdatePLC(PLCViewModel, (int)elapsedMilliseconds);
objStopwatch.Stop();
objetosSimulablesLlamados.Add(objetoSimulable);
if (stopwatch.Elapsed.TotalMilliseconds >= 10)
break;
}
if (remainingObjetosSimulables.Count == 0)
{
objetosSimulablesLlamados.Clear();
}
} }
stopwatch.Stop(); // Stop measuring time
Debug.WriteLine($"OnRefreshEvent: {stopwatch.Elapsed.TotalMilliseconds} ms");
} }
private void OpenWorkDirectory() private void OpenWorkDirectory()
@ -846,6 +927,8 @@ namespace CtrEditor
// Restaurar las propiedades originales de los objetos // Restaurar las propiedades originales de los objetos
foreach (var obj in ObjetosSimulables) foreach (var obj in ObjetosSimulables)
obj.RestaurarDatosNoSerializables(); obj.RestaurarDatosNoSerializables();
HasUnsavedChanges = false;
} }
} }
@ -955,7 +1038,17 @@ namespace CtrEditor
private void Exit() private void Exit()
{ {
Save(); if (HasUnsavedChanges)
{
var result = MessageBox.Show("There are unsaved changes. Do you want to save them?",
"Save Changes",
MessageBoxButton.YesNoCancel);
if (result == MessageBoxResult.Cancel)
return;
else if (result == MessageBoxResult.Yes)
SaveStateObjetosSimulables();
}
Application.Current.Shutdown(); Application.Current.Shutdown();
} }
} }

View File

@ -5,7 +5,7 @@
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:sys="clr-namespace:System;assembly=mscorlib" xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim" xmlns:ObjetosSim="clr-namespace:CtrEditor.ObjetosSim"
xmlns:ObjetosExtraccion="clr-namespace:CtrEditor.ObjetosSim.Extraccion_Datos" x:Class="CtrEditor.MainWindow" xmlns:ObjetosExtraccion="clr-namespace:CtrEditor.ObjetosSim.Extraccion_Datos" x:Class="CtrEditor.MainWindow"
Height="900" Width="1600" WindowState="Maximized" ResizeMode="CanResize" Title="{Binding directorioTrabajo}" Height="900" Width="1600" WindowState="Maximized" ResizeMode="CanResize" Title="{Binding directorioTrabajo, Converter={StaticResource UnsavedChangesConverter}}"
Icon="/app2.png"> Icon="/app2.png">
<Window.DataContext> <Window.DataContext>

View File

@ -49,7 +49,6 @@ namespace CtrEditor
private bool _isResizingUserControl = false; private bool _isResizingUserControl = false;
private bool _isDraggingUserControl = false; private bool _isDraggingUserControl = false;
private bool _isMovingUserControl = false; private bool _isMovingUserControl = false;
private double _initialAngleUserControl;
private TextBlock _angleDisplayTextBlock; private TextBlock _angleDisplayTextBlock;
public MainWindow() public MainWindow()
@ -66,7 +65,11 @@ namespace CtrEditor
ImagenEnTrabajoCanvas.MouseDown += Canvas_MouseDown_Panning; ImagenEnTrabajoCanvas.MouseDown += Canvas_MouseDown_Panning;
ImagenEnTrabajoCanvas.MouseMove += Canvas_MouseMove_Panning; ImagenEnTrabajoCanvas.MouseMove += Canvas_MouseMove_Panning;
ImagenEnTrabajoCanvas.MouseUp += Canvas_MouseUp_Panning; ImagenEnTrabajoCanvas.MouseUp += Canvas_MouseUp_Panning;
// Agregar el evento KeyDown a la ventana
this.KeyDown += MainWindow_KeyDown;
} }
private void MainWindow_Loaded(object sender, RoutedEventArgs e) private void MainWindow_Loaded(object sender, RoutedEventArgs e)
{ {
if (DataContext is MainViewModel viewModel) if (DataContext is MainViewModel viewModel)
@ -103,7 +106,7 @@ namespace CtrEditor
SuscribirEventos(userControl); SuscribirEventos(userControl);
// Añade el UserControl al Canvas // Añade el UserControl al Canvas
Canvas.SetZIndex(userControl, ((int)dataContainer.ZIndex())); Canvas.SetZIndex(userControl, ((int)dataContainer.ZIndex_Base() + dataContainer.zIndex_fromFrames));
ImagenEnTrabajoCanvas.Children.Add(userControl); ImagenEnTrabajoCanvas.Children.Add(userControl);
} }
} }
@ -156,7 +159,6 @@ namespace CtrEditor
rotateTransform = new RotateTransform(); rotateTransform = new RotateTransform();
userControl.RenderTransform = rotateTransform; userControl.RenderTransform = rotateTransform;
} }
_initialAngleUserControl = rotateTransform.Angle;
// Establecer el punto inicial de referencia para el cálculo de rotación // Establecer el punto inicial de referencia para el cálculo de rotación
_startPointUserControl = new Point(rotateTransform.CenterX, rotateTransform.CenterY); _startPointUserControl = new Point(rotateTransform.CenterX, rotateTransform.CenterY);
@ -227,11 +229,14 @@ namespace CtrEditor
private async void TimerCallbackRemoveResizeRectangles(object state) private async void TimerCallbackRemoveResizeRectangles(object state)
{ {
Application.Current.Dispatcher.Invoke(() => if (Application.Current != null)
{ {
// Realiza tus cambios en la interfaz de usuario aquí Application.Current.Dispatcher.Invoke(() =>
MakeResizeRectanglesTransparent(); {
}); // Realiza tus cambios en la interfaz de usuario aquí
MakeResizeRectanglesTransparent();
});
}
} }
public void PauseTimerRemoveResizeRectangles() public void PauseTimerRemoveResizeRectangles()
@ -396,14 +401,26 @@ namespace CtrEditor
private Point lastMousePosition; private Point lastMousePosition;
private void MarkUnsavedChanges()
{
if (DataContext is MainViewModel viewModel)
{
if (_isMovingUserControl || _isRotatingUserControl || _isResizingUserControl || _isDraggingUserControl)
{
viewModel.HasUnsavedChanges = true;
}
}
}
private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) private void UserControl_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
{ {
MarkUnsavedChanges();
if (_isResizingUserControl && resizeRectangles != null && resizeRectangles.Contains(sender)) if (_isResizingUserControl && resizeRectangles != null && resizeRectangles.Contains(sender))
{ {
_isResizingUserControl = false; _isResizingUserControl = false;
_isMovingUserControl = false; _isMovingUserControl = false;
((Rectangle)sender).ReleaseMouseCapture(); ((Rectangle)sender).ReleaseMouseCapture();
AddResizeRectangles(_currentDraggingControl); AddResizeRectangles(_currentDraggingControl);
} }
else if (_isMovingUserControl) else if (_isMovingUserControl)
{ {
@ -413,7 +430,8 @@ namespace CtrEditor
// _currentDraggingControl = null; // _currentDraggingControl = null;
AddResizeRectangles(_currentDraggingControl); AddResizeRectangles(_currentDraggingControl);
_isResizingUserControl = _isRotatingUserControl = _isDraggingUserControl = false; _isResizingUserControl = _isRotatingUserControl = _isDraggingUserControl = false;
_isMovingUserControl = false; _isMovingUserControl = false;
// Ocultar el TextBlock de ángulo // Ocultar el TextBlock de ángulo
if (_angleDisplayTextBlock != null) if (_angleDisplayTextBlock != null)
{ {
@ -711,7 +729,7 @@ namespace CtrEditor
private void ZoomTimer_Tick(object sender, EventArgs e) private void ZoomTimer_Tick(object sender, EventArgs e)
{ {
double elapsedMilliseconds = _stopwatch.ElapsedMilliseconds; double elapsedMilliseconds = _stopwatch.Elapsed.TotalMilliseconds;
if (elapsedMilliseconds >= _ZoomDuration) if (elapsedMilliseconds >= _ZoomDuration)
{ {
@ -805,6 +823,15 @@ namespace CtrEditor
} }
} }
private void MainWindow_KeyDown(object sender, KeyEventArgs e)
{
if (e.Key == Key.Delete && DataContext is MainViewModel viewModel)
{
viewModel.EliminarObjetoSeleccionado();
e.Handled = true;
}
}
} }
public class FloatValidationRule : ValidationRule public class FloatValidationRule : ValidationRule

View File

@ -36,6 +36,16 @@ namespace CtrEditor.ObjetosSim
set => SetProperty(ref nombre, value); set => SetProperty(ref nombre, value);
} }
[ObservableProperty]
[property: Description("Layer index to add to Objects on the Frame")]
[property: Category("Layer:")]
int zindex_FramePlate;
partial void OnZindex_FramePlateChanged(int value)
{
UpdateZIndex(value);
}
[ObservableProperty] [ObservableProperty]
Color color; Color color;
[ObservableProperty] [ObservableProperty]
@ -63,29 +73,59 @@ namespace CtrEditor.ObjetosSim
[property: Category("Encoders:")] [property: Category("Encoders:")]
public float offset_encoder_X; public float offset_encoder_X;
partial void OnK_encoder_XChanged(float value)
{
UpdatePosition();
}
partial void OnOffset_encoder_XChanged(float value)
{
UpdatePosition();
}
[JsonIgnore] [JsonIgnore]
private osEncoderMotorLineal EncoderX; private osEncoderMotorLineal EncoderX;
[JsonIgnore] [JsonIgnore]
private float EncoderXValue; private bool isUpdatingFromEncoderX = false;
partial void OnEncoder_XChanged(string value) partial void OnEncoder_XChanged(string value)
{ {
if (EncoderX != null)
EncoderX.PropertyChanged -= OnEncoderXPropertyChanged;
if (_mainViewModel != null && value != null && value.Length > 0) if (_mainViewModel != null && value != null && value.Length > 0)
{ {
EncoderX = (osEncoderMotorLineal)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osEncoderMotorLineal && s.Nombre == value), null); EncoderX = (osEncoderMotorLineal)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osEncoderMotorLineal && s.Nombre == value), null);
if (EncoderX != null)
EncoderX.PropertyChanged += OnEncoderXPropertyChanged;
} }
} }
public override void UpdateControl(int elapsedMilliseconds) private void OnEncoderXPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (!isUpdatingFromEncoderX)
{
isUpdatingFromEncoderX = true;
// Actualizamos el nombre si este fue modificado
if (e.PropertyName == nameof(osEncoderMotorLineal.Nombre))
Group_Panel = ((osEncoderMotorLineal)sender).Nombre;
if (e.PropertyName == nameof(osEncoderMotorLineal.Valor_Actual))
{
UpdatePosition();
}
isUpdatingFromEncoderX = false;
}
}
public void UpdatePosition()
{ {
if (EncoderX == null) if (EncoderX == null)
return; return;
if (K_encoder_X == 0) if (K_encoder_X == 0)
return; return;
if (EncoderXValue != EncoderX.Valor_Actual) Left = (EncoderX.Valor_Actual / k_encoder_X) + offset_encoder_X;
Left = (EncoderX.Valor_Actual / k_encoder_X) + offset_encoder_X;
EncoderXValue = EncoderX.Valor_Actual;
} }
public override void TopChanging(float oldValue, float newValue) public override void TopChanging(float oldValue, float newValue)
@ -104,6 +144,7 @@ namespace CtrEditor.ObjetosSim
Alto_Titulo = 0.2f; Alto_Titulo = 0.2f;
Color = Colors.WhiteSmoke; Color = Colors.WhiteSmoke;
Titulo = "Frame"; Titulo = "Frame";
Zindex_FramePlate = 0;
} }
public override void ucLoaded() public override void ucLoaded()
@ -111,6 +152,7 @@ namespace CtrEditor.ObjetosSim
base.ucLoaded(); base.ucLoaded();
// El UserControl se ha cargado // El UserControl se ha cargado
OnEncoder_XChanged(Encoder_X); OnEncoder_XChanged(Encoder_X);
UpdateZIndex(Zindex_FramePlate);
} }
public override void ucUnLoaded() public override void ucUnLoaded()
@ -125,6 +167,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucFramePlate : UserControl, IDataContainer public partial class ucFramePlate : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucFramePlate() public ucFramePlate()
{ {
@ -141,7 +184,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Decorativos; return ZIndexEnum.Decorativos;
} }

View File

@ -70,6 +70,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTextPlate : UserControl, IDataContainer public partial class ucTextPlate : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTextPlate() public ucTextPlate()
{ {
@ -86,7 +87,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Decorativos; return ZIndexEnum.Decorativos;
} }

View File

@ -168,6 +168,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucBotella : UserControl, IDataContainer public partial class ucBotella : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucBotella() public ucBotella()
{ {
@ -185,7 +186,7 @@ namespace CtrEditor.ObjetosSim
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Dinamicos; return ZIndexEnum.Dinamicos;
} }

View File

@ -154,6 +154,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucBotellaCuello : UserControl, IDataContainer public partial class ucBotellaCuello : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucBotellaCuello() public ucBotellaCuello()
{ {
@ -171,7 +172,7 @@ namespace CtrEditor.ObjetosSim
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Dinamicos; return ZIndexEnum.Dinamicos;
} }

View File

@ -194,6 +194,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucBottGenerator : UserControl, IDataContainer public partial class ucBottGenerator : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucBottGenerator() public ucBottGenerator()
{ {
@ -210,7 +211,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Generadores; return ZIndexEnum.Generadores;
} }

View File

@ -157,6 +157,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucFiller : UserControl, IDataContainer public partial class ucFiller : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucFiller() public ucFiller()
{ {
@ -181,7 +182,7 @@ namespace CtrEditor.ObjetosSim
} }
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Generadores; return ZIndexEnum.Generadores;
} }

View File

@ -89,6 +89,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTanque : UserControl, IDataContainer public partial class ucTanque : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTanque() public ucTanque()
{ {
@ -105,7 +106,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Generadores; return ZIndexEnum.Generadores;
} }

View File

@ -110,6 +110,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucDescarte : UserControl, IDataContainer public partial class ucDescarte : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucDescarte() public ucDescarte()
{ {
@ -131,7 +132,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Descarte; return ZIndexEnum.Descarte;
} }

View File

@ -80,6 +80,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucGuia : UserControl, IDataContainer public partial class ucGuia : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucGuia() public ucGuia()
{ {
@ -96,7 +97,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Guias; return ZIndexEnum.Guias;
} }

View File

@ -6,6 +6,7 @@ using LibS7Adv;
using CtrEditor.Simulacion; using CtrEditor.Simulacion;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using System.Text.Json.Serialization;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -66,23 +67,28 @@ namespace CtrEditor.ObjetosSim
[property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))] [property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))]
string id_Motor; string id_Motor;
[JsonIgnore]
private PropertyChangedEventHandler motorPropertyChangedHandler;
partial void OnId_MotorChanged(string value) partial void OnId_MotorChanged(string value)
{ {
if (Motor != null) if (Motor != null && motorPropertyChangedHandler != null)
Motor.PropertyChanged -= OnMotorPropertyChanged; Motor.PropertyChanged -= motorPropertyChangedHandler;
if (_mainViewModel != null && value != null && value.Length > 0)
{
Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osVMmotorSim && s.Nombre == value), null);
if (Motor != null)
Motor.PropertyChanged += OnMotorPropertyChanged;
}
}
private void OnMotorPropertyChanged(object sender, PropertyChangedEventArgs e) if (_mainViewModel != null && !string.IsNullOrEmpty(value))
{
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
{ {
Id_Motor = ((osVMmotorSim)sender).Nombre; Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => s is osVMmotorSim motor && motor.Nombre == value);
if (Motor != null)
{
motorPropertyChangedHandler = (sender, e) =>
{
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
{
Id_Motor = ((osVMmotorSim)sender).Nombre;
}
};
Motor.PropertyChanged += motorPropertyChangedHandler;
}
} }
} }
@ -172,6 +178,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTransporteCurva : UserControl, IDataContainer public partial class ucTransporteCurva : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTransporteCurva() public ucTransporteCurva()
{ {
@ -188,7 +195,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -7,6 +7,7 @@ using LibS7Adv;
using CtrEditor.Simulacion; using CtrEditor.Simulacion;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using System.Text.Json.Serialization;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -74,23 +75,28 @@ namespace CtrEditor.ObjetosSim
[property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))] [property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))]
string id_Motor; string id_Motor;
[JsonIgnore]
private PropertyChangedEventHandler motorPropertyChangedHandler;
partial void OnId_MotorChanged(string value) partial void OnId_MotorChanged(string value)
{ {
if (Motor != null) if (Motor != null && motorPropertyChangedHandler != null)
Motor.PropertyChanged -= OnMotorPropertyChanged; Motor.PropertyChanged -= motorPropertyChangedHandler;
if (_mainViewModel != null && value != null && value.Length > 0)
{
Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osVMmotorSim && s.Nombre == value), null);
if (Motor != null)
Motor.PropertyChanged += OnMotorPropertyChanged;
}
}
private void OnMotorPropertyChanged(object sender, PropertyChangedEventArgs e) if (_mainViewModel != null && !string.IsNullOrEmpty(value))
{
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
{ {
Id_Motor = ((osVMmotorSim)sender).Nombre; Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => s is osVMmotorSim motor && motor.Nombre == value);
if (Motor != null)
{
motorPropertyChangedHandler = (sender, e) =>
{
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
{
Id_Motor = ((osVMmotorSim)sender).Nombre;
}
};
Motor.PropertyChanged += motorPropertyChangedHandler;
}
} }
} }
@ -200,6 +206,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTransporteGuias : UserControl, IDataContainer public partial class ucTransporteGuias : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTransporteGuias() public ucTransporteGuias()
{ {
@ -216,7 +223,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -369,6 +369,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTransporteGuiasUnion : UserControl, IDataContainer public partial class ucTransporteGuiasUnion : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTransporteGuiasUnion() public ucTransporteGuiasUnion()
{ {
@ -385,7 +386,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -42,7 +42,7 @@
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}" Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}"
Fill="{StaticResource BeltBrush}"> Fill="{StaticResource BeltBrush}">
</Rectangle> </Rectangle>
<Viewbox Canvas.Top="{Binding AltoGuia, Converter={StaticResource MeterToPixelConverter}}" <Viewbox
Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}" Width="{Binding Ancho, Converter={StaticResource MeterToPixelConverter}}"
Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}" Stretch="Uniform"> Height="{Binding Alto, Converter={StaticResource MeterToPixelConverter}}" Stretch="Uniform">
<Label Content="{Binding Nombre}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold" <Label Content="{Binding Nombre}" VerticalAlignment="Center" HorizontalAlignment="Center" FontWeight="Bold"

View File

@ -6,6 +6,7 @@ using CtrEditor.Simulacion;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using System.ComponentModel; using System.ComponentModel;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using System.Text.Json.Serialization;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -71,27 +72,32 @@ namespace CtrEditor.ObjetosSim
[property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))] [property: ItemsSource(typeof(osBaseItemsSource<osVMmotorSim>))]
string id_Motor; string id_Motor;
[JsonIgnore]
private PropertyChangedEventHandler motorPropertyChangedHandler;
partial void OnId_MotorChanged(string value) partial void OnId_MotorChanged(string value)
{ {
if (Motor != null) if (Motor != null && motorPropertyChangedHandler != null)
Motor.PropertyChanged -= OnMotorPropertyChanged; Motor.PropertyChanged -= motorPropertyChangedHandler;
if (_mainViewModel != null && value != null && value.Length > 0)
if (_mainViewModel != null && !string.IsNullOrEmpty(value))
{ {
Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osVMmotorSim && s.Nombre == value), null); Motor = (osVMmotorSim)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => s is osVMmotorSim motor && motor.Nombre == value);
if (Motor != null) if (Motor != null)
Motor.PropertyChanged += OnMotorPropertyChanged; {
motorPropertyChangedHandler = (sender, e) =>
{
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
{
Id_Motor = ((osVMmotorSim)sender).Nombre;
}
};
Motor.PropertyChanged += motorPropertyChangedHandler;
}
} }
} }
private void OnMotorPropertyChanged(object sender, PropertyChangedEventArgs e)
{
if (e.PropertyName == nameof(osVMmotorSim.Nombre))
{
Id_Motor = ((osVMmotorSim)sender).Nombre;
}
}
[ObservableProperty] [ObservableProperty]
[property: Category("Setup:")] [property: Category("Setup:")]
public float frictionCoefficient; public float frictionCoefficient;
@ -170,6 +176,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTransporteTTop : UserControl, IDataContainer public partial class ucTransporteTTop : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTransporteTTop() public ucTransporteTTop()
{ {
@ -186,7 +193,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -3,6 +3,7 @@ using CommunityToolkit.Mvvm.ComponentModel;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using LibS7Adv; using LibS7Adv;
using Newtonsoft.Json; using Newtonsoft.Json;
using System.Diagnostics;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Media; using System.Windows.Media;
@ -44,6 +45,9 @@ namespace CtrEditor.ObjetosSim
Tamano += Delta_Width + Delta_Height; Tamano += Delta_Width + Delta_Height;
} }
[ObservableProperty]
public float refresh_Time_ms;
[ObservableProperty] [ObservableProperty]
public float proporcional_Speed; public float proporcional_Speed;
@ -106,6 +110,7 @@ namespace CtrEditor.ObjetosSim
Max_Speed_for_Ramp = 100; Max_Speed_for_Ramp = 100;
TiempoRampa = 3; TiempoRampa = 3;
ImageSource_oculta = ImageFromPath("/imagenes/motor2.png"); ImageSource_oculta = ImageFromPath("/imagenes/motor2.png");
Refresh_Time_ms = 500;
} }
public override void UpdateGeometryStart() public override void UpdateGeometryStart()
@ -113,17 +118,36 @@ namespace CtrEditor.ObjetosSim
// Se llama antes de la simulacion // Se llama antes de la simulacion
} }
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
[JsonIgnore]
private float elapsedTimeAccumulator = 0;
public override void UpdatePLC(PLCViewModel plc, int TotalMilliseconds)
{ {
motState.UpdatePLC(plc, this, elapsedMilliseconds); Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
elapsedTimeAccumulator += TotalMilliseconds;
float randomFactor = (float)(new Random().NextDouble() * 0.1); // 10% random factor
float adjustedRefreshTime = Refresh_Time_ms * (1 + randomFactor);
if (elapsedTimeAccumulator >= adjustedRefreshTime)
{
motState.UpdatePLC(plc, this, TotalMilliseconds);
elapsedTimeAccumulator = 0;
}
Velocidad = (Proporcional_Speed / 100) * (motState.STATUS_VFD_ACT_Speed_Hz / 10); Velocidad = (Proporcional_Speed / 100) * (motState.STATUS_VFD_ACT_Speed_Hz / 10);
Sentido_contrario = motState.OUT_Reversal; Sentido_contrario = motState.OUT_Reversal;
stopwatch.Stop();
Debug.WriteLine($" osVMmotorSim : {Nombre} : {stopwatch.Elapsed.TotalMilliseconds} ms");
} }
public override void UpdateControl(int elapsedMilliseconds) public override void UpdateControl(int TotalMilliseconds)
{ {
// Calculamos la velocidad // Calculamos la velocidad
motState.UpdateSpeed(Max_Speed_for_Ramp, TiempoRampa, elapsedMilliseconds); motState.UpdateSpeed(Max_Speed_for_Ramp, TiempoRampa, TotalMilliseconds);
} }
@ -140,6 +164,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucVMmotorSim : UserControl, IDataContainer public partial class ucVMmotorSim : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucVMmotorSim() public ucVMmotorSim()
{ {
@ -156,7 +181,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }
@ -176,7 +201,7 @@ namespace CtrEditor.ObjetosSim
public bool OUT_Reversal; public bool OUT_Reversal;
public float OUT_OUT_VFD_REQ_Speed_Hz; public float OUT_OUT_VFD_REQ_Speed_Hz;
public void UpdatePLC(PLCViewModel plc, osVMmotorSim Data, int elapsedMilliseconds) public void UpdatePLC(PLCViewModel plc, osVMmotorSim Data, int TotalMilliseconds)
{ {
var DB_Motor = Data.PLC_DB_Motor; var DB_Motor = Data.PLC_DB_Motor;
@ -220,9 +245,9 @@ namespace CtrEditor.ObjetosSim
} }
private float CalcSpeedRamp(float max_Speed_for_Ramp, float TiempoRampa, float actual, float expected, int elapsedMilliseconds) private float CalcSpeedRamp(float max_Speed_for_Ramp, float TiempoRampa, float actual, float expected, int TotalMilliseconds)
{ {
float hzIncrementsRamp = (max_Speed_for_Ramp * 10) / (TiempoRampa * (1000.0f / elapsedMilliseconds)); float hzIncrementsRamp = (max_Speed_for_Ramp * 10) / (TiempoRampa * (1000.0f / TotalMilliseconds));
float delta = expected - actual; float delta = expected - actual;
// Conrtolar si la diferencia no es mayor de lo que falta // Conrtolar si la diferencia no es mayor de lo que falta
if (Math.Abs(hzIncrementsRamp) > Math.Abs(delta)) if (Math.Abs(hzIncrementsRamp) > Math.Abs(delta))
@ -233,12 +258,14 @@ namespace CtrEditor.ObjetosSim
return hzIncrementsRamp; return hzIncrementsRamp;
} }
public void UpdateSpeed(float max_Speed_for_Ramp, float TiempoRampa, int elapsedMilliseconds) public void UpdateSpeed(float max_Speed_for_Ramp, float TiempoRampa, int TotalMilliseconds)
{ {
// Calculamos la velocidad // Calculamos la velocidad
STATUS_VFD_ACT_Speed_Hz += CalcSpeedRamp(max_Speed_for_Ramp, TiempoRampa, STATUS_VFD_ACT_Speed_Hz, OUT_OUT_VFD_REQ_Speed_Hz, elapsedMilliseconds); STATUS_VFD_ACT_Speed_Hz += CalcSpeedRamp(max_Speed_for_Ramp, TiempoRampa, STATUS_VFD_ACT_Speed_Hz, OUT_OUT_VFD_REQ_Speed_Hz, TotalMilliseconds);
} }
} }
} }

View File

@ -19,6 +19,10 @@ using System.ComponentModel;
using ClosedXML.Excel; using ClosedXML.Excel;
using Colors = System.Windows.Media.Colors; using Colors = System.Windows.Media.Colors;
using CtrEditor.FuncionesBase; using CtrEditor.FuncionesBase;
using System.Drawing;
using System.Windows.Shapes;
using System.Drawing.Imaging;
using Emgu.CV.Structure;
namespace CtrEditor.ObjetosSim.Extraccion_Datos namespace CtrEditor.ObjetosSim.Extraccion_Datos
{ {
@ -373,6 +377,10 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
// Método para convertir BitmapSource a Mat // Método para convertir BitmapSource a Mat
private Mat BitmapSourceToMat(BitmapSource bitmapSource) private Mat BitmapSourceToMat(BitmapSource bitmapSource)
{ {
if (bitmapSource == null)
throw new ArgumentNullException(nameof(bitmapSource));
// Convierte BitmapSource a Bitmap
Bitmap bitmap; Bitmap bitmap;
using (MemoryStream outStream = new MemoryStream()) using (MemoryStream outStream = new MemoryStream())
{ {
@ -381,7 +389,10 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
enc.Save(outStream); enc.Save(outStream);
bitmap = new Bitmap(outStream); bitmap = new Bitmap(outStream);
} }
return bitmap.ToMat();
// Convierte directamente a Mat usando Image<Bgr, byte>
Image<Bgr, byte> image = bitmap.ToImage<Bgr, byte>();
return image.Mat;
} }
public override void ucLoaded() public override void ucLoaded()
@ -397,6 +408,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
public partial class ucBuscarCoincidencias : UserControl, IDataContainer public partial class ucBuscarCoincidencias : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucBuscarCoincidencias() public ucBuscarCoincidencias()
{ {
@ -413,7 +425,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -175,6 +175,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
public partial class ucExtraccionTag : UserControl, IDataContainer public partial class ucExtraccionTag : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucExtraccionTag() public ucExtraccionTag()
{ {
@ -220,7 +221,7 @@ namespace CtrEditor.ObjetosSim.Extraccion_Datos
datos.Angulo += Angle; datos.Angulo += Angle;
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.ExtraccionTag; return ZIndexEnum.ExtraccionTag;
} }

View File

@ -143,6 +143,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucBoton : UserControl, IDataContainer public partial class ucBoton : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucBoton() public ucBoton()
{ {
@ -183,7 +184,7 @@ namespace CtrEditor.ObjetosSim
} }
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -132,6 +132,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucEncoderMotor : UserControl, IDataContainer public partial class ucEncoderMotor : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucEncoderMotor() public ucEncoderMotor()
{ {
@ -152,7 +153,7 @@ namespace CtrEditor.ObjetosSim
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -124,6 +124,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucEncoderMotorLineal : UserControl, IDataContainer public partial class ucEncoderMotorLineal : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucEncoderMotorLineal() public ucEncoderMotorLineal()
{ {
@ -144,7 +145,7 @@ namespace CtrEditor.ObjetosSim
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -43,8 +43,8 @@ namespace CtrEditor.ObjetosSim
{ {
if (value) if (value)
{ {
var dTime = Stopwatch.ElapsedMilliseconds - stopwatch_last; var dTime = Stopwatch.Elapsed.TotalMilliseconds - stopwatch_last;
stopwatch_last = Stopwatch.ElapsedMilliseconds; stopwatch_last = Stopwatch.Elapsed.TotalMilliseconds;
Tiempo_Pulso = (float)dTime; Tiempo_Pulso = (float)dTime;
} }
@ -146,25 +146,7 @@ namespace CtrEditor.ObjetosSim
} }
public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds) public override void UpdatePLC(PLCViewModel plc, int elapsedMilliseconds)
{ {
if (Motor != null)
{
if (Motor is osVMmotorSim motor)
{
VelocidadActual = motor.Velocidad;
// Calcular la cantidad de giros por segundo
double girosPorSegundo = (VelocidadActual / 100.0) * Giros_segundo_a_100;
// Calcular la fracción del segundo que ha pasado
double segundosTranscurridos = elapsedMilliseconds / 1000.0;
// Calcular el incremento de ángulo
double incrementoAngulo = (girosPorSegundo * 360.0) * segundosTranscurridos;
// Actualizar el ángulo
Angulo = (float) (Angulo + incrementoAngulo) % 360;
}
}
} }
public bool DetectarDiente() public bool DetectarDiente()
@ -207,7 +189,28 @@ namespace CtrEditor.ObjetosSim
public override void UpdateControl(int elapsedMilliseconds) public override void UpdateControl(int elapsedMilliseconds)
{ {
// Calculamos la velocidad // Calculamos la velocidad
if (Motor != null)
{
if (Motor is osVMmotorSim motor)
{
if (motor.Sentido_contrario)
VelocidadActual = -motor.Velocidad;
else
VelocidadActual = motor.Velocidad;
// Calcular la cantidad de giros por segundo
double girosPorSegundo = (VelocidadActual / 100.0) * Giros_segundo_a_100;
// Calcular la fracción del segundo que ha pasado
double segundosTranscurridos = elapsedMilliseconds / 1000.0;
// Calcular el incremento de ángulo
double incrementoAngulo = (girosPorSegundo * 360.0) * segundosTranscurridos;
// Actualizar el ángulo
Angulo = (float)(Angulo + incrementoAngulo) % 360;
}
}
} }
public override void ucLoaded() public override void ucLoaded()
@ -222,6 +225,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucGearEncoder : UserControl, IDataContainer public partial class ucGearEncoder : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucGearEncoder() public ucGearEncoder()
{ {
@ -238,7 +242,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -61,12 +61,12 @@ namespace CtrEditor.ObjetosSim
} }
if (!value) { if (!value) {
Lenght_positive_pulse = (float) (timer.ElapsedMilliseconds- timer_lastPositive); Lenght_positive_pulse = (float) (timer.Elapsed.TotalMilliseconds - timer_lastPositive);
timer_lastNegative = timer.ElapsedMilliseconds; timer_lastNegative = timer.Elapsed.TotalMilliseconds;
} else } else
{ {
Lenght_negative_pulse = (float)(timer.ElapsedMilliseconds - timer_lastNegative); Lenght_negative_pulse = (float)(timer.Elapsed.TotalMilliseconds - timer_lastNegative);
timer_lastPositive = timer.ElapsedMilliseconds; timer_lastPositive = timer.Elapsed.TotalMilliseconds;
Lenght_FP_to_FP = Lenght_positive_pulse + Lenght_negative_pulse; Lenght_FP_to_FP = Lenght_positive_pulse + Lenght_negative_pulse;
Frecuency = (Frecuency * (filter_Frecuency - 1) + (1000 / Lenght_FP_to_FP)) / filter_Frecuency; Frecuency = (Frecuency * (filter_Frecuency - 1) + (1000 / Lenght_FP_to_FP)) / filter_Frecuency;
} }
@ -223,6 +223,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucPhotocell : UserControl, IDataContainer public partial class ucPhotocell : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucPhotocell() public ucPhotocell()
{ {
@ -239,7 +240,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Fotocelula; return ZIndexEnum.Fotocelula;
} }

View File

@ -72,6 +72,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucSensTemperatura : UserControl, IDataContainer public partial class ucSensTemperatura : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucSensTemperatura() public ucSensTemperatura()
{ {
@ -88,7 +89,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -109,6 +109,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucAnalogTag : UserControl, IDataContainer public partial class ucAnalogTag : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucAnalogTag() public ucAnalogTag()
{ {
@ -125,7 +126,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -89,6 +89,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucBoolTag : UserControl, IDataContainer public partial class ucBoolTag : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucBoolTag() public ucBoolTag()
{ {
@ -105,7 +106,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -53,6 +53,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucConsensGeneric : UserControl, IDataContainer public partial class ucConsensGeneric : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucConsensGeneric() public ucConsensGeneric()
{ {
@ -69,7 +70,7 @@ namespace CtrEditor.ObjetosSim
Datos?.ucUnLoaded(); Datos?.ucUnLoaded();
} }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Estaticos; return ZIndexEnum.Estaticos;
} }

View File

@ -263,6 +263,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTrace3 : UserControl, IDataContainer public partial class ucTrace3 : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTrace3() public ucTrace3()
{ {
@ -295,7 +296,7 @@ namespace CtrEditor.ObjetosSim
} }
public float Angle() { return 0; } public void Rotate(float Angle) { } public float Angle() { return 0; } public void Rotate(float Angle) { }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Trace; return ZIndexEnum.Trace;
} }

View File

@ -96,7 +96,7 @@ namespace CtrEditor.ObjetosSim
} }
if (data.Count > 50) if (data.Count > 50)
data.RemoveAt(0); data.RemoveAt(0);
if (stopwatch.ElapsedMilliseconds > 1000) if (stopwatch.Elapsed.TotalMilliseconds > 1000)
{ {
stopwatch.Reset(); stopwatch.Reset();
stopwatch.Start(); stopwatch.Start();
@ -128,6 +128,7 @@ namespace CtrEditor.ObjetosSim
public partial class ucTraceSimple : UserControl, IDataContainer public partial class ucTraceSimple : UserControl, IDataContainer
{ {
public osBase? Datos { get; set; } public osBase? Datos { get; set; }
public int zIndex_fromFrames { get; set; }
public ucTraceSimple() public ucTraceSimple()
{ {
@ -160,7 +161,7 @@ namespace CtrEditor.ObjetosSim
} }
public float Angle() { return 0; } public void Rotate(float Angle) { } public float Angle() { return 0; } public void Rotate(float Angle) { }
public void Highlight(bool State) { } public void Highlight(bool State) { }
public ZIndexEnum ZIndex() public ZIndexEnum ZIndex_Base()
{ {
return ZIndexEnum.Trace; return ZIndexEnum.Trace;
} }

View File

@ -9,14 +9,17 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Windows; using System.Windows;
using System.Windows.Controls; using System.Windows.Controls;
using System.Windows.Forms;
using System.Windows.Media; using System.Windows.Media;
using System.Windows.Media.Animation; using System.Windows.Media.Animation;
using System.Windows.Media.Imaging; using System.Windows.Media.Imaging;
using System.Windows.Shapes; using System.Windows.Shapes;
using Tesseract; using Tesseract;
using Xceed.Wpf.Toolkit.PropertyGrid.Attributes; using Xceed.Wpf.Toolkit.PropertyGrid.Attributes;
using Application = System.Windows.Application;
using ItemCollection = Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemCollection; using ItemCollection = Xceed.Wpf.Toolkit.PropertyGrid.Attributes.ItemCollection;
using JsonIgnoreAttribute = Newtonsoft.Json.JsonIgnoreAttribute; using JsonIgnoreAttribute = Newtonsoft.Json.JsonIgnoreAttribute;
using UserControl = System.Windows.Controls.UserControl;
namespace CtrEditor.ObjetosSim namespace CtrEditor.ObjetosSim
{ {
@ -30,8 +33,9 @@ namespace CtrEditor.ObjetosSim
{ {
[JsonIgnore] [JsonIgnore]
osBase? Datos { get; set; } osBase? Datos { get; set; }
int zIndex_fromFrames { get; set; }
void Highlight(bool State); void Highlight(bool State);
ZIndexEnum ZIndex(); ZIndexEnum ZIndex_Base();
} }
public class DataSaveToSerialize public class DataSaveToSerialize
@ -60,19 +64,6 @@ namespace CtrEditor.ObjetosSim
{ {
public virtual string Nombre { get; set; } = "osBase"; public virtual string Nombre { get; set; } = "osBase";
public osBase()
{
if (float.IsNaN(Left))
{
Left = 0;
}
if (float.IsNaN(Top))
{
Top = 0;
}
}
[JsonIgnore] [JsonIgnore]
private Storyboard _storyboard; private Storyboard _storyboard;
[JsonIgnore] [JsonIgnore]
@ -287,7 +278,19 @@ namespace CtrEditor.ObjetosSim
{ {
FramePlate = (osFramePlate)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osFramePlate && s.Nombre == value), null); FramePlate = (osFramePlate)_mainViewModel.ObjetosSimulables.FirstOrDefault(s => (s is osFramePlate && s.Nombre == value), null);
if (FramePlate != null) if (FramePlate != null)
{
FramePlate.PropertyChanged += OnFramePlatePropertyChanged; FramePlate.PropertyChanged += OnFramePlatePropertyChanged;
UpdateZIndex(FramePlate.Zindex_FramePlate);
}
}
}
protected void UpdateZIndex(int zIndex)
{
if (_visualRepresentation is IDataContainer dataContainer)
{
dataContainer.zIndex_fromFrames = zIndex;
Canvas.SetZIndex(_visualRepresentation, zIndex + ((int)dataContainer.ZIndex_Base()));
} }
} }
@ -312,6 +315,9 @@ namespace CtrEditor.ObjetosSim
OnMoveResizeRotate(); OnMoveResizeRotate();
} }
if (e.PropertyName == nameof(osFramePlate.Zindex_FramePlate))
UpdateZIndex(((osFramePlate)sender).Zindex_FramePlate);
isUpdatingFromFramePlate = false; isUpdatingFromFramePlate = false;
} }
} }
@ -1025,6 +1031,23 @@ namespace CtrEditor.ObjetosSim
} }
} }
protected override void OnPropertyChanged(PropertyChangedEventArgs e)
{
base.OnPropertyChanged(e);
// Don't mark changes for certain properties
if (e.PropertyName != nameof(Top) &&
e.PropertyName != nameof(Left) &&
e.PropertyName != nameof(Ancho) &&
e.PropertyName != nameof(Angulo) &&
Cloned == false &&
e.PropertyName != nameof(Show_On_This_Page) &&
_mainViewModel != null)
{
_mainViewModel.HasUnsavedChanges = true;
}
}
} }
public class UniqueId public class UniqueId
@ -1156,9 +1179,9 @@ namespace CtrEditor.ObjetosSim
public bool SenalFiltrada() public bool SenalFiltrada()
{ {
if (_stopwatch_ON.ElapsedMilliseconds > (Tiempo_ON_s * 1000)) if (_stopwatch_ON.Elapsed.TotalMilliseconds > (Tiempo_ON_s * 1000))
_senalFiltrada = true; _senalFiltrada = true;
if (_stopwatch_OFF.ElapsedMilliseconds > (Tiempo_OFF_s * 1000)) if (_stopwatch_OFF.Elapsed.TotalMilliseconds > (Tiempo_OFF_s * 1000))
_senalFiltrada = false; _senalFiltrada = false;
return _senalFiltrada; return _senalFiltrada;