From 7949ec25c9cea761516dd7969daf74f86d5a3a3a Mon Sep 17 00:00:00 2001 From: 17860779768 <3219079380@qq.com> Date: Fri, 3 Mar 2023 12:10:50 +0800 Subject: [PATCH] Change1 --- .gitattributes | 63 - A020.sln | 21 + Config.json | 1 + src/BRS.Common.Model/Helper/EnumHelper.cs | 18 + src/BRS.Process.A020/A020Process_Operation.cs | 1385 +++-------------- src/BRS.Process.A020/BRS.Process.A020.csproj | 12 + src/BRS.Process.A020/UI/CircleButton.cs | 24 + .../UI/ContorlShaft.Designer.cs | 247 +++ src/BRS.Process.A020/UI/ContorlShaft.cs | 62 + src/BRS.Process.A020/UI/ContorlShaft.resx | 120 ++ .../UI/ControlSet.Designer.cs | 352 ++--- src/BRS.Process.A020/UI/ControlSet.cs | 39 +- src/BRS.Process.A020/UI/OperationFrm.resx | 2 +- src/BRS.UI.Device.Winform/CtrlPLCRunBase.cs | 29 +- src/BRS.UI.Main/MenuForms/FrmOperation.resx | 4 +- src/XKRS.Device.MelsecPLC/App.config | 22 + src/XKRS.Device.MelsecPLC/MelsecPLCConfig.cs | 70 + src/XKRS.Device.MelsecPLC/MelsecPLCDriver.cs | 424 +++++ src/XKRS.Device.MelsecPLC/Program.cs | 15 + .../Properties/AssemblyInfo.cs | 36 + .../Properties/Settings.Designer.cs | 26 + .../Properties/Settings.settings | 6 + .../XKRS.Device.MelsecPLC.csproj | 92 ++ src/XKRS.Device.MelsecPLC/packages.config | 5 + 24 files changed, 1616 insertions(+), 1459 deletions(-) delete mode 100644 .gitattributes create mode 100644 Config.json create mode 100644 src/BRS.Process.A020/UI/CircleButton.cs create mode 100644 src/BRS.Process.A020/UI/ContorlShaft.Designer.cs create mode 100644 src/BRS.Process.A020/UI/ContorlShaft.cs create mode 100644 src/BRS.Process.A020/UI/ContorlShaft.resx create mode 100644 src/XKRS.Device.MelsecPLC/App.config create mode 100644 src/XKRS.Device.MelsecPLC/MelsecPLCConfig.cs create mode 100644 src/XKRS.Device.MelsecPLC/MelsecPLCDriver.cs create mode 100644 src/XKRS.Device.MelsecPLC/Program.cs create mode 100644 src/XKRS.Device.MelsecPLC/Properties/AssemblyInfo.cs create mode 100644 src/XKRS.Device.MelsecPLC/Properties/Settings.Designer.cs create mode 100644 src/XKRS.Device.MelsecPLC/Properties/Settings.settings create mode 100644 src/XKRS.Device.MelsecPLC/XKRS.Device.MelsecPLC.csproj create mode 100644 src/XKRS.Device.MelsecPLC/packages.config diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 1ff0c42..0000000 --- a/.gitattributes +++ /dev/null @@ -1,63 +0,0 @@ -############################################################################### -# Set default behavior to automatically normalize line endings. -############################################################################### -* text=auto - -############################################################################### -# Set default behavior for command prompt diff. -# -# This is need for earlier builds of msysgit that does not have it on by -# default for csharp files. -# Note: This is only used by command line -############################################################################### -#*.cs diff=csharp - -############################################################################### -# Set the merge driver for project and solution files -# -# Merging from the command prompt will add diff markers to the files if there -# are conflicts (Merging from VS is not affected by the settings below, in VS -# the diff markers are never inserted). Diff markers may cause the following -# file extensions to fail to load in VS. An alternative would be to treat -# these files as binary and thus will always conflict and require user -# intervention with every merge. To do so, just uncomment the entries below -############################################################################### -#*.sln merge=binary -#*.csproj merge=binary -#*.vbproj merge=binary -#*.vcxproj merge=binary -#*.vcproj merge=binary -#*.dbproj merge=binary -#*.fsproj merge=binary -#*.lsproj merge=binary -#*.wixproj merge=binary -#*.modelproj merge=binary -#*.sqlproj merge=binary -#*.wwaproj merge=binary - -############################################################################### -# behavior for image files -# -# image files are treated as binary by default. -############################################################################### -#*.jpg binary -#*.png binary -#*.gif binary - -############################################################################### -# diff behavior for common document formats -# -# Convert binary document formats to text before diffing them. This feature -# is only available from the command line. Turn it on by uncommenting the -# entries below. -############################################################################### -#*.doc diff=astextplain -#*.DOC diff=astextplain -#*.docx diff=astextplain -#*.DOCX diff=astextplain -#*.dot diff=astextplain -#*.DOT diff=astextplain -#*.pdf diff=astextplain -#*.PDF diff=astextplain -#*.rtf diff=astextplain -#*.RTF diff=astextplain diff --git a/A020.sln b/A020.sln index 038f807..224d38b 100644 --- a/A020.sln +++ b/A020.sln @@ -34,6 +34,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BRS.Device.OmronPLC", "src\ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XKRS.Device.NbtRobot", "src\BRS.Device.NbtRobot\XKRS.Device.NbtRobot.csproj", "{8FA74161-0D03-408F-811A-A244C9027BFB}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XKRS.Device.MelsecPLC", "src\XKRS.Device.MelsecPLC\XKRS.Device.MelsecPLC.csproj", "{887F9454-B1F3-47B8-B9F7-48BEBA47193D}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -209,6 +211,24 @@ Global {8FA74161-0D03-408F-811A-A244C9027BFB}.Release|x64.Build.0 = Release|Any CPU {8FA74161-0D03-408F-811A-A244C9027BFB}.Release|x86.ActiveCfg = Release|Any CPU {8FA74161-0D03-408F-811A-A244C9027BFB}.Release|x86.Build.0 = Release|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug|Any CPU.Build.0 = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug|x64.ActiveCfg = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug|x64.Build.0 = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug|x86.ActiveCfg = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug|x86.Build.0 = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug1|Any CPU.ActiveCfg = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug1|Any CPU.Build.0 = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug1|x64.ActiveCfg = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug1|x64.Build.0 = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug1|x86.ActiveCfg = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Debug1|x86.Build.0 = Debug|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Release|Any CPU.ActiveCfg = Release|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Release|Any CPU.Build.0 = Release|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Release|x64.ActiveCfg = Release|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Release|x64.Build.0 = Release|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Release|x86.ActiveCfg = Release|Any CPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -223,6 +243,7 @@ Global {9EB9DFC1-C78A-46C0-826A-5ED1A08232C0} = {DD1CE747-341A-4419-8398-0D482E02DE54} {560CC80B-389B-46FC-9B8C-DA1D62A555D9} = {5DB27B2D-14A5-441F-A861-BAFDB7BAA05B} {8FA74161-0D03-408F-811A-A244C9027BFB} = {5DB27B2D-14A5-441F-A861-BAFDB7BAA05B} + {887F9454-B1F3-47B8-B9F7-48BEBA47193D} = {5DB27B2D-14A5-441F-A861-BAFDB7BAA05B} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {4BF9CC66-BB0E-4400-BCF8-5BF7F5DA800A} diff --git a/Config.json b/Config.json new file mode 100644 index 0000000..8377c49 --- /dev/null +++ b/Config.json @@ -0,0 +1 @@ +{"$type":"BRS.Process.A020.A020Config, BRS.Process.A020","StationCode":null,"CameraConfigCollection":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Interface.IInitialConfig, BRS.Common.Model]], mscorlib","$values":[]},"PLCConfigCollection":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Interface.IInitialConfig, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Device.OmronPLC.OmronPLCInitialConfig, BRS.Device.OmronPLC","PLCIpAddress":"192.168.1.21","PLCPort":9600,"PLCUnitNum":0,"PCNetNum":20,"HeartbeatAddress":null,"HeartbeatCycle":0,"DriverType":"OmronPLC","WarningSetCollection":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Interface.IWarningSet, BRS.Common.Model]], mscorlib","$values":[]},"MonitorSetCollection":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Interface.IMonitorSet, BRS.Common.Model]], mscorlib","$values":[]},"IsEnableMonitor":true,"MonitorInterval":100,"MonitorTimeout":500,"EventStartAddress":0,"EventLength":200,"MotionStateCollection":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Base.PLCMotionDefinition_State, BRS.Common.Device]], mscorlib","$values":[]},"Id":"7C04B49B-C35D-4095-B561-3090530182AF","Name":"mPLC","IsEnabled":true,"LogPath":"","IsEnableLog":false,"IsEnableCSV":false}]},"RobotConfigCollection":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Interface.IInitialConfig, BRS.Common.Model]], mscorlib","$values":[{"$type":"XKRS.Device.NbtRobot.NbtRobotInitialConfig, XKRS.Device.NbtRobot","RobotIpAddress":"192.168.1.13","RobotPortNum":3,"RobotSpeed":0.1,"DriverType":"NbtRobot","RobotOriginPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5944,"Y":-951.7325,"Z":546.73,"A":1.5646,"B":0.0306,"C":-1.7171,"_Description":"起始点P0"},"RobotMachine1Entrance1GrabPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5944,"Y":-951.7325,"Z":546.73,"A":1.5646,"B":0.0306,"C":-1.7171,"_Description":"1号机1号位抓取点P101"},"RobotMachine1Entrance2GrabPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5944,"Y":-951.7325,"Z":546.73,"A":1.5646,"B":0.0306,"C":-1.7171,"_Description":"1号机2号位抓取点P201"},"RobotMachine2Entrance1GrabPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位抓取点P101"},"RobotMachine2Entrance2GrabPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位抓取点P201"},"RobotMachine1Entrance1UpPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1184.772,"Y":-785.504,"Z":1296.4,"A":0.981,"B":1.514,"C":-1.149,"_Description":"1号机1号位放料点P102"},"RobotMachine1Entrance2UpPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1192.58,"Y":-786.589,"Z":76.663,"A":1.021,"B":1.529,"C":-1.131,"_Description":"1号机2号位放料点P102"},"RobotMachine2Entrance1UpPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位放料点P102"},"RobotMachine2Entrance2UpPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位放料点P202"},"RobotMachine1Entrance1UpPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5859,"Y":-951.7537,"Z":1283.948,"A":1.5649,"B":0.0305,"C":-1.7174,"_Description":"1号机1号位上料过度点1P104"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":38.8871,"Y":-856.3748,"Z":1469.34937,"A":1.3739,"B":1.0063,"C":-1.5805,"_Description":"1号机1号位上料过度点2P105"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":30.4944,"Y":-893.3191,"Z":1378.66809,"A":1.2962,"B":1.386,"C":-1.5317,"_Description":"1号机1号位上料过度点3P106"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":160.7552,"Y":-713.1599,"Z":1506.21326,"A":0.6689,"B":1.4707,"C":-0.8149,"_Description":"1号机1号位料仓门口P103"}]},"RobotMachine1Entrance2UpPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.1279,"Y":-833.3962,"Z":546.9038,"A":1.5579,"B":0.9827,"C":-1.6893,"_Description":"1号机2号位上料过度点1P204"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.1279,"Y":-833.3962,"Z":546.9038,"A":1.5579,"B":0.9827,"C":-1.6893,"_Description":"1号机2号位上料过度点2P205"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.1279,"Y":-833.3962,"Z":546.9038,"A":1.5579,"B":0.9827,"C":-1.6893,"_Description":"1号机2号位上料过度点3P206"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":63.8628,"Y":-831.439,"Z":390.7485,"A":0.9621,"B":1.5274,"C":-1.1019,"_Description":"1号机2号位料仓门口P203"}]},"RobotMachine2Entrance1UpPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位上料过度点1P104"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位上料过度点2P105"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位上料过度点3P106"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位料仓门口P103"}]},"RobotMachine2Entrance2UpPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位上料过度点1P204"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位上料过度点2P205"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位上料过度点3P206"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位料仓门口P203"}]},"RobotMachine1Entrance1TakeTyrePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":723.569,"Y":-780.416,"Z":1353.361,"A":2.899,"B":1.445,"C":-3.02,"_Description":"1号机1号位下料取料点"},"RobotMachine1Entrance1TakeTyreTiltUpperPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":742.535,"Y":-758.209,"Z":1125.344,"A":0.283,"B":1.322,"C":-0.378,"_Description":"夹爪水平点"},"RobotMachine1Entrance2TakeTyrePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":715.79,"Y":-778.849,"Z":157.305,"A":3.005,"B":1.405,"C":-3.109,"_Description":"点位描述"},"RobotMachine1Entrance2TakeTyreTiltUpperPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":734.429,"Y":-760.918,"Z":-78.125,"A":0.261,"B":1.377,"C":-0.371,"_Description":"点位描述"},"RobotMachine2Entrance1TakeTyrePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotMachine2Entrance1TakeTyreTiltUpperPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotMachine2Entrance2TakeTyrePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotMachine2Entrance2TakeTyreTiltUpperPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotMachine1Entrance1DownPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5944,"Y":-951.7325,"Z":900.73,"A":1.5646,"B":0.0306,"C":-1.7171,"_Description":"1号机1号位下料放置点"},"RobotMachine1Entrance2DownPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.645,"Y":-922.2,"Z":372.393,"A":1.559,"B":0.052,"C":-1.491,"_Description":"点位描述"},"RobotMachine2Entrance1DownPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotMachine2Entrance2DownPlacePoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotMachine1Entrance1DownPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5859,"Y":-951.7537,"Z":1283.948,"A":1.5649,"B":0.0305,"C":-1.7174,"_Description":"下料1号机1号位过度点1(P109)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":38.8871,"Y":-856.3748,"Z":1469.34937,"A":1.3739,"B":1.0063,"C":-1.5805,"_Description":"下料1号机1号位过度点1(P110)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":30.4944,"Y":-893.3191,"Z":1378.66809,"A":1.2962,"B":1.386,"C":-1.5317,"_Description":"下料1号机1号位过度点1(P111)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":160.7552,"Y":-713.1599,"Z":1506.21326,"A":0.6689,"B":1.4707,"C":-0.8149,"_Description":"1号机1号位料仓门口(P103)"}]},"RobotMachine1Entrance2DownPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.1279,"Y":-833.3962,"Z":546.9038,"A":1.5579,"B":0.9827,"C":-1.6893,"_Description":"下料1号机2号位过度点1(P209)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.1279,"Y":-833.3962,"Z":546.9038,"A":1.5579,"B":0.9827,"C":-1.6893,"_Description":"下料1号机2号位过度点1(P210)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":1.1279,"Y":-833.3962,"Z":546.9038,"A":1.5579,"B":0.9827,"C":-1.6893,"_Description":"下料1号机2号位过度点1(P211)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":299.806,"Y":-783.351,"Z":321.617,"A":0.965,"B":1.527,"C":-1.105,"_Description":"1号机2号位料仓门口(P203)"}]},"RobotMachine2Entrance1DownPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"下料2号机1号位过度点1(P109)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"下料2号机1号位过度点1(P110)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"下料2号机1号位过度点1(P111)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机1号位料仓门口(P103)"}]},"RobotMachine2Entrance2DownPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"下料2号机2号位过度点1(P209)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"下料2号机2号位过度点1(P210)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"下料2号机2号位过度点1(P211)"},{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"2号机2号位料仓门口(P203)"}]},"RobotUpMovePoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[]},"RobotUPBackPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[]},"RobotDownMovePoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[]},"RobotDownBackPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[]},"ConfigRobotDownBackPoints":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Model.RobotPoint, BRS.Common.Model]], mscorlib","$values":[]},"RobotInitPosition":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":21.5944,"Y":-951.7325,"Z":546.73,"A":1.5646,"B":0.0306,"C":-1.7171,"_Description":"起始点0"},"X1Point":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":444.0,"Y":555.0,"Z":666.0,"A":111.0,"B":222.0,"C":333.0,"_Description":"点位描述"},"X2Point":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"RobotTyReRadius":null,"SetWhoolSize":"17","GripperFastenPosition":"45000","GripperLoosenPosition":"30000","GripperAllLoosenPosition":"30000","GripperAllFastenPosition":"45000","Wheel12GripperUpFasten":"40000","Wheel12GripperUpLoosen":"30000","Wheel12GripperDownFasten":"40000","Wheel12GripperDownLoosen":"30000","Wheel13GripperUpFasten":"40000","Wheel13GripperUpLoosen":"30000","Wheel13GripperDownFasten":"40000","Wheel13GripperDownLoosen":"30000","Wheel14GripperUpFasten":"40000","Wheel14GripperUpLoosen":"30000","Wheel14GripperDownFasten":"40000","Wheel14GripperDownLoosen":"30000","Wheel15GripperUpFasten":"40000","Wheel15GripperUpLoosen":"30000","Wheel15GripperDownFasten":"40000","Wheel15GripperDownLoosen":"30000","Wheel16GripperUpFasten":"40000","Wheel16GripperUpLoosen":"30000","Wheel16GripperDownFasten":"40000","Wheel16GripperDownLoosen":"30000","Wheel17GripperUpFasten":"38000","Wheel17GripperUpLoosen":"6000","Wheel17GripperDownFasten":"31000","Wheel17GripperDownLoosen":"5000","Wheel18GripperUpFasten":"24000","Wheel18GripperUpLoosen":"6000","Wheel18GripperDownFasten":"26000","Wheel18GripperDownLoosen":"18000","X1_1Point":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"X1_2Point":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"X2_1Point":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"X2_2Point":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"TakeOutPoint":{"$type":"BRS.Common.Model.RobotPoint, BRS.Common.Model","X":0.0,"Y":0.0,"Z":0.0,"A":0.0,"B":0.0,"C":0.0,"_Description":"点位描述"},"Id":"8C0B56DE-1FC5-4907-BD4F-B81B1EFC507E","Name":"MachineArm","IsEnabled":true,"LogPath":"","IsEnableLog":true,"IsEnableCSV":false}]},"DeviceConfigs":{"$type":"System.Collections.Generic.List`1[[BRS.Common.Interface.IInitialConfig, BRS.Common.Model]], mscorlib","$values":[]},"IsLogEnabled":false,"DefaultLogLevel":3,"IsCSVOutputEnabled":false,"LogPath":""} \ No newline at end of file diff --git a/src/BRS.Common.Model/Helper/EnumHelper.cs b/src/BRS.Common.Model/Helper/EnumHelper.cs index 3a97dd9..55f8d05 100644 --- a/src/BRS.Common.Model/Helper/EnumHelper.cs +++ b/src/BRS.Common.Model/Helper/EnumHelper.cs @@ -8,6 +8,22 @@ namespace BRS.Common.Model.Helper { public static class EnumHelper { + static int ShijiaoPostion1 = 0; + static int ShijiaoPostion2 = 0; + static int ShijiaoPostion3 = 0; + public struct MyPoint + { + public double dX; + public double dY; + } + public struct Corner + { + public MyPoint LU; + public MyPoint RU; + public MyPoint LD; + public MyPoint RD; + + } /// /// 根据枚举的代码名称获取枚举列表信息 /// @@ -672,6 +688,8 @@ namespace BRS.Common.Model.Helper Resetting = 5, Closing = 6, ClearProduct = 7, + //等待 + Waiting=8, } public enum WhoolSize diff --git a/src/BRS.Process.A020/A020Process_Operation.cs b/src/BRS.Process.A020/A020Process_Operation.cs index 39fd694..464a488 100644 --- a/src/BRS.Process.A020/A020Process_Operation.cs +++ b/src/BRS.Process.A020/A020Process_Operation.cs @@ -32,6 +32,7 @@ namespace BRS.Process.A020 else ProcessWriteInt(OmronPlc, "D103", "int", "0"); } +#if false public void Machine1Entrance1Up(int tyreSize) { @@ -78,7 +79,7 @@ namespace BRS.Process.A020 //} LogAsync(DateTime.Now, LogLevel.Detail, "1号位胎胚就位,开始上料流程。"); - #region 1号机1号位上料流程 + #region 1号机1号位上料流程 //去抓料 StrRobotPoint pointMachine1Entrance1GrabPos = ClassChangeStruct(robotPointMachine1Entrance1GrabPos); @@ -185,7 +186,7 @@ namespace BRS.Process.A020 NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - #endregion + #endregion LogAsync(DateTime.Now, LogLevel.Detail, "1号位上料完成。"); } else @@ -197,7 +198,6 @@ namespace BRS.Process.A020 IsSingleStepOperating = false; }); } - public void Machine1Entrance1Down(int tyreSize) { // 设置设备 @@ -305,7 +305,7 @@ namespace BRS.Process.A020 //硫化机上环升,硫化机程序内设置保持5S //VulcanizaMachineOperateOnce(OmronPlc, addrD127, 5000); //硫化机上环升,并保持状态。 - VulcanizaMachineOperateKeep(OmronPlc, addrD127,"1"); + VulcanizaMachineOperateKeep(OmronPlc, addrD127, "1"); //水平放置点上方350 StrRobotPoint strM1E1DownPlaceLevelPointUpper = strM1E1TakeTiltUpperPoint; @@ -403,7 +403,7 @@ namespace BRS.Process.A020 // machine1Entrance2TyreReadyStateD83 = ProcessReadInt(OmronPlc, addrD83, "int"); //} LogAsync(DateTime.Now, LogLevel.Detail, "2号位胎胚就位,开始上料流程。"); - #region 1号机2号位上料流程 + #region 1号机2号位上料流程 //去抓料 StrRobotPoint pointMachine1Entrance2GrabPos = ClassChangeStruct(robotPointMachine1Entrance2GrabPos); @@ -513,7 +513,7 @@ namespace BRS.Process.A020 NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - #endregion + #endregion LogAsync(DateTime.Now, LogLevel.Detail, "2号位上料完成。"); } else @@ -713,7 +713,7 @@ namespace BRS.Process.A020 IsSingleStepOperating = false; }); } - +#endif //PLC地址 public class PlcAddress { @@ -1667,6 +1667,141 @@ namespace BRS.Process.A020 PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.IsProcessOpened.ToString(), true, null); return new ProcessResponse(true); } + public void ShaftRightMouseDown(MachineState machineState) + { + if (machineState != MachineState.Ready) + { + LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); + return; + } + LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); + + var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + + string addD201 = "D201";//通讯故障检查地址 + string addD19 = "D19";//急停状态检查地址 + string addD1 = "D1";//上位机启动标志位 + string addD7 = "D7";//手动自动改变 + string addD51 = "D51";//手动拧紧螺丝标志位 + string addD171 = "D171";//最大扭矩设置 + string addD351 = "D351";//高速计数器当前值200000一圈360° + string addD251 = "D251";//当前扭矩返回值 + string addD3 = "D3";//上机位停止标志位 + + machineState = MachineState.Running; + ProcessStatus = ProcessStatus.Init; + MachineStateStep = MachineStateStep.Ready; + + Task.Run(() => + { + while (machineState == MachineState.Running && MachineStateStep != MachineStateStep.Pause) + { + string ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int");//通讯 + + if (ShaftCommunication == "111")//如果等于111,流程启动 + { + string ShaftEmergencyStop = ProcessReadInt(MelsecPLC, addD19, "int");//急停 + if (ShaftEmergencyStop != "0")//判断是否急停,0不急停,1急停 + { + LogAsync(DateTime.Now, LogLevel.Warning, "设备急停!"); + Thread.Sleep(2000); + continue; + } + else + { + ProcessWriteInt(MelsecPLC, addD3, "int", "0");//D3置0 + ShaftOperateOnce(MelsecPLC, addD1, 500);//D1置1延时500后置0 + ProcessWriteInt(MelsecPLC, addD171, "int", "3000");//最大扭矩3000 + ProcessWriteInt(MelsecPLC, addD51, "int", "1");//手动拧紧螺丝D51置1 + + machineState = MachineState.Waiting;//设备启动完成后保持状态, + LogAsync(DateTime.Now, LogLevel.Detail, "设备已启动,请勿其他操作!!"); + + } + ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int"); + continue; + } + else + { + LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); + return; + } + + } + + }); + + IsSingleStepOperating = false; + } + + public void ShaftRightMouseUp(MachineState machineState) + { + + if (machineState != MachineState.Ready) + { + LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); + return; + } + LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); + + var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + + string addD201 = "D201";//通讯故障检查地址 + string addD19 = "D19";//急停状态检查地址 + string addD1 = "D1";//上位机启动标志位 + string addD7 = "D7";//手动自动改变 + string addD51 = "D51";//手动拧紧螺丝标志位 + string addD171 = "D171";//最大扭矩设置 + string addD351 = "D351";//高速计数器当前值200000一圈360° + string addD251 = "D251";//当前扭矩返回值 + string addD3 = "D3";//上机位停止标志位 + + machineState = MachineState.Running; + ProcessStatus = ProcessStatus.Init; + MachineStateStep = MachineStateStep.Ready; + + Task.Run(() => + { + while (machineState == MachineState.Running && MachineStateStep != MachineStateStep.Pause) + { + string ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int");//通讯 + + if (ShaftCommunication == "111")//如果等于111,流程启动 + { + string ShaftEmergencyStop = ProcessReadInt(MelsecPLC, addD19, "int");//急停 + if (ShaftEmergencyStop != "0")//判断是否急停,0不急停,1急停 + { + LogAsync(DateTime.Now, LogLevel.Warning, "设备急停!"); + Thread.Sleep(2000); + continue; + } + else + { + ProcessWriteInt(MelsecPLC, addD3, "int", "1");//D3置0 + + + ProcessWriteInt(MelsecPLC, addD51, "int", "0");//手动拧紧螺丝D51置1 + + machineState = MachineState.Pause;//设备暂停 + LogAsync(DateTime.Now, LogLevel.Detail, "设备已关闭"); + + } + ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int"); + continue; + } + else + { + LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); + return; + } + + } + + }); + + IsSingleStepOperating = false; + + } /// /// 进入自动化控制进程,完成系列动作 /// @@ -1675,1230 +1810,69 @@ namespace BRS.Process.A020 { if (MachineState != MachineState.Ready) { - LogAsync(DateTime.Now, LogLevel.Error, "硫化机不在就绪状态,无法启动"); + LogAsync(DateTime.Now, LogLevel.Error, "机台不在就绪状态,无法启动"); return new ProcessResponse(false); } LogAsync(DateTime.Now, LogLevel.Information, "流程启动中,请稍候..."); - // 设置设备 - var OmronPlc = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; - var NbtRobot = DeviceCollection.FirstOrDefault(u => u is RobotBase) as RobotBase; - - RobotPoint robotPointInitPos = NbtRobot.IConfig.RobotInitPosition;//初始位置 - StrRobotPoint initPoint = ClassChangeStruct(robotPointInitPos); - - RobotPoint robotPointMachine1Entrance1TakeTyrePos = NbtRobot.IConfig.RobotMachine1Entrance1TakeTyrePoint;//M1E1取料点 - RobotPoint robotPointMachine1Entrance1TakeTyreTiltUpperPos = NbtRobot.IConfig.RobotMachine1Entrance1TakeTyreTiltUpperPoint;//M1E1P107斜向上移动 - RobotPoint robotPointMachine1Entrance2TakeTyrePos = NbtRobot.IConfig.RobotMachine1Entrance2TakeTyrePoint;//M1E2取料点 - RobotPoint robotPointMachine1Entrance2TakeTyreTiltUpperPos = NbtRobot.IConfig.RobotMachine1Entrance2TakeTyreTiltUpperPoint;//M1E2P207斜向上移动 - - RobotPoint robotPointMachine2Entrance1TakeTyrePos = NbtRobot.IConfig.RobotMachine2Entrance1TakeTyrePoint;//M2E1取料点 - RobotPoint robotPointMachine2Entrance1TakeTyreTiltUpperPos = NbtRobot.IConfig.RobotMachine2Entrance1TakeTyreTiltUpperPoint;//M2E1P107上方220斜向上移动 - - RobotPoint robotPointMachine2Entrance2TakeTyrePos = NbtRobot.IConfig.RobotMachine2Entrance2TakeTyrePoint;//M2E2取料点 - RobotPoint robotPointMachine2Entrance2TakeTyreTiltUpperPos = NbtRobot.IConfig.RobotMachine2Entrance2TakeTyreTiltUpperPoint;//P207斜向上移动 - - - RobotPoint robotPointMachine1Entrance1DownPlacePos = NbtRobot.IConfig.RobotMachine1Entrance1DownPlacePoint;//M1E1取料放置点 - RobotPoint robotPointMachine1Entrance2DownPlacePos = NbtRobot.IConfig.RobotMachine1Entrance2DownPlacePoint;//M1E2取料放置点 - RobotPoint robotPointMachine2Entrance1DownPlacePos = NbtRobot.IConfig.RobotMachine2Entrance1DownPlacePoint;//M2E1取料放置点 - RobotPoint robotPointMachine2Entrance2DownPlacePos = NbtRobot.IConfig.RobotMachine2Entrance2DownPlacePoint;//M2E2取料放置点 - - RobotPoint robotPointMachine1Entrance1GrabPos = NbtRobot.IConfig.RobotMachine1Entrance1GrabPoint;//M1E1上料抓取点 - RobotPoint robotPointMachine1Entrance2GrabPos = NbtRobot.IConfig.RobotMachine1Entrance2GrabPoint;//M1E2上料抓取点 - RobotPoint robotPointMachine2Entrance1GrabPos = NbtRobot.IConfig.RobotMachine2Entrance1GrabPoint;//M2E1上料抓取点 - RobotPoint robotPointMachine2Entrance2GrabPos = NbtRobot.IConfig.RobotMachine1Entrance2GrabPoint;//M2E2上料抓取点 - - RobotPoint robotPointMachine1Entrance1UpPlacePos = NbtRobot.IConfig.RobotMachine1Entrance1UpPlacePoint;//M1E1上料放置点 - RobotPoint robotPointMachine1Entrance2UpPlacePos = NbtRobot.IConfig.RobotMachine1Entrance2UpPlacePoint;//M1E2上料放置点 - RobotPoint robotPointMachine2Entrance1UpPlacePos = NbtRobot.IConfig.RobotMachine2Entrance1UpPlacePoint;//M2E1上料放置点 - RobotPoint robotPointMachine2Entrance2UpPlacePos = NbtRobot.IConfig.RobotMachine2Entrance2UpPlacePoint;//M2E2上料放置点 + var MelsecPLC = DeviceCollection.FirstOrDefault(u => u is PLCBase) as PLCBase; + string addD201 = "D201";//通讯故障检查地址 + string addD19 = "D19";//急停状态检查地址 + string addD1 = "D1";//上位机启动标志位 + string addD7 = "D7";//手动自动改变 + string addD51 = "D51";//手动拧紧螺丝标志位 + string addD171 = "D171";//最大扭矩设置 + string addD351 = "D351";//高速计数器当前值200000一圈360° + string addD251 = "D251";//当前扭矩返回值 + string addD3 = "D3";//上机位停止标志位 MachineState = MachineState.Running; - RobotsStatus = RobotsStatus.Relasing; - MachineStateStep = MachineStateStep.Ready; ProcessStatus = ProcessStatus.Init; - - - //初始化设备 - //机械手复位,夹爪复位 - LogAsync(DateTime.Now, LogLevel.Information, "设备正在进行初始化,请稍后..."); - GripperInit(OmronPlc);//夹爪复位 - NbtRobotInit(NbtRobot);//机械臂复位 - //LogAsync(DateTime.Now, LogLevel.Information, "设备初始化完成..."); - - //LogAsync(DateTime.Now, LogLevel.Action, "流程启动完成!"); - //PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.IsProcessOpened.ToString(), true, null); - //return new ProcessResponse(true); - - bool isMachine1Entrance1Enabled = false;//0号启用 - bool isMachine1Entrance2Enabled = false;//1号启用 - bool isMachine2Entrance1Enabled = false;//2号启用 - bool isMachine2Entrance2Enabled = false;//3号启用 - - int Machine1Entrance1TireSize = 0; - int Machine1Entrance2TireSize = 0; - int Machine2Entrance1TireSize = 0; - int Machine2Entrance2TireSize = 0; - - - //胎胚到位,1时:胎坯就位,可以抓取 - //string addrD81 = "D81";//1号胎胚到位 - //string addrD83 = "D83";//2号胎胚到位 - //string addrD85 = "D85";//3号胎胚到位 - //string addrD87 = "D87";//4号胎胚到位 - - //string addrD09 = "D09";//1号开模到位状态 - //string addrD11 = "D11";//2号开模到位状态 - string addrD101 = "D101";//1号硫化完成状态 - string addrD201 = "D201";//2号硫化完成状态 - - Dictionary machineInfos = MachineInfos;//拿到界面上的设置参数 - var sortMachineInfos = from pair in machineInfos orderby pair.Key ascending select pair;//以字典Key值顺序排序 - int iter = 0; - //根据字典中保存的参数设置是否启用每个硫化机,并读取相应TireSize - foreach (var item in sortMachineInfos) - { - if (item.Value.location == 0) - { - isMachine1Entrance1Enabled = item.Value.isReady; - Machine1Entrance1TireSize = item.Value.tyreSize; - } - if (item.Value.location == 1) - { - isMachine1Entrance2Enabled = item.Value.isReady; - Machine1Entrance2TireSize = item.Value.tyreSize; - } - if (item.Value.location == 2) - { - isMachine2Entrance1Enabled = item.Value.isReady; - Machine2Entrance1TireSize = item.Value.tyreSize; - } - if (item.Value.location == 3) - { - isMachine2Entrance2Enabled = item.Value.isReady; - Machine2Entrance2TireSize = item.Value.tyreSize; - } - - iter++; - string strLog = $"料仓使用中总数:{machineInfos.Count}, 第{iter}个, 位置:{item.Value.location}, 轮胎大小:{item.Value.tyreSize}"; - LogAsync(DateTime.Now, LogLevel.Information, strLog); - } - + MachineStateStep = MachineStateStep.Ready; Task.Run(() => { - //获取硫化机D101 D201硫化状态,等待硫化完成 - //流程中,等待硫化完成,进入下料--上料--硫化--再下料的循环过程 - - while (isMachineRobotRunning()) + while (MachineState == MachineState.Running && MachineStateStep != MachineStateStep.Pause) { - Thread.Sleep(2000);//延迟2s,防止合模过程未结束,硫化机还处于开模状态 + string ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int");//通讯 - //D101: 1为硫化中,0为硫化完成 - string machine1VulcanStateD101 = ProcessReadInt(OmronPlc, "D101", "int"); - - //判断1号机是否开模 - if (machine1VulcanStateD101 == "0") + if (ShaftCommunication == "111")//如果等于111,流程启动 { - Thread.Sleep(10000); - //首先进行下料过程 - string machine1EmergencyStop = ProcessReadInt(OmronPlc, "D111", "int"); - string machine2EmergencyStop = ProcessReadInt(OmronPlc, "D211", "int"); - //判断1号机是否急停 - if (machine1EmergencyStop == "1") + string ShaftEmergencyStop = ProcessReadInt(MelsecPLC, addD19, "int");//急停 + if (ShaftEmergencyStop != "0")//判断是否急停,0不急停,1急停 { - LogAsync(DateTime.Now, LogLevel.Exception, "1号硫化机进入急停状态"); - //*把流程停止,把按钮变为--流程开始--*// - - //判断2号机是否同时急停,是则停止流程,否则继续循环,走2号机 - if (machine2EmergencyStop == "1") - { - LogAsync(DateTime.Now, LogLevel.Exception, "2号硫化机同时为急停状态,流程停止"); - //1、2号机都是急停状态,则直接停止流程,不在循环 - - //*把流程停止,把按钮变为--流程开始--*// - - return;//直接停止流程 - } - } - else if (!isMachine1Entrance1Enabled && !isMachine1Entrance2Enabled) - { - //在1号机不在急停的状态下,判断有无可用下料口 - LogAsync(DateTime.Now, LogLevel.Error, "1号机已开模,但无已启用的料仓,已跳过。"); + LogAsync(DateTime.Now, LogLevel.Warning, "设备急停!"); + Thread.Sleep(2000); continue; } - //有下料口,开始 1号机 下料--上料-- 。。。。。。。。 else { - ////////////////////////////***********1号机下料***********//////////////////////////// - ////延时20秒 - //Thread.Sleep(20000); - //开模 - VulcanizaMachineOperateOnce(OmronPlc, "D107", 500); - ////延时10秒 - Thread.Sleep(30000); - LogAsync(DateTime.Now, LogLevel.Detail, $"等待30s"); - //硫化机自动切换为手动,0为手动,1为自动 - ProcessWriteInt(OmronPlc, "D103", "int", "0"); - //硫化机进行总定型动作,总定型3s - VulcanizaMachineOperateOnce(OmronPlc, "D117", 3000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D109", 500); - //硫化机进行抽真空动作,抽真空4s - VulcanizaMachineOperateOnce(OmronPlc, "D125", 7000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D109", 500); - //移动到初始点 - NbtRobotMove(NbtRobot, initPoint, 1000); - //1号位下料 - if (isMachine1Entrance1Enabled) - { - LogAsync(DateTime.Now, LogLevel.Detail, "开始1号位下料流程。"); - #region 1号机1号位下料流程 - - //机械臂 从初始点移动到1号位料仓门口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance1DownPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine1Entrance1料仓门口"); - - //移动到取料点上方220 - StrRobotPoint strM1E1TakePoint = ClassChangeStruct(robotPointMachine1Entrance1TakeTyrePos);//取料点 - StrRobotPoint strM1E1TakePointUpper = strM1E1TakePoint;//取料点上方 - strM1E1TakePointUpper.Z = strM1E1TakePoint.Z + 220; - NbtRobotMove(NbtRobot, strM1E1TakePointUpper, 1000);//移动到取料点上方220 - - LogAsync(DateTime.Now, LogLevel.Detail, $"当前轮胎尺寸:{Machine1Entrance1TireSize}"); - - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - string M1E1DownFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance1TireSize, MoveState.DownFasten); - if (M1E1DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - continue; - } - else - GripperMove(OmronPlc, M1E1DownFastenPos);//夹爪运动 - - //移动到取料点 - NbtRobotMove(NbtRobot, strM1E1TakePoint, 1000); - - //夹爪运动到下料放松点,夹爪(D31,D33)扩张 - //同时开始上定型 - string M1E1DownLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance1TireSize, MoveState.DownLoosen); - if (M1E1DownLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E1DownLoosenPos);//夹爪运动 - - //先移动到夹爪水平或上挑的点 - StrRobotPoint strM1E1TakeTiltUpperPoint = ClassChangeStruct(robotPointMachine1Entrance1TakeTyreTiltUpperPos); - NbtRobotMove(NbtRobot, strM1E1TakeTiltUpperPoint, 500); - - //硫化机进行上定型动作,上定型2s - VulcanizaMachineOperateOnce(OmronPlc, "D113 ", 2000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D109", 500); - //硫化机上环升,硫化机程序内设置保持5S - //VulcanizaMachineOperateOnce(OmronPlc, "D127", 5000); - - //硫化机上环升,并保持置1状态,2s - VulcanizaMachineOperateKeep(OmronPlc, "D127", "1"); - Thread.Sleep(5000); - - //水平放置点上方350 - StrRobotPoint strM1E1DownPlaceLevelPointUpper = strM1E1TakeTiltUpperPoint; - strM1E1DownPlaceLevelPointUpper.Z = strM1E1TakeTiltUpperPoint.Z + 350;//水平放置点上方 - //从取料点移出 - NbtRobotMove(NbtRobot, strM1E1DownPlaceLevelPointUpper, 1000); - - VulcanizaMachineOperateKeep(OmronPlc, "D127", "0"); - - ////从取料点移出 - //NbtRobotMove(NbtRobot, strM1E1TakePointUpper, 1000); - - ////移动到220后再斜上方 - //StrRobotPoint strM1E1TakeTiltUpperPoint = ClassChangeStruct(robotPointMachine1Entrance1TakeTyreTiltUpperPos); - //NbtRobotMove(NbtRobot, strM1E1TakeTiltUpperPoint, 1000); - - - //移动到放置点,反用DownPoints - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance1DownPoints, 2000, true); - - //移动到放置点上方220 - StrRobotPoint strM1E1DownPlacePoint = ClassChangeStruct(robotPointMachine1Entrance1DownPlacePos);//放置点 - StrRobotPoint strM1E1DownPlacePointUpper = strM1E1DownPlacePoint;//放置点上方 - strM1E1DownPlacePointUpper.Z = strM1E1DownPlacePoint.Z + 220; - //移动到放置点上方 - NbtRobotMove(NbtRobot, strM1E1DownPlacePointUpper, 2000); - LogAsync(DateTime.Now, LogLevel.Error, "是否在-<放置点>-加传感器,判断放置点是否已置空??"); - //移动到放置点 - NbtRobotMove(NbtRobot, strM1E1DownPlacePoint, 2000); - - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂从Machine1Entrance1料仓门口移动到放置点"); - - //开始放料 - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - if (M1E1DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E1DownFastenPos);//夹爪运动 - Thread.Sleep(1000); - - //放料完,移走机械臂 - //移动到放置点上方 - NbtRobotMove(NbtRobot, strM1E1DownPlacePointUpper, 1000); - //夹爪运动到放松点 - GripperMove(OmronPlc, NbtRobot.IConfig.GripperLoosenPosition); - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "1号位下料完成。"); - - //1号位下料结束;判断2号位是否需要下料,不需要则机械臂回原点 - if (!isMachine1Entrance2Enabled) - { - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - GripperInit(OmronPlc);//夹爪复位 - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - } - } - - //2号位下料 - if (isMachine1Entrance2Enabled) - { - LogAsync(DateTime.Now, LogLevel.Detail, "开始2号位下料流程。"); - #region 1号机2号位下料流程 - GripperInit(OmronPlc);//夹爪复位 - //机械臂移动到二号位料仓门口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance2DownPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine1Entrance2料仓门口"); - - //移动到取料点上方220 - StrRobotPoint strM1E2TakePoint = ClassChangeStruct(robotPointMachine1Entrance2TakeTyrePos);//取料点 - StrRobotPoint strM1E2TakePointUpper = strM1E2TakePoint;//取料点上方 - strM1E2TakePointUpper.Z = strM1E2TakePoint.Z + 220; - //移动到取料点上方220 - NbtRobotMove(NbtRobot, strM1E2TakePointUpper, 1000); - - //本台硫化机总定型1s,防止上环升不起来 - VulcanizaMachineOperateOnce(OmronPlc, "D117", 1000); - VulcanizaMachineOperateOnce(OmronPlc, "D123", 2000); - //Thread.Sleep(2000);//定型完成后延时两秒 - - LogAsync(DateTime.Now, LogLevel.Detail, $"当前轮胎尺寸:{Machine1Entrance2TireSize}"); - //上环升保持 - VulcanizaMachineOperateKeep(OmronPlc, "D127", "1"); - Thread.Sleep(3000);//保持3s - - //放料点上方55 - strM1E2TakePointUpper.Z = strM1E2TakePoint.Z + 65; - //移动到取料点上方30 - NbtRobotMove(NbtRobot, strM1E2TakePointUpper, 1000); - - //上环升保持 - VulcanizaMachineOperateKeep(OmronPlc, "D127", "1"); - - //硫化机进行抽真空动作,抽真空2s - VulcanizaMachineOperateOnce(OmronPlc, "D125", 2000); - - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - string M1E2DownFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance2TireSize, MoveState.DownFasten); - if (M1E2DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E2DownFastenPos);//夹爪运动 - - VulcanizaMachineOperateKeep(OmronPlc, "D127", "1");//上环升保持 - //移动到取料点 - NbtRobotMove(NbtRobot, strM1E2TakePoint, 1000);//移动到取料点 - - //夹爪运动到下料放松点,夹爪(D31,D33)扩张 - //同时开始下定型 - string M1E2DownLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance2TireSize, MoveState.DownLoosen); - if (M1E2DownLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E2DownLoosenPos);//夹爪运动 - - //先移动到夹爪水平或上挑的点 robotPointMachine1Entrance2TakeTyreTiltUpperPos - StrRobotPoint strM1E2TakeTiltUpperPoint = ClassChangeStruct(robotPointMachine1Entrance2TakeTyreTiltUpperPos); - NbtRobotMove(NbtRobot, strM1E2TakeTiltUpperPoint, 500); - - //上环升保持 - VulcanizaMachineOperateKeep(OmronPlc, "D127", "1"); - Thread.Sleep(3000);//保持5s - - //硫化机进行下定型动作2s - //VulcanizaMachineOperateOnce(OmronPlc, "D115 ", 2000); - //硫化机停止 - - VulcanizaMachineOperateOnce(OmronPlc, "D109", 500); - //硫化机下环升,硫化机程序内设置保持5S - //VulcanizaMachineOperateOnce(OmronPlc, "D129 ", 5000); - //VulcanizaMachineOperateKeep(OmronPlc, "D129", "1"); - - - //从水平点移动到 - StrRobotPoint strM1E2DownPlaceLevelPointUpper = strM1E2TakeTiltUpperPoint; - strM1E2DownPlaceLevelPointUpper.Z = strM1E2TakeTiltUpperPoint.Z + 350; - - //取出轮胎之前先抽真空硫化机进行抽真空动作,抽真空3s - VulcanizaMachineOperateOnce(OmronPlc, "D125", 3000); - - //从水平点移动到上方350的距离 - NbtRobotMove(NbtRobot, strM1E2DownPlaceLevelPointUpper, 1000); - - VulcanizaMachineOperateKeep(OmronPlc, "D127", "0"); - - ////移动到2号位取料点上方220 - //NbtRobotMove(NbtRobot, strM1E2TakePointUpper, 1000); - ////上方220再斜向上移动一点 - //StrRobotPoint strM1E2TakeTiltUpperPoint = ClassChangeStruct(robotPointMachine1Entrance2TakeTyreTiltUpperPos); - //NbtRobotMove(NbtRobot, strM1E2TakeTiltUpperPoint, 1000); - - //移动回到放置点 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance2DownPoints, 1000, true); - StrRobotPoint strM1E2DownPlacePoint = ClassChangeStruct(robotPointMachine1Entrance2DownPlacePos);//放置点 - StrRobotPoint strM1E2DownPlacePointUpper = strM1E2DownPlacePoint;//放置点上方 - strM1E2DownPlacePointUpper.Z = strM1E2DownPlacePoint.Z; - //移动到放置点上方 - NbtRobotMove(NbtRobot, strM1E2DownPlacePointUpper, 1000); - LogAsync(DateTime.Now, LogLevel.Error, "是否在-<放置点>-加传感器,判断放置点是否已置空??"); - //移动到放置点 - NbtRobotMove(NbtRobot, strM1E2DownPlacePoint, 1000); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂从Machine1Entrance2料仓门口移动到放置点"); - - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - if (M1E2DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E2DownFastenPos);//夹爪运动 - - Thread.Sleep(5000); - - strM1E2DownPlacePointUpper.Z = strM1E2DownPlacePoint.Z + 220; - NbtRobotMove(NbtRobot, strM1E2DownPlacePointUpper, 1000);//移动到放置点上方 - - GripperMove(OmronPlc, NbtRobot.IConfig.GripperLoosenPosition);//夹爪运动到放松点 - - //二号位下料结束 - GripperInit(OmronPlc);//夹爪复位 - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "2号位下料完成。"); - } - - ////////////////////////////***********1号机上料***********//////////////////////////// - - LogAsync(DateTime.Now, LogLevel.Detail, "开始进行上料过程"); - NbtRobotMove(NbtRobot, initPoint, 1000);//移动到初始点 - - //判断是否硫化完成 - machine1VulcanStateD101 = ProcessReadInt(OmronPlc, "D101", "int"); - - //1号位硫化机开模到位状态,为1时:硫化机开模到位可以进行上下料动作 - //string machine1OpenReadyStateD09 = ProcessReadInt(OmronPlc, addrD09, "int"); - - //string machine1Entrance1TyreReadyStateD81 = ProcessReadInt(OmronPlc, addrD81, "int"); - //string machine1Entrance2TyreReadyStateD83 = ProcessReadInt(OmronPlc, addrD83, "int"); - - //1号位上料,判断以下状态:D101:硫化完成、M1E1Enabled、D09:开模到位 - //if (machine1VulcanStateD101 == "0" && isMachine1Entrance1Enabled && machine1OpenReadyStateD09 == "1") - if(machine1VulcanStateD101=="0"&&isMachine1Entrance1Enabled) - { - //读D05:1号上料抓取位胎坯就位,等待D05置1胎胚就位 - //while (machine1Entrance1TyreReadyStateD81=="0") - //{ - // Thread.Sleep(1000); - // machine1Entrance1TyreReadyStateD81 = ProcessReadInt(OmronPlc, addrD81, "int"); - //} - LogAsync(DateTime.Now, LogLevel.Detail, "1号位胎胚就位,开始上料流程。"); - #region 1号机1号位上料流程 - - //去抓料 - StrRobotPoint pointMachine1Entrance1GrabPos = ClassChangeStruct(robotPointMachine1Entrance1GrabPos); - StrRobotPoint pointMachine1Entrance1GrabPosUpper = pointMachine1Entrance1GrabPos; - pointMachine1Entrance1GrabPosUpper.Z = pointMachine1Entrance1GrabPos.Z + 200; - NbtRobotMove(NbtRobot, pointMachine1Entrance1GrabPosUpper, 1000);//抓取点上方200 - ////夹爪运动到全松点 - //GripperMove(OmronPlc, NbtRobot.IConfig.GripperAllLoosenPosition); - NbtRobotMove(NbtRobot, pointMachine1Entrance1GrabPos, 1000);//移动到抓取点 - - //夹爪夹紧 - string M1E1UpFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance1TireSize, MoveState.UpFasten);//获取上料夹紧点 - if (M1E1UpFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E1UpFastenPos);//夹爪运动 - - //抓取轮胎后,根据预设点位移动到上料口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance1UpPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine1Entrance1上料口"); - - //运动到放料点 - StrRobotPoint pointMachine1Entrance1UpPlace = ClassChangeStruct(robotPointMachine1Entrance1UpPlacePos);//放料点 - StrRobotPoint pointMachine1Entrance1UpPlaceUpper = pointMachine1Entrance1UpPlace;//放料点上方200 - pointMachine1Entrance1UpPlaceUpper.Z = pointMachine1Entrance1UpPlace.Z + 200; - NbtRobotMove(NbtRobot, pointMachine1Entrance1UpPlaceUpper, 1000);//运动到放料点上方200 - //移动到放料点同时,硫化机上环升 - //VulcanizaMachineOperateOnce(OmronPlc, "D127", 5000);//上环升,硫化机程序内设置保持5S - - VulcanizaMachineOperateKeep(OmronPlc, "D127 ", "1");//上环升,保持升的状态 - Thread.Sleep(2000); - - NbtRobotMove(NbtRobot, pointMachine1Entrance1UpPlace, 1000);//运动到放料点 - - //下定型5秒,其中第2秒时松夹爪、机械臂移动出 - ProcessWriteInt(OmronPlc, "D115", "int", "0"); - Thread.Sleep(500); - ProcessWriteInt(OmronPlc, "D115", "int", "1"); - - //第2秒时,松夹爪、机械臂移动 - //夹爪放松 - string M1E1UpLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance1TireSize, MoveState.UpLoosen);//获取上料放松点 - if (M1E1UpLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E1UpLoosenPos);//夹爪运动 - NbtRobotMove(NbtRobot, pointMachine1Entrance1UpPlaceUpper, 1000);//运动到放料点上方200 - - ProcessWriteInt(OmronPlc, "D115", "int", "0");//下定型结束 - Thread.Sleep(500); - - VulcanizaMachineOperateKeep(OmronPlc, "D127 ", "0");//上环降 - - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D109", 500); - - //料仓门口点 - StrRobotPoint pointM1E1SiloDoor = ClassChangeStruct(NbtRobot.IConfig.RobotMachine1Entrance1UpPoints[3]); - NbtRobotMove(NbtRobot, pointM1E1SiloDoor, 1000);//运动到料仓门口 - - - //检测机械臂是否移动到料仓外 - StrRobotPoint currentP; - if (IsTesting) - currentP = pointM1E1SiloDoor; - else - currentP = NbtRobot.GetPosition(); - - //if (currentP.X != pointM1E1SiloDoor.X || currentP.Y != pointM1E1SiloDoor.Y || currentP.Z != pointM1E1SiloDoor.Z || - //currentP.A != pointM1E1SiloDoor.A || currentP.B != pointM1E1SiloDoor.B || currentP.C != pointM1E1SiloDoor.C) - //{ - // LogAsync(DateTime.Now, LogLevel.Exception, "机械臂位置错误,可能未移动出料仓,当前流程停止"); - // break; - //} - if (!IsNumApproximateEqual(currentP.X, pointM1E1SiloDoor.X, 0.5f) || - !IsNumApproximateEqual(currentP.Y, pointM1E1SiloDoor.Y, 0.5f) || - !IsNumApproximateEqual(currentP.Z, pointM1E1SiloDoor.Z, 0.5f) || - !IsNumApproximateEqual(currentP.A, pointM1E1SiloDoor.A, 0.5f) || - !IsNumApproximateEqual(currentP.B, pointM1E1SiloDoor.B, 0.5f) || - !IsNumApproximateEqual(currentP.C, pointM1E1SiloDoor.C, 0.5f)) - { - LogAsync(DateTime.Now, LogLevel.Exception, "机械臂位置错误,可能未移动出料仓,当前流程停止"); - break; - } - - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance1UpPoints, 1000, true);//从料仓门口回原点 - - - //1号位上料结束;判断2号位是否需要上料,不需要则机械臂回原点,开始合模 - if (!isMachine1Entrance2Enabled) - { - - VulcanizaMachineOperateKeep(OmronPlc, "D127 ", "1");//上环升,保持升的状态 - Thread.Sleep(2000); - //合模之前加入总定型5S - VulcanizaMachineOperateOnce(OmronPlc, "D117", 5000); - VulcanizaMachineOperateKeep(OmronPlc, "D127 ", "0");//上环降 - - //硫化机进入自动状态,0为手动,1为自动 - ProcessWriteInt(OmronPlc, "D103", "int", "1"); - //硫化机合模 - VulcanizaMachineOperateOnce(OmronPlc, "D105", 500); - Thread.Sleep(60000); - - //二号位不可用时,只硫化一号位 - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - } - GripperInit(OmronPlc);//夹爪复位 - LogAsync(DateTime.Now, LogLevel.Detail, "夹爪复位"); - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "1号位上料完成。"); - } - - - machine1VulcanStateD101 = ProcessReadInt(OmronPlc, addrD101, "int");//重新获取D101是否硫化完成状态 - //machine1Entrance2TyreReadyStateD83 = ProcessReadInt(OmronPlc, addrD83, "int");//重新2号上料抓取位胎坯就位状态 - //machine1OpenReadyStateD09 = ProcessReadInt(OmronPlc, addrD09, "int");//重新获取开模到位状态 - //2号位上料,判断以下状态:D101:硫化完成、M1E2Enabled、D09:开模到位、D07:2号上料抓取位胎坯就位 - //if (machine1VulcanStateD101 == "0" && isMachine1Entrance2Enabled && machine1OpenReadyStateD09 == "1") - if(machine1VulcanStateD101=="0"&&isMachine1Entrance2Enabled) - { - //读D07:1号上料抓取位胎坯就位,等待D07置1胎胚就位 - //while (machine1Entrance2TyreReadyStateD83 == "0") - //{ - // Thread.Sleep(1000); - // machine1Entrance2TyreReadyStateD83 = ProcessReadInt(OmronPlc, addrD83, "int"); - //} - LogAsync(DateTime.Now, LogLevel.Detail, "2号位胎胚就位,开始上料流程。"); - #region 1号机2号位上料流程 - - //去抓料 - StrRobotPoint pointMachine1Entrance2GrabPos = ClassChangeStruct(robotPointMachine1Entrance2GrabPos); - StrRobotPoint pointMachine1Entrance2GrabPosUpper = pointMachine1Entrance2GrabPos; - pointMachine1Entrance2GrabPosUpper.Z = pointMachine1Entrance2GrabPos.Z + 200; - //机械臂移动到抓取点上方200 - NbtRobotMove(NbtRobot, pointMachine1Entrance2GrabPosUpper, 1000); - ////夹爪运动到全松点 - //GripperMove(OmronPlc, NbtRobot.IConfig.GripperAllLoosenPosition); - //机械臂移动到抓取点 - NbtRobotMove(NbtRobot, pointMachine1Entrance2GrabPos, 1000); - - //夹爪夹紧 - string M1E2UpFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance2TireSize, MoveState.UpFasten);//获取上料夹紧点 - if (M1E2UpFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E2UpFastenPos);//夹爪运动 - - //抓取轮胎后,根据预设点位移动到上料口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance2UpPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine1Entrance2上料口"); - - //运动到放料点 - StrRobotPoint pointMachine1Entrance2UpPlace = ClassChangeStruct(robotPointMachine1Entrance2UpPlacePos);//放料点 - StrRobotPoint pointMachine1Entrance2UpPlaceUpper = pointMachine1Entrance2UpPlace;//放料点上方200 - pointMachine1Entrance2UpPlaceUpper.Z = pointMachine1Entrance2UpPlace.Z + 200; - NbtRobotMove(NbtRobot, pointMachine1Entrance2UpPlaceUpper, 1000);//运动到放料点上方200 - //移动到放料点同时,硫化机上环升 - //VulcanizaMachineOperateOnce(OmronPlc, "D127 ", 5000);//上环升,硫化机程序内设置保持5S - VulcanizaMachineOperateKeep(OmronPlc, "D127", "1");//上环升,硫化机程序内设置保持5S - Thread.Sleep(2000); - - NbtRobotMove(NbtRobot, pointMachine1Entrance2UpPlace, 1000);//运动到放料点 - - //下定型5秒,其中第2秒时松夹爪、机械臂移动出 - ProcessWriteInt(OmronPlc, "D115", "int", "0"); - Thread.Sleep(500); - ProcessWriteInt(OmronPlc, "D115", "int", "1"); - - //第2秒时,松夹爪、机械臂移动 - //夹爪放松 - string M1E2UpLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine1Entrance2TireSize, MoveState.UpLoosen);//获取上料放松点 - if (M1E2UpLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M1E2UpLoosenPos); - - // 运动到放料点上方200 - NbtRobotMove(NbtRobot, pointMachine1Entrance2UpPlaceUpper, 1000); - //下定型结束 - ProcessWriteInt(OmronPlc, "D115", "int", "0"); - Thread.Sleep(500); - - VulcanizaMachineOperateKeep(OmronPlc, "D127", "0");//上环降 - - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D109", 500); - - - //料仓门口点 - StrRobotPoint pointM1E2SiloDoor = ClassChangeStruct(NbtRobot.IConfig.RobotMachine1Entrance2UpPoints[3]); - NbtRobotMove(NbtRobot, pointM1E2SiloDoor, 1000);//运动到料仓门口 - - - //检测机械臂是否移动到料仓外 - StrRobotPoint currentP; - if (IsTesting) - currentP = pointM1E2SiloDoor; - else - currentP = NbtRobot.GetPosition(); - - //if (currentP.X != pointM1E2SiloDoor.X || currentP.Y != pointM1E2SiloDoor.Y || currentP.Z != pointM1E2SiloDoor.Z || - //currentP.A != pointM1E2SiloDoor.A || currentP.B != pointM1E2SiloDoor.B || currentP.C != pointM1E2SiloDoor.C) - //{ - // LogAsync(DateTime.Now, LogLevel.Exception, "机械臂位置错误,可能未移动出料仓,当前流程停止"); - // break; - //} - if (!IsNumApproximateEqual(currentP.X, pointM1E2SiloDoor.X, 0.5f) || - !IsNumApproximateEqual(currentP.Y, pointM1E2SiloDoor.Y, 0.5f) || - !IsNumApproximateEqual(currentP.Z, pointM1E2SiloDoor.Z, 0.5f) || - !IsNumApproximateEqual(currentP.A, pointM1E2SiloDoor.A, 0.5f) || - !IsNumApproximateEqual(currentP.B, pointM1E2SiloDoor.B, 0.5f) || - !IsNumApproximateEqual(currentP.C, pointM1E2SiloDoor.C, 0.5f)) - { - LogAsync(DateTime.Now, LogLevel.Exception, "机械臂位置错误,可能未移动出料仓,当前流程停止"); - break; - } - - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine1Entrance2UpPoints, 1000, true);//从料仓门口回原点 - - GripperInit(OmronPlc);//夹爪复位 - LogAsync(DateTime.Now, LogLevel.Detail, "夹爪复位"); - - VulcanizaMachineOperateKeep(OmronPlc, "D127 ", "1");//上环升,保持升的状态 - Thread.Sleep(2000); - - //合模之前加入总定型5S - VulcanizaMachineOperateOnce(OmronPlc, "D117", 5000); - VulcanizaMachineOperateKeep(OmronPlc, "D127 ", "0");//上环降 - - //硫化机进入自动状态,0为手动,1为自动 - ProcessWriteInt(OmronPlc, "D103", "int", "1"); - //硫化机合模 - VulcanizaMachineOperateOnce(OmronPlc, "D105", 500); - Thread.Sleep(60000);//等待合模完成 - //机械臂回原点 - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "2号位上料完成。"); - } - - - LogAsync(DateTime.Now, LogLevel.Action, "----1号机上下料完成----"); + ShaftOperateKeep(MelsecPLC, addD3, "0"); + Thread.Sleep(500); + ShaftOperateOnce(MelsecPLC, addD1, 500); + ProcessWriteInt(MelsecPLC, addD171, "int", "3000"); + ShaftOperateKeep(MelsecPLC, addD51, "1"); } + ShaftCommunication = ProcessReadInt(MelsecPLC, addD201, "int"); + continue; + } + else + { + LogAsync(DateTime.Now, LogLevel.Warning, "通讯故障!"); + return; } - //D201: 1为硫化中,0为硫化完成 - string machine2VulcanStateD201 = ProcessReadInt(OmronPlc, addrD201, "int"); - //判断2号机是否开模 - if (machine2VulcanStateD201 == "0") - { - //首先进行下料过程 - string machine1EmergencyStop = ProcessReadInt(OmronPlc, "D111", "int"); - string machine2EmergencyStop = ProcessReadInt(OmronPlc, "D211", "int"); - //判断2号机是否急停 - if (machine2EmergencyStop == "1") - { - LogAsync(DateTime.Now, LogLevel.Exception, "2号硫化机进入急停状态"); - - //判断1号机是否同时急停 - if (machine1EmergencyStop == "1") - { - LogAsync(DateTime.Now, LogLevel.Exception, "1号硫化机同时为急停状态,流程停止"); - //1、2号机都是急停状态,则直接停止流程,不在循环 - - //*把流程停止,把按钮变为--流程开始--*// - - return; - } - else - { - //二号机急停,1号机未急停,继续循环流程 - continue; - } - } - else if (!isMachine1Entrance1Enabled && !isMachine1Entrance2Enabled) - { - LogAsync(DateTime.Now, LogLevel.Error, "2号机已开模,但无已启用的料仓,已跳过。"); - continue; - } - //判断有2号机无可用下料口 - else - { - //有下料口 - ////////////////////////////***********2号机下料***********//////////////////////////// - ////延时20秒 - //Thread.Sleep(20000); - //开模 - VulcanizaMachineOperateOnce(OmronPlc, "D207", 500); - ////延时10秒 - //Thread.Sleep(10000); - //硫化机自动切换为手动,0为手动,1为自动 - ProcessWriteInt(OmronPlc, "D203", "int", "0"); - //硫化机进行总定型动作,总定型3s - VulcanizaMachineOperateOnce(OmronPlc, "D217", 3000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D209", 500); - //硫化机进行抽真空动作,抽真空4s - VulcanizaMachineOperateOnce(OmronPlc, "D225", 4000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D209", 500); - - //移动到初始点 - NbtRobotMove(NbtRobot, initPoint, 1000); - - //1号位下料 - if (isMachine2Entrance1Enabled) - { - LogAsync(DateTime.Now, LogLevel.Detail, "开始2号机1号位下料流程。"); - #region 2号机1号位下料流程 - - //机械臂 从初始点移动到1号位料仓门口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance1DownPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine2Entrance1料仓门口"); - - //移动到取料点上方220 - StrRobotPoint strM2E1TakePoint = ClassChangeStruct(robotPointMachine2Entrance1TakeTyrePos);//取料点 - StrRobotPoint strM2E1TakePointUpper = strM2E1TakePoint;//取料点上方 - strM2E1TakePointUpper.Z = strM2E1TakePoint.Z + 220; - //移动到取料点上方220 - NbtRobotMove(NbtRobot, strM2E1TakePointUpper, 1000); - - LogAsync(DateTime.Now, LogLevel.Detail, $"当前轮胎尺寸:{Machine2Entrance1TireSize}"); - - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - string M2E1DownFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance1TireSize, MoveState.DownFasten); - if (M2E1DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - continue; - } - else - GripperMove(OmronPlc, M2E1DownFastenPos);//夹爪运动 - - //移动到取料点 - NbtRobotMove(NbtRobot, strM2E1TakePoint, 1000); - - //夹爪运动到下料放松点,夹爪(D31,D33)扩张 - //同时开始上定型 - string M2E1DownLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance1TireSize, MoveState.DownLoosen); - if (M2E1DownLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E1DownLoosenPos);//夹爪运动 - - //硫化机进行上定型动作,上定型2s - VulcanizaMachineOperateOnce(OmronPlc, "D213 ", 2000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D209", 500); - //硫化机上环升,硫化机程序内设置保持5S - //VulcanizaMachineOperateOnce(OmronPlc, "D227 ", 5000); - - VulcanizaMachineOperateKeep(OmronPlc, "D227", "1"); - - //从取料点移出 - NbtRobotMove(NbtRobot, strM2E1TakePointUpper, 1000); - //斜向上移动 - StrRobotPoint strM2E1TakeTiltUpperPoint = ClassChangeStruct(robotPointMachine2Entrance1TakeTyreTiltUpperPos); - NbtRobotMove(NbtRobot, strM2E1TakeTiltUpperPoint, 1000); - - VulcanizaMachineOperateKeep(OmronPlc, "D227", "0"); - - - //移动到放置点,反用DownPoints - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance1DownPoints, 1000, true); - - //移动到取料点上方220 - StrRobotPoint strM2E1DownPlacePoint = ClassChangeStruct(robotPointMachine2Entrance1DownPlacePos);//放置点 - StrRobotPoint strM2E1DownPlacePointUpper = strM2E1DownPlacePoint;//放置点上方 - strM2E1DownPlacePointUpper.Z = strM2E1DownPlacePoint.Z + 220; - //移动到放置点上方 - NbtRobotMove(NbtRobot, strM2E1DownPlacePointUpper, 1000); - LogAsync(DateTime.Now, LogLevel.Error, "是否在-<放置点>-加传感器,判断放置点是否已置空??"); - //移动到放置点 - NbtRobotMove(NbtRobot, strM2E1DownPlacePoint, 1000); - - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂从Machine2Entrance1料仓门口移动到放置点"); - - //开始放料 - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - if (M2E1DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E1DownFastenPos);//夹爪运动 - Thread.Sleep(1000); - - //放料完,移走机械臂 - //移动到放置点上方 - NbtRobotMove(NbtRobot, strM2E1DownPlacePointUpper, 1000); - //夹爪运动到放松点 - GripperMove(OmronPlc, NbtRobot.IConfig.GripperLoosenPosition); - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "2号机1号位下料完成。"); - - //1号位下料结束;判断2号位是否需要下料,不需要则机械臂回原点 - if (!isMachine2Entrance2Enabled) - { - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - } - } - - //2号位下料 - if (isMachine2Entrance2Enabled) - { - LogAsync(DateTime.Now, LogLevel.Detail, "开始2号机2号位下料流程。"); - #region 2号机2号位下料流程 - - //机械臂移动到二号位料仓门口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance2DownPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine2Entrance2料仓门口"); - - //移动到取料点上方220 - StrRobotPoint strM2E2TakePoint = ClassChangeStruct(robotPointMachine2Entrance2TakeTyrePos);//取料点 - StrRobotPoint strM2E2TakePointUpper = strM2E2TakePoint;//取料点上方 - strM2E2TakePointUpper.Z = strM2E2TakePoint.Z + 220; - //移动到取料点上方220 - NbtRobotMove(NbtRobot, strM2E2TakePointUpper, 1000); - - LogAsync(DateTime.Now, LogLevel.Detail, $"当前轮胎尺寸:{Machine2Entrance2TireSize}"); - - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - string M2E2DownFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance2TireSize, MoveState.DownFasten); - if (M2E2DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E2DownFastenPos);//夹爪运动 - - //移动到取料点 - NbtRobotMove(NbtRobot, strM2E2TakePoint, 1000);//移动到取料点 - - //夹爪运动到下料放松点,夹爪(D31,D33)扩张 - //同时开始下定型 - string M2E2DownLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance2TireSize, MoveState.DownLoosen); - if (M2E2DownLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E2DownLoosenPos);//夹爪运动 - - //硫化机进行下定型动作2s - VulcanizaMachineOperateOnce(OmronPlc, "D215 ", 2000); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D209", 500); - //硫化机下环升,硫化机程序内设置保持5S - //VulcanizaMachineOperateOnce(OmronPlc, "D229 ", 5000); - VulcanizaMachineOperateKeep(OmronPlc, "D229", "1"); - - //移动到2号位取料点上方220 - NbtRobotMove(NbtRobot, strM2E2TakePointUpper, 1000); - //斜向上移动 - StrRobotPoint strM2E2TakeTiltUpperPoint = ClassChangeStruct(robotPointMachine2Entrance2TakeTyreTiltUpperPos); - NbtRobotMove(NbtRobot, strM2E2TakeTiltUpperPoint, 1000); - - VulcanizaMachineOperateKeep(OmronPlc, "D229", "0"); - - //移动回到放置点 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance2DownPoints, 1000, true); - StrRobotPoint strM2E2DownPlacePoint = ClassChangeStruct(robotPointMachine2Entrance2DownPlacePos);//放置点 - StrRobotPoint strM2E2DownPlacePointUpper = strM2E2DownPlacePoint;//放置点上方 - strM2E2DownPlacePointUpper.Z = strM2E2DownPlacePoint.Z; - //移动到放置点上方 - NbtRobotMove(NbtRobot, strM2E2DownPlacePointUpper, 1000); - LogAsync(DateTime.Now, LogLevel.Error, "是否在-<放置点>-加传感器,判断放置点是否已置空??"); - //移动到放置点 - NbtRobotMove(NbtRobot, strM2E2DownPlacePoint, 1000); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂从Machine2Entrance2料仓门口移动到放置点"); - - //夹爪运动到下料夹紧点,夹爪(D31,D33)夹紧 - if (M2E2DownFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E2DownFastenPos);//夹爪运动 - - Thread.Sleep(5000); - - strM2E2DownPlacePointUpper.Z = strM2E2DownPlacePoint.Z + 220; - NbtRobotMove(NbtRobot, strM2E2DownPlacePointUpper, 1000);//移动到放置点上方 - - GripperMove(OmronPlc, NbtRobot.IConfig.GripperLoosenPosition);//夹爪运动到放松点 - - //二号位下料结束 - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "2号位下料完成。"); - } - - - ////////////////////////////***********2号机上料***********//////////////////////////// - - LogAsync(DateTime.Now, LogLevel.Detail, "开始进行上料过程"); - NbtRobotMove(NbtRobot, initPoint, 1000);//移动到初始点 - - //判断是否硫化完成 - machine2VulcanStateD201 = ProcessReadInt(OmronPlc, addrD201, "int"); - //1号位硫化机开模到位状态,为1时:硫化机开模到位可以进行上下料动作 - //string machine2OpenReadyStateD11 = ProcessReadInt(OmronPlc, addrD11, "int"); - ////胎胚到位,1时:胎坯就位,可以抓取 - //string machine2Entrance1TyreReadyStateD85 = ProcessReadInt(OmronPlc, addrD85, "int"); - //string machine2Entrance2TyreReadyStateD87 = ProcessReadInt(OmronPlc, addrD87, "int"); - - //1号位上料 - //if (machine2VulcanStateD201 == "0" && isMachine2Entrance1Enabled && machine2OpenReadyStateD11 == "1") - if(machine2VulcanStateD201=="0"&&isMachine2Entrance1Enabled) - { - //读D85:1号上料抓取位胎坯就位,等待D05置1胎胚就位 - //while (machine2Entrance1TyreReadyStateD85 == "0") - //{ - // Thread.Sleep(1000); - // machine2Entrance1TyreReadyStateD85 = ProcessReadInt(OmronPlc, addrD85, "int"); - //} - LogAsync(DateTime.Now, LogLevel.Detail, "开始2号机1号位上料流程。"); - #region 2号机1号位上料流程 - - //去抓料 - StrRobotPoint pointMachine2Entrance1GrabPos = ClassChangeStruct(robotPointMachine2Entrance1GrabPos);//抓取点 - StrRobotPoint pointMachine2Entrance1GrabPosUpper = pointMachine2Entrance1GrabPos;//抓取点上方200 - pointMachine2Entrance1GrabPosUpper.Z = pointMachine2Entrance1GrabPos.Z + 200; - NbtRobotMove(NbtRobot, pointMachine2Entrance1GrabPosUpper, 1000); - //夹爪运动到全松点 - GripperMove(OmronPlc, NbtRobot.IConfig.GripperAllLoosenPosition); - NbtRobotMove(NbtRobot, pointMachine2Entrance1GrabPos, 1000);//移动到抓取点 - - //夹爪夹紧 - string M2E1UpFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance1TireSize, MoveState.UpFasten);//获取上料夹紧点 - if (M2E1UpFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E1UpFastenPos);//夹爪运动 - - //抓取轮胎后,根据预设点位移动到上料口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance1UpPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine2Entrance1上料口"); - - //运动到放料点 - StrRobotPoint pointMachine2Entrance1UpPlace = ClassChangeStruct(robotPointMachine2Entrance1UpPlacePos);//放料点 - StrRobotPoint pointMachine2Entrance1UpPlaceUpper = pointMachine2Entrance1UpPlace;//放料点上方200 - pointMachine2Entrance1UpPlaceUpper.Z = pointMachine2Entrance1UpPlace.Z + 200; - //运动到放料点上方200 - NbtRobotMove(NbtRobot, pointMachine2Entrance1UpPlaceUpper, 1000); - //移动到放料点同时,硫化机上环升 - VulcanizaMachineOperateOnce(OmronPlc, "D227 ", 5000);//上环升,硫化机程序内设置保持5S - NbtRobotMove(NbtRobot, pointMachine2Entrance1UpPlace, 1000);//运动到放料点 - - //下定型5秒,其中第2秒时松夹爪、机械臂移动出 - ProcessWriteInt(OmronPlc, "D215", "int", "0"); - Thread.Sleep(500); - ProcessWriteInt(OmronPlc, "D215", "int", "1"); - Thread.Sleep(500); - - //第2秒时,松夹爪、机械臂移动 - //夹爪放松 - string M2E1UpLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance1TireSize, MoveState.UpLoosen);//获取上料放松点 - if (M2E1UpLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E1UpLoosenPos);//夹爪运动 - - //下定型结束 - ProcessWriteInt(OmronPlc, "D215", "int", "0"); - Thread.Sleep(500); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D209", 500); - - NbtRobotMove(NbtRobot, pointMachine2Entrance1UpPlaceUpper, 1000);//运动到放料点上方200 - - StrRobotPoint pointM2E1SiloDoor = ClassChangeStruct(NbtRobot.IConfig.RobotMachine2Entrance1UpPoints[3]);//料仓门口点 - //运动到料仓门口 - NbtRobotMove(NbtRobot, pointM2E1SiloDoor, 1000); - - - //检测机械臂是否移动到料仓外 - StrRobotPoint currentP; - if (IsTesting) - currentP = pointM2E1SiloDoor; - else - currentP = NbtRobot.GetPosition(); - - if (currentP.X != pointM2E1SiloDoor.X || currentP.Y != pointM2E1SiloDoor.Y || currentP.Z != pointM2E1SiloDoor.Z || - currentP.A != pointM2E1SiloDoor.A || currentP.B != pointM2E1SiloDoor.B || currentP.C != pointM2E1SiloDoor.C) - { - LogAsync(DateTime.Now, LogLevel.Exception, "机械臂位置错误,可能未移动出料仓,当前流程停止"); - break; - } - //从料仓门口回原点 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance1UpPoints, 1000, true); - - GripperInit(OmronPlc);//夹爪复位 - LogAsync(DateTime.Now, LogLevel.Detail, "夹爪复位"); - - //1号位上料结束;判断2号位是否需要上料,不需要则机械臂回原点,开始合模 - if (!isMachine2Entrance2Enabled) - { - //硫化机进入自动状态,0为手动,1为自动 - ProcessWriteInt(OmronPlc, "D203", "int", "1"); - //硫化机合模 - VulcanizaMachineOperateOnce(OmronPlc, "D205", 500); - - //2号位不可用时,只硫化1号位 - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - } - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "2号机1号位上料完成。"); - } - - - //machine2OpenReadyStateD11 = ProcessReadInt(OmronPlc, addrD11, "int"); - machine2VulcanStateD201 = ProcessReadInt(OmronPlc, addrD201, "int"); - //machine2Entrance2TyreReadyStateD87 = ProcessReadInt(OmronPlc, addrD87, "int"); - //2号机2号位上料 - //if (machine2VulcanStateD201 == "0" && isMachine2Entrance2Enabled && machine2OpenReadyStateD11 == "1") - if(machine2VulcanStateD201=="0"&&isMachine2Entrance2Enabled) - { - ////读D87:2号上料抓取位胎坯就位,等待D87置1胎胚就位 - //while (machine2Entrance2TyreReadyStateD87 == "0") - //{ - // Thread.Sleep(1000); - // machine2Entrance2TyreReadyStateD87 = ProcessReadInt(OmronPlc, addrD87, "int"); - //} - LogAsync(DateTime.Now, LogLevel.Detail, "开始2号机2号位上料流程。"); - #region 2号机2号位上料流程 - - //去抓料 - StrRobotPoint pointMachine2Entrance2GrabPos = ClassChangeStruct(robotPointMachine2Entrance2GrabPos); - StrRobotPoint pointMachine2Entrance2GrabPosUpper = pointMachine2Entrance2GrabPos; - pointMachine2Entrance2GrabPosUpper.Z = pointMachine2Entrance2GrabPos.Z + 200; - //机械臂移动到抓取点上方200 - NbtRobotMove(NbtRobot, pointMachine2Entrance2GrabPosUpper, 1000); - //夹爪运动到全松点 - GripperMove(OmronPlc, NbtRobot.IConfig.GripperAllLoosenPosition); - //机械臂移动到抓取点 - NbtRobotMove(NbtRobot, pointMachine2Entrance2GrabPos, 1000); - - //夹爪夹紧 - string M2E2UpFastenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance2TireSize, MoveState.UpFasten);//获取上料夹紧点 - if (M2E2UpFastenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E2UpFastenPos);//夹爪运动 - - //抓取轮胎后,根据预设点位移动到上料口 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance2UpPoints, 1000, false); - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂移动到Machine2Entrance2上料口"); - - //运动到放料点 - StrRobotPoint pointMachine2Entrance2UpPlace = ClassChangeStruct(robotPointMachine2Entrance2UpPlacePos);//放料点 - StrRobotPoint pointMachine2Entrance2UpPlaceUpper = pointMachine2Entrance2UpPlace;//放料点上方200 - pointMachine2Entrance2UpPlaceUpper.Z = pointMachine2Entrance2UpPlace.Z + 200; - //运动到放料点上方200 - NbtRobotMove(NbtRobot, pointMachine2Entrance2UpPlaceUpper, 1000); - //移动到放料点同时,硫化机上环升,硫化机程序内设置保持5S - VulcanizaMachineOperateOnce(OmronPlc, "D227 ", 5000); - //运动到放料点 - NbtRobotMove(NbtRobot, pointMachine2Entrance2UpPlace, 1000); - - //下定型5秒,其中第2秒时松夹爪、机械臂移动出 - ProcessWriteInt(OmronPlc, "D215", "int", "0"); - Thread.Sleep(500); - ProcessWriteInt(OmronPlc, "D215", "int", "1"); - Thread.Sleep(500); - - //第2秒时,松夹爪、机械臂移动 - //夹爪放松 - string M2E2UpLoosenPos = GetGripperPosByTyreSize(NbtRobot, Machine2Entrance2TireSize, MoveState.UpLoosen);//获取上料放松点 - if (M2E2UpLoosenPos == "error") - { - LogAsync(DateTime.Now, LogLevel.Error, "夹爪位置错误,当前流程停止"); - break; - } - else - GripperMove(OmronPlc, M2E2UpLoosenPos);//夹爪运动 - - //下定型结束 - ProcessWriteInt(OmronPlc, "D215", "int", "0"); - Thread.Sleep(500); - //硫化机停止 - VulcanizaMachineOperateOnce(OmronPlc, "D209", 500); - - //运动到放料点上方200 - NbtRobotMove(NbtRobot, pointMachine2Entrance2UpPlaceUpper, 1000); - //料仓门口点 - StrRobotPoint pointM2E2SiloDoor = ClassChangeStruct(NbtRobot.IConfig.RobotMachine2Entrance2UpPoints[3]); - NbtRobotMove(NbtRobot, pointM2E2SiloDoor, 1000);//运动到料仓门口 - - - //检测机械臂是否移动到料仓外 - StrRobotPoint currentP; - if (IsTesting) - currentP = pointM2E2SiloDoor; - else - currentP = NbtRobot.GetPosition(); - - if (currentP.X != pointM2E2SiloDoor.X || currentP.Y != pointM2E2SiloDoor.Y || currentP.Z != pointM2E2SiloDoor.Z || - currentP.A != pointM2E2SiloDoor.A || currentP.B != pointM2E2SiloDoor.B || currentP.C != pointM2E2SiloDoor.C) - { - LogAsync(DateTime.Now, LogLevel.Exception, "机械臂位置错误,可能未移动出料仓,当前流程停止"); - break; - } - //从料仓门口回原点 - NbtRobotMoves(NbtRobot, NbtRobot.IConfig.RobotMachine2Entrance2UpPoints, 1000, true); - - GripperInit(OmronPlc);//夹爪复位 - LogAsync(DateTime.Now, LogLevel.Detail, "夹爪复位"); - - //硫化机进入自动状态,0为手动,1为自动 - ProcessWriteInt(OmronPlc, "D203", "int", "1"); - //硫化机合模 - VulcanizaMachineOperateOnce(OmronPlc, "D205", 500); - - //机械臂回原点 - NbtRobotMove(NbtRobot, initPoint, 1000);//回原点 - LogAsync(DateTime.Now, LogLevel.Detail, "机械臂回原点,夹爪回原点。"); - - #endregion - LogAsync(DateTime.Now, LogLevel.Detail, "2号机2号位上料完成。"); - } - - LogAsync(DateTime.Now, LogLevel.Action, "----2号机上下料完成----"); - } - } } + + }); + + LogAsync(DateTime.Now, LogLevel.Action, "流程启动完成!"); PubSubCenter.GetInstance().Publish(PubSubCenterMessageType.IsProcessOpened.ToString(), true, null); return new ProcessResponse(true); @@ -2910,7 +1884,7 @@ namespace BRS.Process.A020 /// PLC驱动 /// PLC地址 /// 一次操作持续多长时间后停止 - public void VulcanizaMachineOperateOnce(PLCBase PLC, string Address, int Duration) + public void ShaftOperateOnce(PLCBase PLC, string Address, int Duration) { //按下前先置0,按下置1,延迟500Ms,模拟人工按下效果后,置0 ProcessWriteInt(PLC, Address, "int", "0"); @@ -2927,7 +1901,7 @@ namespace BRS.Process.A020 /// /// /// 0为降,1为升 - public void VulcanizaMachineOperateKeep(PLCBase PLC, string Address, string status) + public void ShaftOperateKeep(PLCBase PLC, string Address, string status) { //按下前先置0,按下置1,延迟500Ms,模拟人工按下效果后,置0 ProcessWriteInt(PLC, Address, "int", "0"); @@ -3162,7 +2136,6 @@ namespace BRS.Process.A020 } - private string ProcessReadInt(PLCBase PLC, string address, string type, ushort length = 10) { Stopwatch sw = new Stopwatch(); diff --git a/src/BRS.Process.A020/BRS.Process.A020.csproj b/src/BRS.Process.A020/BRS.Process.A020.csproj index 0ece661..af81fcd 100644 --- a/src/BRS.Process.A020/BRS.Process.A020.csproj +++ b/src/BRS.Process.A020/BRS.Process.A020.csproj @@ -120,6 +120,15 @@ ContolPlc.cs + + Component + + + Form + + + ContorlShaft.cs + Form @@ -184,6 +193,9 @@ ContolPlc.cs + + ContorlShaft.cs + ControlSet.cs diff --git a/src/BRS.Process.A020/UI/CircleButton.cs b/src/BRS.Process.A020/UI/CircleButton.cs new file mode 100644 index 0000000..e0f0a9c --- /dev/null +++ b/src/BRS.Process.A020/UI/CircleButton.cs @@ -0,0 +1,24 @@ +using System; +using System.Collections.Generic; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; + +namespace BRS.Process.A020.UI +{ + public class CircleButton:Button + { + protected override void OnPaint(PaintEventArgs e)//重新设置控件的形状 protected 保护 override重新 + { + base.OnPaint(e);//递归 每次重新都发生此方法,保证其形状为自定义形状 + System.Drawing.Drawing2D.GraphicsPath path = new System.Drawing.Drawing2D.GraphicsPath(); + path.AddEllipse(2, 2, this.Width - 6, this.Height - 6); + Graphics g = e.Graphics; + g.DrawEllipse(new Pen(Color.Black, 2), 2, 2, Width - 6, Height - 6); + Region = new Region(path); + } + + } +} diff --git a/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs b/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs new file mode 100644 index 0000000..0770cda --- /dev/null +++ b/src/BRS.Process.A020/UI/ContorlShaft.Designer.cs @@ -0,0 +1,247 @@ + +namespace BRS.Process.A020.UI +{ + partial class 扭矩轴控制 + { + /// + /// Required designer variable. + /// + private System.ComponentModel.IContainer components = null; + + /// + /// Clean up any resources being used. + /// + /// true if managed resources should be disposed; otherwise, false. + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// + private void InitializeComponent() + { + this.TorqueSettingBtn = new Sunny.UI.UIButton(); + this.StartBtn = new Sunny.UI.UIButton(); + this.ToughBtn = new Sunny.UI.UIButton(); + this.LoosenBtn = new Sunny.UI.UIButton(); + this.StopBtn = new Sunny.UI.UIButton(); + this.ManualOrAuto = new Sunny.UI.UIButton(); + this.uiBarChart1 = new Sunny.UI.UIBarChart(); + this.uiBarChart2 = new Sunny.UI.UIBarChart(); + this.MoveStateLabel = new Sunny.UI.UILabel(); + this.StopStateLabel = new Sunny.UI.UILabel(); + this.EmengencyStopBtn = new BRS.Process.A020.UI.CircleButton(); + this.StopStateLight = new BRS.Process.A020.UI.CircleButton(); + this.MoveStateLight = new BRS.Process.A020.UI.CircleButton(); + this.SuspendLayout(); + // + // TorqueSettingBtn + // + this.TorqueSettingBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.TorqueSettingBtn.Font = new System.Drawing.Font("宋体", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.TorqueSettingBtn.Location = new System.Drawing.Point(169, 392); + this.TorqueSettingBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.TorqueSettingBtn.Name = "TorqueSettingBtn"; + this.TorqueSettingBtn.RightToLeft = System.Windows.Forms.RightToLeft.No; + this.TorqueSettingBtn.Size = new System.Drawing.Size(124, 46); + this.TorqueSettingBtn.TabIndex = 2; + this.TorqueSettingBtn.Text = "最大扭矩设置"; + this.TorqueSettingBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.TorqueSettingBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // StartBtn + // + this.StartBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.StartBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StartBtn.Location = new System.Drawing.Point(180, 215); + this.StartBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.StartBtn.Name = "StartBtn"; + this.StartBtn.Size = new System.Drawing.Size(100, 35); + this.StartBtn.TabIndex = 3; + this.StartBtn.Text = "开始"; + this.StartBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StartBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.StartBtn.Click += new System.EventHandler(this.StartBtn_Click); + this.StartBtn.MouseDown += new System.Windows.Forms.MouseEventHandler(this.StartBtn_MouseDown); + this.StartBtn.MouseUp += new System.Windows.Forms.MouseEventHandler(this.StartBtn_MouseUp); + // + // ToughBtn + // + this.ToughBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.ToughBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ToughBtn.Location = new System.Drawing.Point(367, 215); + this.ToughBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.ToughBtn.Name = "ToughBtn"; + this.ToughBtn.Size = new System.Drawing.Size(100, 35); + this.ToughBtn.TabIndex = 4; + this.ToughBtn.Text = "手动拧紧"; + this.ToughBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ToughBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // LoosenBtn + // + this.LoosenBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.LoosenBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.LoosenBtn.Location = new System.Drawing.Point(367, 293); + this.LoosenBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.LoosenBtn.Name = "LoosenBtn"; + this.LoosenBtn.Size = new System.Drawing.Size(100, 35); + this.LoosenBtn.TabIndex = 5; + this.LoosenBtn.Text = "手动拧松"; + this.LoosenBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.LoosenBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // StopBtn + // + this.StopBtn.Cursor = System.Windows.Forms.Cursors.Hand; + this.StopBtn.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StopBtn.Location = new System.Drawing.Point(180, 293); + this.StopBtn.MinimumSize = new System.Drawing.Size(1, 1); + this.StopBtn.Name = "StopBtn"; + this.StopBtn.Size = new System.Drawing.Size(100, 35); + this.StopBtn.TabIndex = 6; + this.StopBtn.Text = "停止"; + this.StopBtn.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StopBtn.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.StopBtn.Click += new System.EventHandler(this.StopBtn_Click); + // + // ManualOrAuto + // + this.ManualOrAuto.Cursor = System.Windows.Forms.Cursors.Hand; + this.ManualOrAuto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ManualOrAuto.Location = new System.Drawing.Point(367, 400); + this.ManualOrAuto.MinimumSize = new System.Drawing.Size(1, 1); + this.ManualOrAuto.Name = "ManualOrAuto"; + this.ManualOrAuto.Size = new System.Drawing.Size(100, 35); + this.ManualOrAuto.TabIndex = 7; + this.ManualOrAuto.Text = "手动/自动"; + this.ManualOrAuto.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.ManualOrAuto.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // uiBarChart1 + // + this.uiBarChart1.Dock = System.Windows.Forms.DockStyle.Right; + this.uiBarChart1.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiBarChart1.LegendFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiBarChart1.Location = new System.Drawing.Point(870, 0); + this.uiBarChart1.MinimumSize = new System.Drawing.Size(1, 1); + this.uiBarChart1.Name = "uiBarChart1"; + this.uiBarChart1.Size = new System.Drawing.Size(346, 568); + this.uiBarChart1.SubFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiBarChart1.TabIndex = 8; + this.uiBarChart1.Text = "uiBarChart1"; + this.uiBarChart1.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // uiBarChart2 + // + this.uiBarChart2.Dock = System.Windows.Forms.DockStyle.Right; + this.uiBarChart2.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiBarChart2.LegendFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiBarChart2.Location = new System.Drawing.Point(524, 0); + this.uiBarChart2.MinimumSize = new System.Drawing.Size(1, 1); + this.uiBarChart2.Name = "uiBarChart2"; + this.uiBarChart2.Size = new System.Drawing.Size(346, 568); + this.uiBarChart2.SubFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.uiBarChart2.TabIndex = 9; + this.uiBarChart2.Text = "uiBarChart2"; + this.uiBarChart2.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // MoveStateLabel + // + this.MoveStateLabel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.MoveStateLabel.Location = new System.Drawing.Point(165, 111); + this.MoveStateLabel.Name = "MoveStateLabel"; + this.MoveStateLabel.Size = new System.Drawing.Size(125, 23); + this.MoveStateLabel.TabIndex = 10; + this.MoveStateLabel.Text = "运动状态指示灯"; + this.MoveStateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleCenter; + this.MoveStateLabel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // StopStateLabel + // + this.StopStateLabel.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.StopStateLabel.Location = new System.Drawing.Point(354, 111); + this.StopStateLabel.Name = "StopStateLabel"; + this.StopStateLabel.Size = new System.Drawing.Size(125, 23); + this.StopStateLabel.TabIndex = 11; + this.StopStateLabel.Text = "停止状态指示灯"; + this.StopStateLabel.TextAlign = System.Drawing.ContentAlignment.MiddleLeft; + this.StopStateLabel.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // EmengencyStopBtn + // + this.EmengencyStopBtn.BackColor = System.Drawing.Color.Red; + this.EmengencyStopBtn.Font = new System.Drawing.Font("宋体", 27.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0))); + this.EmengencyStopBtn.Location = new System.Drawing.Point(12, 203); + this.EmengencyStopBtn.Name = "EmengencyStopBtn"; + this.EmengencyStopBtn.Size = new System.Drawing.Size(124, 125); + this.EmengencyStopBtn.TabIndex = 12; + this.EmengencyStopBtn.Text = "急停"; + this.EmengencyStopBtn.UseVisualStyleBackColor = false; + // + // StopStateLight + // + this.StopStateLight.Location = new System.Drawing.Point(379, 33); + this.StopStateLight.Name = "StopStateLight"; + this.StopStateLight.Size = new System.Drawing.Size(76, 75); + this.StopStateLight.TabIndex = 1; + this.StopStateLight.UseVisualStyleBackColor = true; + // + // MoveStateLight + // + this.MoveStateLight.Location = new System.Drawing.Point(193, 33); + this.MoveStateLight.Name = "MoveStateLight"; + this.MoveStateLight.Size = new System.Drawing.Size(76, 75); + this.MoveStateLight.TabIndex = 0; + this.MoveStateLight.UseVisualStyleBackColor = true; + // + // 扭矩轴控制 + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(1216, 568); + this.Controls.Add(this.EmengencyStopBtn); + this.Controls.Add(this.StopStateLabel); + this.Controls.Add(this.MoveStateLabel); + this.Controls.Add(this.uiBarChart2); + this.Controls.Add(this.uiBarChart1); + this.Controls.Add(this.ManualOrAuto); + this.Controls.Add(this.StopBtn); + this.Controls.Add(this.LoosenBtn); + this.Controls.Add(this.ToughBtn); + this.Controls.Add(this.StartBtn); + this.Controls.Add(this.TorqueSettingBtn); + this.Controls.Add(this.StopStateLight); + this.Controls.Add(this.MoveStateLight); + this.Name = "扭矩轴控制"; + this.Text = "ContorlShaft"; + this.ResumeLayout(false); + + } + + #endregion + + private CircleButton MoveStateLight; + private CircleButton StopStateLight; + private Sunny.UI.UIButton TorqueSettingBtn; + private Sunny.UI.UIButton StartBtn; + private Sunny.UI.UIButton ToughBtn; + private Sunny.UI.UIButton LoosenBtn; + private Sunny.UI.UIButton StopBtn; + private Sunny.UI.UIButton ManualOrAuto; + private Sunny.UI.UIBarChart uiBarChart1; + private Sunny.UI.UIBarChart uiBarChart2; + private Sunny.UI.UILabel MoveStateLabel; + private Sunny.UI.UILabel StopStateLabel; + private CircleButton EmengencyStopBtn; + } +} \ No newline at end of file diff --git a/src/BRS.Process.A020/UI/ContorlShaft.cs b/src/BRS.Process.A020/UI/ContorlShaft.cs new file mode 100644 index 0000000..23e2898 --- /dev/null +++ b/src/BRS.Process.A020/UI/ContorlShaft.cs @@ -0,0 +1,62 @@ +using BRS.UI.Model.Winform; +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows.Forms; +using static BRS.Common.Model.Helper.EnumHelper; + +namespace BRS.Process.A020.UI +{ + [MenuNode("ControlShaft", "扭矩轴控制", 5, "View2", true)] + public partial class 扭矩轴控制 : MenuFormBase + { + private bool is_btn_manual { get; set; } = false; + A020Process ProcessA020 => Process as A020Process; + A020Config Config => Process?.IConfig as A020Config; + + private bool isSingleStepOperating = false; + public 扭矩轴控制() + { + InitializeComponent(); + } + + private void StartBtn_Click(object sender, EventArgs e) + { + + } + + private void StartBtn_MouseDown(object sender, MouseEventArgs e) + { + this.MoveStateLight.BackColor = Color.GreenYellow; + if (!ProcessA020.IsSingleStepOperating) + { + ProcessA020.IsSingleStepOperating = true; + ProcessA020.ShaftRightMouseDown(MachineState.Ready); + } + else + LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); + } + + private void StartBtn_MouseUp(object sender, MouseEventArgs e) + { + this.MoveStateLight.BackColor = Color.Red; + if (!ProcessA020.IsSingleStepOperating) + { + ProcessA020.IsSingleStepOperating = true; + ProcessA020.ShaftRightMouseUp(MachineState.Ready); + } + else + LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); + } + + private void StopBtn_Click(object sender, EventArgs e) + { + this.MoveStateLight.BackColor = Color.Gray; + } + } +} diff --git a/src/BRS.Process.A020/UI/ContorlShaft.resx b/src/BRS.Process.A020/UI/ContorlShaft.resx new file mode 100644 index 0000000..1af7de1 --- /dev/null +++ b/src/BRS.Process.A020/UI/ContorlShaft.resx @@ -0,0 +1,120 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + \ No newline at end of file diff --git a/src/BRS.Process.A020/UI/ControlSet.Designer.cs b/src/BRS.Process.A020/UI/ControlSet.Designer.cs index 5e7b0c9..744a258 100644 --- a/src/BRS.Process.A020/UI/ControlSet.Designer.cs +++ b/src/BRS.Process.A020/UI/ControlSet.Designer.cs @@ -29,15 +29,6 @@ namespace BRS.Process.A020.UI /// private void InitializeComponent() { - this.uiTableLayoutPanel1 = new Sunny.UI.UITableLayoutPanel(); - this.btn_start = new Sunny.UI.UIButton(); - this.btn_pause = new Sunny.UI.UIButton(); - this.btn_stop = new Sunny.UI.UIButton(); - this.btn_manual = new Sunny.UI.UIButton(); - this.btn_auto = new Sunny.UI.UIButton(); - this.btn_reset = new Sunny.UI.UIButton(); - this.btn_plcset = new Sunny.UI.UIButton(); - this.btn_robotset = new Sunny.UI.UIButton(); this.splitContainer1 = new System.Windows.Forms.SplitContainer(); this.uiTitlePanel1 = new Sunny.UI.UITitlePanel(); this.uiPanel2 = new Sunny.UI.UIPanel(); @@ -61,7 +52,15 @@ namespace BRS.Process.A020.UI this.btn_load2_1 = new Sunny.UI.UIButton(); this.cmb_sizechoose2_1 = new Sunny.UI.UIComboBox(); this.uiPanel8 = new Sunny.UI.UIPanel(); - this.uiTableLayoutPanel1.SuspendLayout(); + this.btn_robotset = new Sunny.UI.UIButton(); + this.btn_plcset = new Sunny.UI.UIButton(); + this.btn_reset = new Sunny.UI.UIButton(); + this.btn_auto = new Sunny.UI.UIButton(); + this.btn_manual = new Sunny.UI.UIButton(); + this.btn_stop = new Sunny.UI.UIButton(); + this.btn_pause = new Sunny.UI.UIButton(); + this.btn_start = new Sunny.UI.UIButton(); + this.uiTableLayoutPanel1 = new Sunny.UI.UITableLayoutPanel(); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit(); this.splitContainer1.Panel1.SuspendLayout(); this.splitContainer1.Panel2.SuspendLayout(); @@ -72,162 +71,9 @@ namespace BRS.Process.A020.UI this.uiTitlePanel2.SuspendLayout(); this.uiPanel5.SuspendLayout(); this.uiPanel7.SuspendLayout(); + this.uiTableLayoutPanel1.SuspendLayout(); this.SuspendLayout(); // - // uiTableLayoutPanel1 - // - this.uiTableLayoutPanel1.ColumnCount = 1; - this.uiTableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); - this.uiTableLayoutPanel1.Controls.Add(this.btn_start, 0, 0); - this.uiTableLayoutPanel1.Controls.Add(this.btn_pause, 0, 1); - this.uiTableLayoutPanel1.Controls.Add(this.btn_stop, 0, 2); - this.uiTableLayoutPanel1.Controls.Add(this.btn_manual, 0, 3); - this.uiTableLayoutPanel1.Controls.Add(this.btn_auto, 0, 4); - this.uiTableLayoutPanel1.Controls.Add(this.btn_reset, 0, 5); - this.uiTableLayoutPanel1.Controls.Add(this.btn_plcset, 0, 6); - this.uiTableLayoutPanel1.Controls.Add(this.btn_robotset, 0, 7); - this.uiTableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Left; - this.uiTableLayoutPanel1.Location = new System.Drawing.Point(0, 0); - this.uiTableLayoutPanel1.Name = "uiTableLayoutPanel1"; - this.uiTableLayoutPanel1.RowCount = 8; - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); - this.uiTableLayoutPanel1.Size = new System.Drawing.Size(112, 545); - this.uiTableLayoutPanel1.TabIndex = 5; - this.uiTableLayoutPanel1.TagString = null; - // - // btn_start - // - this.btn_start.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_start.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_start.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_start.Location = new System.Drawing.Point(3, 13); - this.btn_start.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_start.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_start.Name = "btn_start"; - this.btn_start.Size = new System.Drawing.Size(106, 42); - this.btn_start.TabIndex = 0; - this.btn_start.Text = "启动"; - this.btn_start.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_start.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.btn_start.Click += new System.EventHandler(this.btn_start_Click); - // - // btn_pause - // - this.btn_pause.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_pause.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_pause.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_pause.Location = new System.Drawing.Point(3, 81); - this.btn_pause.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_pause.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_pause.Name = "btn_pause"; - this.btn_pause.Radius = 1; - this.btn_pause.Size = new System.Drawing.Size(106, 42); - this.btn_pause.TabIndex = 1; - this.btn_pause.Text = "暂停"; - this.btn_pause.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_pause.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - // - // btn_stop - // - this.btn_stop.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_stop.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_stop.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_stop.Location = new System.Drawing.Point(3, 149); - this.btn_stop.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_stop.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_stop.Name = "btn_stop"; - this.btn_stop.Size = new System.Drawing.Size(106, 42); - this.btn_stop.TabIndex = 2; - this.btn_stop.Text = "停止"; - this.btn_stop.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_stop.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click); - // - // btn_manual - // - this.btn_manual.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_manual.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_manual.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_manual.Location = new System.Drawing.Point(3, 217); - this.btn_manual.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_manual.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_manual.Name = "btn_manual"; - this.btn_manual.Size = new System.Drawing.Size(106, 42); - this.btn_manual.Style = Sunny.UI.UIStyle.Custom; - this.btn_manual.TabIndex = 3; - this.btn_manual.Text = "手动"; - this.btn_manual.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_manual.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.btn_manual.Click += new System.EventHandler(this.btn_manual_Click); - // - // btn_auto - // - this.btn_auto.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_auto.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_auto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_auto.Location = new System.Drawing.Point(3, 285); - this.btn_auto.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_auto.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_auto.Name = "btn_auto"; - this.btn_auto.Size = new System.Drawing.Size(106, 42); - this.btn_auto.TabIndex = 4; - this.btn_auto.Text = "自动"; - this.btn_auto.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_auto.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - this.btn_auto.Click += new System.EventHandler(this.btn_auto_Click); - // - // btn_reset - // - this.btn_reset.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_reset.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_reset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_reset.Location = new System.Drawing.Point(3, 353); - this.btn_reset.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_reset.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_reset.Name = "btn_reset"; - this.btn_reset.Size = new System.Drawing.Size(106, 42); - this.btn_reset.TabIndex = 5; - this.btn_reset.Text = "复位"; - this.btn_reset.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_reset.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - // - // btn_plcset - // - this.btn_plcset.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_plcset.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_plcset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_plcset.Location = new System.Drawing.Point(3, 421); - this.btn_plcset.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_plcset.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_plcset.Name = "btn_plcset"; - this.btn_plcset.Size = new System.Drawing.Size(106, 42); - this.btn_plcset.TabIndex = 6; - this.btn_plcset.Text = "PLC设置"; - this.btn_plcset.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_plcset.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - // - // btn_robotset - // - this.btn_robotset.Cursor = System.Windows.Forms.Cursors.Hand; - this.btn_robotset.Dock = System.Windows.Forms.DockStyle.Fill; - this.btn_robotset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_robotset.Location = new System.Drawing.Point(3, 489); - this.btn_robotset.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); - this.btn_robotset.MinimumSize = new System.Drawing.Size(1, 1); - this.btn_robotset.Name = "btn_robotset"; - this.btn_robotset.Size = new System.Drawing.Size(106, 43); - this.btn_robotset.TabIndex = 7; - this.btn_robotset.Text = "ROBOT设置"; - this.btn_robotset.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); - this.btn_robotset.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); - // // splitContainer1 // this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill; @@ -635,6 +481,162 @@ namespace BRS.Process.A020.UI this.uiPanel8.TextAlignment = System.Drawing.ContentAlignment.MiddleCenter; this.uiPanel8.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); // + // btn_robotset + // + this.btn_robotset.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_robotset.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_robotset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_robotset.Location = new System.Drawing.Point(3, 489); + this.btn_robotset.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_robotset.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_robotset.Name = "btn_robotset"; + this.btn_robotset.Size = new System.Drawing.Size(106, 43); + this.btn_robotset.TabIndex = 7; + this.btn_robotset.Text = "ROBOT设置"; + this.btn_robotset.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_robotset.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // btn_plcset + // + this.btn_plcset.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_plcset.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_plcset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_plcset.Location = new System.Drawing.Point(3, 421); + this.btn_plcset.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_plcset.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_plcset.Name = "btn_plcset"; + this.btn_plcset.Size = new System.Drawing.Size(106, 42); + this.btn_plcset.TabIndex = 6; + this.btn_plcset.Text = "PLC设置"; + this.btn_plcset.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_plcset.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // btn_reset + // + this.btn_reset.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_reset.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_reset.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_reset.Location = new System.Drawing.Point(3, 353); + this.btn_reset.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_reset.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_reset.Name = "btn_reset"; + this.btn_reset.Size = new System.Drawing.Size(106, 42); + this.btn_reset.TabIndex = 5; + this.btn_reset.Text = "复位"; + this.btn_reset.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_reset.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // btn_auto + // + this.btn_auto.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_auto.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_auto.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_auto.Location = new System.Drawing.Point(3, 285); + this.btn_auto.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_auto.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_auto.Name = "btn_auto"; + this.btn_auto.Size = new System.Drawing.Size(106, 42); + this.btn_auto.TabIndex = 4; + this.btn_auto.Text = "自动"; + this.btn_auto.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_auto.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.btn_auto.Click += new System.EventHandler(this.btn_auto_Click); + // + // btn_manual + // + this.btn_manual.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_manual.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_manual.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_manual.Location = new System.Drawing.Point(3, 217); + this.btn_manual.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_manual.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_manual.Name = "btn_manual"; + this.btn_manual.Size = new System.Drawing.Size(106, 42); + this.btn_manual.TabIndex = 3; + this.btn_manual.Text = "手动"; + this.btn_manual.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_manual.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.btn_manual.Click += new System.EventHandler(this.btn_manual_Click); + // + // btn_stop + // + this.btn_stop.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_stop.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_stop.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_stop.Location = new System.Drawing.Point(3, 149); + this.btn_stop.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_stop.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_stop.Name = "btn_stop"; + this.btn_stop.Size = new System.Drawing.Size(106, 42); + this.btn_stop.TabIndex = 2; + this.btn_stop.Text = "停止"; + this.btn_stop.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_stop.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.btn_stop.Click += new System.EventHandler(this.btn_stop_Click); + // + // btn_pause + // + this.btn_pause.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_pause.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_pause.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_pause.Location = new System.Drawing.Point(3, 81); + this.btn_pause.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_pause.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_pause.Name = "btn_pause"; + this.btn_pause.Radius = 1; + this.btn_pause.Size = new System.Drawing.Size(106, 42); + this.btn_pause.TabIndex = 1; + this.btn_pause.Text = "暂停"; + this.btn_pause.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_pause.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + // + // btn_start + // + this.btn_start.Cursor = System.Windows.Forms.Cursors.Hand; + this.btn_start.Dock = System.Windows.Forms.DockStyle.Fill; + this.btn_start.Font = new System.Drawing.Font("微软雅黑", 12F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_start.Location = new System.Drawing.Point(3, 13); + this.btn_start.Margin = new System.Windows.Forms.Padding(3, 13, 3, 13); + this.btn_start.MinimumSize = new System.Drawing.Size(1, 1); + this.btn_start.Name = "btn_start"; + this.btn_start.Size = new System.Drawing.Size(106, 42); + this.btn_start.TabIndex = 0; + this.btn_start.Text = "启动"; + this.btn_start.TipsFont = new System.Drawing.Font("微软雅黑", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134))); + this.btn_start.ZoomScaleRect = new System.Drawing.Rectangle(0, 0, 0, 0); + this.btn_start.Click += new System.EventHandler(this.btn_start_Click); + this.btn_start.MouseDown += new System.Windows.Forms.MouseEventHandler(this.btn_start_MouseDown); + this.btn_start.MouseUp += new System.Windows.Forms.MouseEventHandler(this.btn_start_MouseUp); + // + // uiTableLayoutPanel1 + // + this.uiTableLayoutPanel1.ColumnCount = 1; + this.uiTableLayoutPanel1.ColumnStyles.Add(new System.Windows.Forms.ColumnStyle(System.Windows.Forms.SizeType.Percent, 100F)); + this.uiTableLayoutPanel1.Controls.Add(this.btn_start, 0, 0); + this.uiTableLayoutPanel1.Controls.Add(this.btn_pause, 0, 1); + this.uiTableLayoutPanel1.Controls.Add(this.btn_stop, 0, 2); + this.uiTableLayoutPanel1.Controls.Add(this.btn_manual, 0, 3); + this.uiTableLayoutPanel1.Controls.Add(this.btn_auto, 0, 4); + this.uiTableLayoutPanel1.Controls.Add(this.btn_reset, 0, 5); + this.uiTableLayoutPanel1.Controls.Add(this.btn_plcset, 0, 6); + this.uiTableLayoutPanel1.Controls.Add(this.btn_robotset, 0, 7); + this.uiTableLayoutPanel1.Dock = System.Windows.Forms.DockStyle.Left; + this.uiTableLayoutPanel1.Location = new System.Drawing.Point(0, 0); + this.uiTableLayoutPanel1.Name = "uiTableLayoutPanel1"; + this.uiTableLayoutPanel1.RowCount = 8; + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.RowStyles.Add(new System.Windows.Forms.RowStyle(System.Windows.Forms.SizeType.Percent, 12.5F)); + this.uiTableLayoutPanel1.Size = new System.Drawing.Size(112, 545); + this.uiTableLayoutPanel1.TabIndex = 5; + this.uiTableLayoutPanel1.TagString = null; + this.uiTableLayoutPanel1.Paint += new System.Windows.Forms.PaintEventHandler(this.uiTableLayoutPanel1_Paint); + // // ControlSet // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); @@ -645,7 +647,6 @@ namespace BRS.Process.A020.UI this.Name = "ControlSet"; this.Text = "控制设置"; this.Load += new System.EventHandler(this.ControlSet_Load); - this.uiTableLayoutPanel1.ResumeLayout(false); this.splitContainer1.Panel1.ResumeLayout(false); this.splitContainer1.Panel2.ResumeLayout(false); ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit(); @@ -656,21 +657,22 @@ namespace BRS.Process.A020.UI this.uiTitlePanel2.ResumeLayout(false); this.uiPanel5.ResumeLayout(false); this.uiPanel7.ResumeLayout(false); + this.uiTableLayoutPanel1.ResumeLayout(false); this.ResumeLayout(false); } #endregion - private Sunny.UI.UITableLayoutPanel uiTableLayoutPanel1; - private Sunny.UI.UIButton btn_start; - private Sunny.UI.UIButton btn_pause; - private Sunny.UI.UIButton btn_stop; - private Sunny.UI.UIButton btn_manual; - private Sunny.UI.UIButton btn_auto; - private Sunny.UI.UIButton btn_reset; - private Sunny.UI.UIButton btn_plcset; - private Sunny.UI.UIButton btn_robotset; private System.Windows.Forms.SplitContainer splitContainer1; + private Sunny.UI.UIButton btn_robotset; + private Sunny.UI.UIButton btn_plcset; + private Sunny.UI.UIButton btn_reset; + private Sunny.UI.UIButton btn_auto; + private Sunny.UI.UIButton btn_manual; + private Sunny.UI.UIButton btn_stop; + private Sunny.UI.UIButton btn_pause; + private Sunny.UI.UIButton btn_start; + private Sunny.UI.UITableLayoutPanel uiTableLayoutPanel1; private Sunny.UI.UITitlePanel uiTitlePanel1; private Sunny.UI.UIPanel uiPanel2; private Sunny.UI.UIButton btn_down1_2; @@ -679,6 +681,7 @@ namespace BRS.Process.A020.UI private Sunny.UI.UIPanel uiPanel4; private Sunny.UI.UIPanel uiPanel1; private Sunny.UI.UIButton btn_down1_1; + private Sunny.UI.UIComboBox cmb_sizechoose1_1; private Sunny.UI.UIButton btn_load1_1; private Sunny.UI.UIPanel uiPanel3; private Sunny.UI.UITitlePanel uiTitlePanel2; @@ -692,6 +695,5 @@ namespace BRS.Process.A020.UI private Sunny.UI.UIButton btn_load2_1; private Sunny.UI.UIComboBox cmb_sizechoose2_1; private Sunny.UI.UIPanel uiPanel8; - private Sunny.UI.UIComboBox cmb_sizechoose1_1; } } \ No newline at end of file diff --git a/src/BRS.Process.A020/UI/ControlSet.cs b/src/BRS.Process.A020/UI/ControlSet.cs index ac43095..68a3a3a 100644 --- a/src/BRS.Process.A020/UI/ControlSet.cs +++ b/src/BRS.Process.A020/UI/ControlSet.cs @@ -41,9 +41,11 @@ namespace BRS.Process.A020.UI private void btn_start_Click(object sender, EventArgs e) { - + //流程正转启动按钮 + } + private void ControlSet_Load(object sender, EventArgs e) { //cmb_sizechoose1_1.SelectedIndex = 0; @@ -247,7 +249,7 @@ namespace BRS.Process.A020.UI if (item.Value.location == 0) Machine1Entrance1TyreSize = item.Value.tyreSize; } - ProcessA020.Machine1Entrance1Up(Machine1Entrance1TyreSize); + //ProcessA020.Machine1Entrance1Up(Machine1Entrance1TyreSize); } else LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); @@ -266,7 +268,7 @@ namespace BRS.Process.A020.UI if (item.Value.location == 0) Machine1Entrance1TyreSize = item.Value.tyreSize; } - ProcessA020.Machine1Entrance1Down(Machine1Entrance1TyreSize); + //ProcessA020.Machine1Entrance1Down(Machine1Entrance1TyreSize); } else LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); @@ -285,7 +287,7 @@ namespace BRS.Process.A020.UI if (item.Value.location == 1) Machine1Entrance2TyreSize = item.Value.tyreSize; } - ProcessA020.Machine1Entrance2Down(Machine1Entrance2TyreSize); + //ProcessA020.Machine1Entrance2Down(Machine1Entrance2TyreSize); } else LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); @@ -305,7 +307,7 @@ namespace BRS.Process.A020.UI if (item.Value.location == 1) Machine1Entrance2TyreSize = item.Value.tyreSize; } - ProcessA020.Machine1Entrance2Up(Machine1Entrance2TyreSize); + //ProcessA020.Machine1Entrance2Up(Machine1Entrance2TyreSize); } else LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); @@ -331,6 +333,33 @@ namespace BRS.Process.A020.UI ProcessA020.Machine1SwitchAutoManual(true); } + + private void uiTableLayoutPanel1_Paint(object sender, PaintEventArgs e) + { + + } + + private void btn_start_MouseDown(object sender, MouseEventArgs e) + { + if (!ProcessA020.IsSingleStepOperating) + { + ProcessA020.IsSingleStepOperating = true; + ProcessA020.ShaftRightMouseDown(MachineState.Ready); + } + else + LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); + } + + private void btn_start_MouseUp(object sender, MouseEventArgs e) + { + if (!ProcessA020.IsSingleStepOperating) + { + ProcessA020.IsSingleStepOperating = true; + ProcessA020.ShaftRightMouseUp(MachineState.Ready); + } + else + LogAsync(DateTime.Now, LogLevel.Error, $"有未完成的操作。"); + } } } diff --git a/src/BRS.Process.A020/UI/OperationFrm.resx b/src/BRS.Process.A020/UI/OperationFrm.resx index 7768940..66bbe7f 100644 --- a/src/BRS.Process.A020/UI/OperationFrm.resx +++ b/src/BRS.Process.A020/UI/OperationFrm.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAAy - CwAAAk1TRnQBSQFMAgEBBAEAAfABBAHwAQQBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CwAAAk1TRnQBSQFMAgEBBAEAAQgBBQEIAQUBEAEAARABAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABQAMAASADAAEBAQABCAYAAQgYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA diff --git a/src/BRS.UI.Device.Winform/CtrlPLCRunBase.cs b/src/BRS.UI.Device.Winform/CtrlPLCRunBase.cs index e08c084..3ab886f 100644 --- a/src/BRS.UI.Device.Winform/CtrlPLCRunBase.cs +++ b/src/BRS.UI.Device.Winform/CtrlPLCRunBase.cs @@ -11,6 +11,7 @@ using BRS.Common.Interface; using BRS.Common.Base; using static BRS.Common.Model.Helper.EnumHelper; using System.Diagnostics; +using System.Collections.Concurrent; namespace BRS.UI.Device.Winform { @@ -195,7 +196,9 @@ namespace BRS.UI.Device.Winform } List oldValues = null; - Dictionary _cellChangedTimerDict = new Dictionary(); + private ConcurrentDictionary _cellChangedTimerDict = new ConcurrentDictionary(); + + //Dictionary _cellChangedTimerDict = new Dictionary(); private void OnRefreshMonitorValues(object state) { if (PLC.CurrentState != DeviceState.DSOpen || !dgvMonitor.IsHandleCreated) @@ -255,15 +258,25 @@ namespace BRS.UI.Device.Winform cell.Value = GetSignedIntValue(newValues[i]); cell.Style.BackColor = Color.PaleGreen; cell.Style.ForeColor = Color.Red; - - if (!_cellChangedTimerDict.ContainsKey(i)) + try { - _cellChangedTimerDict[i] = new System.Threading.Timer(OnChangedDisplayTimeout, new object[] { cell, i }, 1000, -1); + if (!_cellChangedTimerDict.ContainsKey(i)) + { + var timer = new System.Threading.Timer(OnChangedDisplayTimeout, new object[] { cell, i }, 1000, -1); + //_cellChangedTimerDict[i] = new System.Threading.Timer(OnChangedDisplayTimeout, new object[] { cell, i }, 1000, -1); + _cellChangedTimerDict.TryAdd(i, timer); + + } + else + { + _cellChangedTimerDict[i].Change(1000, -1); + } } - else + catch(Exception ex) { - _cellChangedTimerDict[i].Change(1000, -1); + OnChangedDisplayTimeout(new object[] { cell, i }); } + } } } @@ -379,7 +392,9 @@ namespace BRS.UI.Device.Winform cell.Style.BackColor = SystemColors.Control; cell.Style.ForeColor = SystemColors.ControlText; - _cellChangedTimerDict.Remove(index); + _cellChangedTimerDict.TryRemove(index, out System.Threading.Timer _); + + //_cellChangedTimerDict.Remove(index); } private void btnReadInt_Click(object sender, EventArgs e) diff --git a/src/BRS.UI.Main/MenuForms/FrmOperation.resx b/src/BRS.UI.Main/MenuForms/FrmOperation.resx index 1c28b69..18b0e0c 100644 --- a/src/BRS.UI.Main/MenuForms/FrmOperation.resx +++ b/src/BRS.UI.Main/MenuForms/FrmOperation.resx @@ -125,7 +125,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAADm - CgAAAk1TRnQBSQFMAgEBAgEAAZgBAgGYAQIBGAEAARgBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo + CgAAAk1TRnQBSQFMAgEBAgEAAcgBAgHIAQIBGAEAARgBAAT/AQkBAAj/AUIBTQE2AQQGAAE2AQQCAAEo AwABYAMAARgDAAEBAQABCAYAAQkYAAGAAgABgAMAAoABAAGAAwABgAEAAYABAAKAAgADwAEAAcAB3AHA AQAB8AHKAaYBAAEzBQABMwEAATMBAAEzAQACMwIAAxYBAAMcAQADIgEAAykBAANVAQADTQEAA0IBAAM5 AQABgAF8Af8BAAJQAf8BAAGTAQAB1gEAAf8B7AHMAQABxgHWAe8BAAHWAucBAAGQAakBrQIAAf8BMwMA @@ -182,7 +182,7 @@ AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4w LCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACZTeXN0 ZW0uV2luZG93cy5Gb3Jtcy5JbWFnZUxpc3RTdHJlYW1lcgEAAAAERGF0YQcCAgAAAAkDAAAADwMAAAD4 - CAAAAk1TRnQBSQFMAwEBAAGYAQIBmAECARgBAAEYAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA + CAAAAk1TRnQBSQFMAwEBAAHIAQIByAECARgBAAEYAQAE/wEJAQAI/wFCAU0BNgEEBgABNgEEAgABKAMA AWADAAEYAwABAQEAAQgGAAEJGAABgAIAAYADAAKAAQABgAMAAYABAAGAAQACgAIAA8ABAAHAAdwBwAEA AfABygGmAQABMwUAATMBAAEzAQABMwEAAjMCAAMWAQADHAEAAyIBAAMpAQADVQEAA00BAANCAQADOQEA AYABfAH/AQACUAH/AQABkwEAAdYBAAH/AewBzAEAAcYB1gHvAQAB1gLnAQABkAGpAa0CAAH/ATMDAAFm diff --git a/src/XKRS.Device.MelsecPLC/App.config b/src/XKRS.Device.MelsecPLC/App.config new file mode 100644 index 0000000..dd72730 --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/App.config @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/src/XKRS.Device.MelsecPLC/MelsecPLCConfig.cs b/src/XKRS.Device.MelsecPLC/MelsecPLCConfig.cs new file mode 100644 index 0000000..7928026 --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/MelsecPLCConfig.cs @@ -0,0 +1,70 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BRS.Common.Base; +using BRS.Common.Interface; +using BRS.Common.Model.Helper; +using BRS.UI.Device.Winform; +using System.Collections.Generic; +using System.ComponentModel; + +namespace XKRS.Device.MelsecPLC +{ + [Device("MelsecPLC", "三菱PLC", EnumHelper.DeviceAttributeType.OperationConfig)] + public class MelsecPLCOperationConfig : PLCOperationConfigBase + { + public int StartAddress { get; set; } + + public int OpLength { get; set; } + + public List OpValues { get; set; } + } + + [Device("MelsecPLC", "三菱PLC", EnumHelper.DeviceAttributeType.InitialConfig)] + public class MelsecPLCInitialConfig : PLCInitialConfigBase + { + [Category("PLC设置")] + [Description("PLCIP地址")] + [DisplayName("PLC IP")] + public string PLCIpAddress { get; set; } + + [Category("PLC设置")] + [Description("PLC端口号")] + [DisplayName("PLC端口")] + [DefaultValue(502)] + public int PLCPort { get; set; } = 502; + + [Category("PLC设置")] + [Description("PLC单元号")] + [DisplayName("PLC单元号")] + public int PLCUnitNum { get; set; } = 0; + + [Category("PLC设置")] + [Description("本机网络号")] + [DisplayName("本机网络号")] + public int PCNetNum { get; set; } = 0; + + [Category("PLC设置")] + [Description("PLC心跳地址")] + [DisplayName("PLC心跳地址")] + public string HeartbeatAddress { get; set; } + + [Category("PLC设置")] + [Description("PLC心跳间隔")] + [DisplayName("PLC心跳间隔")] + public int HeartbeatCycle { get; set; } = 0; + + //[Category("PLC设置")] + //[Description("PLC单元号")] + //[DisplayName("断线后是否更换PLC单元号的值")] + //public bool IsChangeSA1AfterReadFailed { get; set; } = false; + } + + [Device("MelsecPLC", "三菱PLC", EnumHelper.DeviceAttributeType.RunCtrl)] + public class OmronPLCRunCtrl : CtrlPLCRunBase + { + public OmronPLCRunCtrl(IDevice device) : base(device) { } + } +} diff --git a/src/XKRS.Device.MelsecPLC/MelsecPLCDriver.cs b/src/XKRS.Device.MelsecPLC/MelsecPLCDriver.cs new file mode 100644 index 0000000..70e107f --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/MelsecPLCDriver.cs @@ -0,0 +1,424 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using BRS.Common.Base; +using BRS.Common.Model; +using BRS.Common.Model.Helper; +using System.Threading.Tasks; +using HslCommunication; +using HslCommunication.Profinet.Melsec; +using static BRS.Common.Model.Helper.EnumHelper; +using System.Diagnostics; + +namespace XKRS.Device.MelsecPLC +{ + + [Device("MelsecPLC", "三菱PLC", DeviceAttributeType.Device)] + public class MelsecPLCDriver : PLCBase + { + public MelsecPLCInitialConfig IIConfig + { + get + { + return InitialConfig as MelsecPLCInitialConfig; + } + } + private MelsecMcNet melsecMc = new MelsecMcNet(); + + + #region PLCBase + public override List Read(string startAddress, int length) + { + PLCItem item = new PLCItem(); + item.Address = startAddress; + item.ItemLength = length; + + ReadItem(item); + //List valueList = new List(); + //if (!string.IsNullOrWhiteSpace(item.ItemValue)) + //{ + // valueList = item.ItemValue.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries).ToList().ConvertAll(s => int.Parse(s)).ToList(); + //} + return item.ItemValues; + } + + public override void ReadItem(PLCItem item) + { + item.PLCOpType = PLCOpType.Read; + item.ItemValues.Clear(); + try + { + // 读取Int变量 + var result = melsecMc.ReadInt32(item.Address, (ushort)item.ItemLength); + if (result.IsSuccess) + { + for (int i = 0; i < result.Content.Length; i++) + { + item.ItemValues.Add(result.Content[i]); + } + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:" + item.Address + ";长度:" + item.ItemLength + ";提示:" + result.Message); + } + } + catch (Exception ex) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}读取异常:" + ex.GetExceptionMessage()); + } + } + + + public override int ReadInt(string address) + { + try + { + // 读取Int变量 + var result = melsecMc.ReadInt32(address); + if (result.IsSuccess) + { + return result.Content; + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:" + address + ";提示:" + result.Message); + return -1; + } + } + catch (Exception ex) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}读取异常:" + ex.GetExceptionMessage()); + return -1; + } + } + public override string ReadString(string address, ushort length) + { + try + { + // 读取String变量 + var result = melsecMc.ReadString(address, length); + if (result.IsSuccess) + { + return result.Content; + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:" + address + ";提示:" + result.Message); + return "-1"; + } + } + catch (Exception ex) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}读取异常:" + ex.GetExceptionMessage()); + return "-1"; + } + } + public override float ReadFloat(string address) + { + try + { + // 读取Float变量 + var result = melsecMc.ReadFloat(address); + if (result.IsSuccess) + { + return result.Content; + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:" + address + ";提示:" + result.Message); + return -1; + } + } + catch (Exception ex) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}读取异常:" + ex.GetExceptionMessage()); + return -1; + } + } + public override void WriteItem(PLCItem item, bool waitForReply = true) + { + item.PLCOpType = PLCOpType.Write; + + if (item.ItemValues == null || item.ItemValues.Count < 1) + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入值不能为空"); + return; + } + + int repeatTime = 3; + Stopwatch sw = new Stopwatch(); + + do + { + try + { + var result = melsecMc.Write(item.Address, item.ItemValues.First()); + if (result.IsSuccess) + { + repeatTime = 0; + } + } + catch (Exception ex) + { + if (repeatTime < 0) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}"); + } + } + } while (repeatTime > 0); + sw.Stop(); + LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} WriteItem:{item.GetDisplayText()},写入 {item.ItemValues.First()}完成,耗时:{sw.ElapsedMilliseconds} ms"); + } + + /// + /// 写单独地址 + /// + /// 地址 + /// + /// + public override void WriteInt(string address, int writeValue, bool waitForReply = true) + { + if (string.IsNullOrEmpty(address)) + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!"); + return; + } + + int repeatTime = 3; + Stopwatch sw = new Stopwatch(); + + do + { + try + { + + var result = melsecMc.Write(address, writeValue); + if (result.IsSuccess) + { + repeatTime = 0; + } + } + catch (Exception ex) + { + if (repeatTime < 0) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}"); + } + } + } while (repeatTime > 0); + sw.Stop(); + LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入 {writeValue} 完成,耗时:{sw.ElapsedMilliseconds} ms"); + } + /// + /// 写单独地址 string值 + /// + /// 地址 + /// + /// + public override void WriteString(string address, string writeValue, bool waitForReply = true) + { + if (string.IsNullOrEmpty(address) || string.IsNullOrEmpty(writeValue)) + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!"); + return; + } + + int repeatTime = 3; + Stopwatch sw = new Stopwatch(); + + do + { + try + { + var result = melsecMc.Write(address, writeValue); + if (result.IsSuccess) + { + repeatTime = 0; + } + } + catch (Exception ex) + { + if (repeatTime < 0) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}"); + } + } + } while (repeatTime > 0); + sw.Stop(); + LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入{writeValue}完成,耗时:{sw.ElapsedMilliseconds} ms"); + } + + /// + /// 写单独地址 float值 + /// + /// 地址 + /// + /// + public override void WriteFloat(string address, float writeValue, bool waitForReply = true) + { + if (string.IsNullOrEmpty(address)) + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name} 数据写入参数不能为空!"); + return; + } + + int repeatTime = 3; + Stopwatch sw = new Stopwatch(); + + do + { + try + { + var result = melsecMc.Write(address, writeValue); + if (result.IsSuccess) + { + repeatTime = 0; + } + } + catch (Exception ex) + { + if (repeatTime < 0) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}数据写入异常:{ex.GetExceptionMessage()}"); + } + } + } while (repeatTime > 0); + sw.Stop(); + LogAsync(DateTime.Now, LogLevel.Assist, $"{Name} {address},写入{writeValue}完成,耗时:{sw.ElapsedMilliseconds} ms"); + } + #endregion + + #region DeviceBase + protected override void Init() + { + + } + + protected override void Start() + { + // IConfig.ip + + melsecMc = new MelsecMcNet(IIConfig.PLCIpAddress, IIConfig.PLCPort); + + // 如果网络不太理想,配置了两个端口,一个有问题,立即切换另一个的话,可以配置如下的代码 + // melsecMc.GetPipeSocket().SetMultiPorts(new int[] { 6000, 6001 }); + + // 连接对象 + OperateResult connect = melsecMc.ConnectServer(); + if (connect.IsSuccess) + { + base.Start(); + Task.Run(() => + { + HeartbeatMonitor(); + }); + } + else + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}已开启异常:{connect.Message}"); + } + } + + protected override void Stop() + { + try + { + + // 断开连接 + // melsecMc.RemoteStop(); + // OmronUDPNet.Stop(); + } + catch (Exception ex) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{Name}关闭异常:{ex.GetExceptionMessage()}"); + } + } + #endregion + + + //private void InitialScanClient() + //{ + // InitialTcpClient(ref scanClient, ref scanStream); + //} + + //private void InitialOpClient() + //{ + // InitialTcpClient(ref opClient, ref opStream); + //} + + //private void InitialTcpClient(ref TcpClient client, ref NetworkStream stream) + //{ + // if (client == null || !client.Connected || !client.Client.Connected) + // { + // client = new TcpClient(); + // client.NoDelay = true; + // client.Client.NoDelay = true; + // client.Client.Blocking = true; + // client.Connect(plcEP); + + // stream = client.GetStream(); + // } + //} + + #region IMonitor + readonly byte[] scanBuffer = new byte[2048]; + public override List GetMonitorValues(int startAddress, int length) + { + List res = new List(); + //var result = melsecMc.ReadInt32("D" + startAddress, (ushort)length); + var result = melsecMc.ReadInt32("D" + startAddress, (ushort)length); + if (result.IsSuccess) + { + res = new List(result.Content); + } + else + { + LogAsync(DateTime.Now, LogLevel.Error, $"{Name}未读取到数据:" + "地址:W" + startAddress + ";长度:" + length + ";提示:" + result.Message); + } + return res; + } + #endregion + + public async void HeartbeatMonitor() + { + if (IIConfig.HeartbeatCycle <= 0) + { + return; + } + await Task.Run(async () => + { + if (!string.IsNullOrEmpty(IIConfig.HeartbeatAddress) + && IIConfig.HeartbeatCycle > 0) + { + while (CurrentState != DeviceState.DSClose && CurrentState != DeviceState.DSExcept) + { + if (IIConfig.HeartbeatCycle <= 0) + { + return; + } + + try + { + await Task.Delay(IIConfig.HeartbeatCycle * 1000); + var result = melsecMc.Write(IIConfig.HeartbeatAddress, 1); + if (!result.IsSuccess) + { + LogAsync(DateTime.Now, LogLevel.Error, $"{this.Name} 心跳监听失败"); + } + } + catch (Exception ex) + { + if (CurrentState == DeviceState.DSOpen) + { + LogAsync(DateTime.Now, LogLevel.Exception, $"{this.Name} 心跳监听异常,{ex.GetExceptionMessage()}"); + } + } + } + } + }); + } + } + +} diff --git a/src/XKRS.Device.MelsecPLC/Program.cs b/src/XKRS.Device.MelsecPLC/Program.cs new file mode 100644 index 0000000..412d3df --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace XKRS.Device.MelsecPLC +{ + class Program + { + static void Main(string[] args) + { + } + } +} diff --git a/src/XKRS.Device.MelsecPLC/Properties/AssemblyInfo.cs b/src/XKRS.Device.MelsecPLC/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..5c59375 --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("XKRS.Device.MelsecPLC")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("HP Inc.")] +[assembly: AssemblyProduct("XKRS.Device.MelsecPLC")] +[assembly: AssemblyCopyright("Copyright © HP Inc. 2023")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("887f9454-b1f3-47b8-b9f7-48beba47193d")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值 +//通过使用 "*",如下所示: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/src/XKRS.Device.MelsecPLC/Properties/Settings.Designer.cs b/src/XKRS.Device.MelsecPLC/Properties/Settings.Designer.cs new file mode 100644 index 0000000..361dd36 --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/Properties/Settings.Designer.cs @@ -0,0 +1,26 @@ +//------------------------------------------------------------------------------ +// +// 此代码由工具生成。 +// 运行时版本:4.0.30319.42000 +// +// 对此文件的更改可能会导致不正确的行为,并且如果 +// 重新生成代码,这些更改将会丢失。 +// +//------------------------------------------------------------------------------ + +namespace XKRS.Device.MelsecPLC.Properties { + + + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "16.10.0.0")] + internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase { + + private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings()))); + + public static Settings Default { + get { + return defaultInstance; + } + } + } +} diff --git a/src/XKRS.Device.MelsecPLC/Properties/Settings.settings b/src/XKRS.Device.MelsecPLC/Properties/Settings.settings new file mode 100644 index 0000000..049245f --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/Properties/Settings.settings @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/XKRS.Device.MelsecPLC/XKRS.Device.MelsecPLC.csproj b/src/XKRS.Device.MelsecPLC/XKRS.Device.MelsecPLC.csproj new file mode 100644 index 0000000..59889a9 --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/XKRS.Device.MelsecPLC.csproj @@ -0,0 +1,92 @@ + + + + + Debug + AnyCPU + {887F9454-B1F3-47B8-B9F7-48BEBA47193D} + Library + XKRS.Device.MelsecPLC + XKRS.Device.MelsecPLC + v4.6.1 + 512 + true + true + + + AnyCPU + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + AnyCPU + pdbonly + true + ..\Release\ + TRACE + prompt + 4 + + + + + + + ..\..\packages\HslCommunication.10.6.1\lib\net451\HslCommunication.dll + + + ..\..\packages\Newtonsoft.Json.12.0.3\lib\net45\Newtonsoft.Json.dll + + + + + + + + + + + + + + + + + + True + True + Settings.settings + + + + + + + SettingsSingleFileGenerator + Settings.Designer.cs + + + + + {987308dd-8baa-463a-94e2-77d62e01a5bf} + BRS.Common.Device + + + {1a3cbfe7-3f78-42c3-95c5-10360450dbea} + BRS.Common.Model + + + {e6429c64-92b3-46a2-b35e-579856d47f62} + BRS.UI.Device.Winform + + + + + + + \ No newline at end of file diff --git a/src/XKRS.Device.MelsecPLC/packages.config b/src/XKRS.Device.MelsecPLC/packages.config new file mode 100644 index 0000000..430f8cb --- /dev/null +++ b/src/XKRS.Device.MelsecPLC/packages.config @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file