Files
ATV_STDLabelAttach/QRValidation/Project/StateMachine/_BW_Right.cs
atvstdla dc66158497 Add QRValidation project to repository
- Added QRValidation vision control system
- Includes CapCleaningControl UI components
- WebSocket-based barcode validation system
- Support for Crevis PLC integration
- Test projects for PLC emulator, motion, IO panel, and Modbus

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-02 11:38:38 +09:00

98 lines
3.7 KiB
C#

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using WatsonWebsocket;
namespace Project
{
public partial class fMain
{
private void bwRight_DoWork(object sender, DoWorkEventArgs e)
{
var camIdx = PUB.setting.CameraIndexR;
var logIdx = 1;
PUB.log_[logIdx].Add("Camera thread(R) start");
System.Diagnostics.Stopwatch wat = new System.Diagnostics.Stopwatch();
var framedelay = (int)(1000f / 12f);//Time required to get 1 frame 12f / 1000;
while (bRunConnection && this.IsDisposed == false && this.Disposing == false)
{
wat.Restart();
var _fpsms = framedelay;// IsTrigger ? Pub.setting.GrabDelayFast : Pub.setting.GrabDelaySlow;
if (PUB.imgque == null || PUB.imgque.Any() == false) continue;
if (PUB.imgque.Peek().Equals(this.Name) == false) continue;
if (camIdx < 0 || PUB.setting.CameraIndexL == PUB.setting.CameraIndexR)
{
this.BeginInvoke(new Action(() =>
{
sbConnCamR.ForeColor = Color.Red;
}));
System.Threading.Thread.Sleep(1000);
continue;
}
//If camera is not connected, do not process.
if (PUB._isCrevisOpen[camIdx] == false || PUB.IsLive[camIdx] == false || PUB.flag.get(eFlag.CAMERAINIT) == false) _fpsms = 1000;
else
{
//Data processing after image acquisition
var Piv = this.pIvRight;
if (PUB.CrevisGrab(camIdx, true, Piv))
{
if (PUB.IsProcess[camIdx])
PUB.CreavisProcess(camIdx, PUB.IsTrigger[camIdx], Piv);
}
if (PUB.setting.TriggerTimeout > 0 && PUB.setting.TriggerTimeout < 999)
{
var ts = DateTime.Now - PUB.triggerTime[camIdx];
if (PUB.IsTrigger[camIdx] && ts.TotalSeconds > PUB.setting.TriggerTimeout)
{
PUB.log_[logIdx].Add($"Trigger maximum time({PUB.setting.TriggerTimeout}) exceeded, releasing");
PUB.IsTrigger[camIdx] = false;
}
}
}
wat.Stop();
if (wat.ElapsedMilliseconds < _fpsms)
{
try
{
if (PUB.setting.AutoDeleteSeconds > 0 && PUB.setting.AutoDeleteSeconds < 99)
{
var di = new System.IO.DirectoryInfo(PUB.setting.ImageSavePath);
var ttime = DateTime.Now.AddSeconds(-PUB.setting.AutoDeleteSeconds);
var dellist = di.GetFiles().Where(t => t.CreationTime <= ttime).FirstOrDefault();
if (dellist != null) dellist.Delete();
}
}
catch { }
System.Threading.Thread.Sleep(_fpsms - (int)wat.ElapsedMilliseconds);
}
//heart beat
this.BeginInvoke(new Action(() =>
{
if (sbConnCamR.ForeColor == Color.Green)
sbConnCamR.ForeColor = Color.LimeGreen;
else
sbConnCamR.ForeColor = Color.Green;
}));
}
}
}
}