|
|
@@ -1,4 +1,5 @@
|
|
|
-using GSG.NET.Logging;
|
|
|
+using GSG.NET.Concurrent;
|
|
|
+using GSG.NET.Logging;
|
|
|
using GSG.NET.PLC;
|
|
|
using GSG.NET.PLC.Keyence;
|
|
|
using GSG.NET.PLC.KNC;
|
|
|
@@ -30,8 +31,19 @@ namespace OHVDriveLogger
|
|
|
|
|
|
private void FormMain_FormClosing( object sender, FormClosingEventArgs e )
|
|
|
{
|
|
|
- this.plc.Disconnect();
|
|
|
- this.zmp.Dispose();
|
|
|
+ DialogResult result = MessageBox.Show( "Drive Logger", "EXIT", MessageBoxButtons.YesNo, MessageBoxIcon.Question );
|
|
|
+ if ( result == System.Windows.Forms.DialogResult.Yes )
|
|
|
+ {
|
|
|
+ plc.WriteBit( "DRIVE_LOGGING_ONOFF", false );
|
|
|
+ LockUtils.Wait( 200 );
|
|
|
+
|
|
|
+ this.plc.Disconnect();
|
|
|
+ this.zmp.Dispose();
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ e.Cancel = true;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void FormMain_Load( object sender, EventArgs e )
|
|
|
@@ -42,7 +54,7 @@ namespace OHVDriveLogger
|
|
|
this.plc.Config.MonitorInterval = 1000;
|
|
|
|
|
|
var grpB = new KncGroup { Device = KncDevice.MR, Name = "MR" };
|
|
|
- grpB.AddBitBlock( new KncBitBlock { Name = $"DRIVE_LOGGING_ONOFF", Address = 16, SubNo = 0 } );
|
|
|
+ grpB.AddBitBlock( new KncBitBlock { Name = $"DRIVE_LOGGING_ONOFF", Address = 16, SubNo = 0 } ); //MR100 Keyence 주소 체계가 다름.
|
|
|
|
|
|
this.plc.AddGroup( grpB );
|
|
|
|
|
|
@@ -83,11 +95,14 @@ namespace OHVDriveLogger
|
|
|
|
|
|
private void button1_Click( object sender, EventArgs e )
|
|
|
{
|
|
|
- var bit = plc.ReadBit( "DRIVE_LOGGING_ONOFF" );
|
|
|
- if ( bit.IsBitOn )
|
|
|
- plc.WriteBit( "DRIVE_LOGGING_ONOFF", false );
|
|
|
- else
|
|
|
- plc.WriteBit( "DRIVE_LOGGING_ONOFF", true );
|
|
|
+ //var bit = plc.ReadBit( "DRIVE_LOGGING_ONOFF" );
|
|
|
+ //if ( bit.IsBitOn )
|
|
|
+ // plc.WriteBit( "DRIVE_LOGGING_ONOFF", false );
|
|
|
+ //else
|
|
|
+ // plc.WriteBit( "DRIVE_LOGGING_ONOFF", true );
|
|
|
+
|
|
|
+ string strOut;
|
|
|
+ zmp.Request( "Hello", out strOut );
|
|
|
}
|
|
|
}
|
|
|
}
|