public void setup(Action <bool, string> errorhandler, Action <string, string, LogViewType> loghandler, IOpcClient client, OPCParam param) { this.loghandler = loghandler; this.client = client; this.param = param; loghandler?.Invoke("!fake robot setup.", LogType.ROBOT_STACK, LogViewType.OnlyForm); loghandler?.Invoke($"!ip: {ip}, job name: {jobName}", "fake robot", LogViewType.OnlyFile); }
public static void NotifyFullPanel(IOpcClient client, OPCParam param, string relloc) { client.TryWrite(param.BAreaPanelFinish[relloc], true); FrmMain.logOpt.Write($"{relloc}: 满板信号发出。slot: {param.BAreaPanelFinish[relloc]}", LogType.ROBOT_STACK); const int SIGNAL_3 = 3; client.TryWrite(param.BAreaPanelState[relloc], SIGNAL_3); FrmMain.logOpt.Write($"{relloc}: 板状态信号发出,状态值: {SIGNAL_3}。slot: {param.BAreaPanelState[relloc]}", LogType.ROBOT_STACK); }
/// <summary> /// 标签采集处,写布卷直径和去向。 /// </summary> /// <param name="client"></param> /// <param name="diameter">直径</param> /// <param name="channel">去向, 1 or 2.</param> /// <param name="param"></param> public static void WriteLabelUpData(IOpcClient client, OPCParam param, decimal diameter, RollCatchChannel channel) { // diameter单位是毫米。 client.TryWrite(param.LableUpParam.Diameter, diameter); client.TryWrite(param.LableUpParam.Goto, channel); Thread.Sleep(DELAY); // 复位标签采集处来料信号。 client.TryWrite(param.LableUpParam.Signal, 0); param.LableUpParam.PlcSn.WriteSN(client); }
public static bool WriteScanResult(IOpcClient client, OPCParam param, string area, string locationNo, string codepart1, string codepart2) { client.TryWrite(param.ScanParam.ToLocationArea, area); client.TryWrite(param.ScanParam.ToLocationNo, locationNo); // write label. client.TryWrite(param.ScanParam.ScanLable1, codepart1); client.TryWrite(param.ScanParam.ScanLable2, codepart2); // write camera no. and set state true. return(client.TryWrite(param.ScanParam.ScanState, true)); }
/// <summary> /// 写缓存动作 /// </summary> /// <param name="client">opc client.</param> /// <param name="job">动作编号。</param> /// <param name="posSave">动作编号。</param> /// <param name="posGet">动作编号。</param> /// <param name="param"></param> /// <param name="lcode"></param> public static void WriteCacheJob(IOpcClient client, OPCParam param, CacheState job, int posSave, int posGet, string lcode) { client.TryWrite(param.CacheParam.BeforCacheLable1, lcode.Substring(0, 6)); client.TryWrite(param.CacheParam.BeforCacheLable2, lcode.Substring(6, 6)); client.TryWrite(param.CacheParam.CacheStatus, job); client.TryWrite(param.CacheParam.CachePoint, posSave); client.TryWrite(param.CacheParam.GetPoint, posGet); Thread.Sleep(DELAY); // 复位来料信号。 param.CacheParam.PlcSn.WriteSN(client); client.TryWrite(param.CacheParam.BeforCacheStatus, 0); }
private static void notifyOpc(string lcode) { var param = new OPCParam(); IOpcClient client; #if DEBUG client = new FakeOpcClient(param); #else client = new OPCClient(); #endif client.Open(clsSetting.OPCServerIP); param.DeleteLCode = new LCodeSignal(client, "DeleteLCode"); PlcHelper.NotifyLabelCodeDeleted(client, param, lcode); }
public static bool IsPushedAside(IOpcClient client, OPCParam param, Action onResetError = null) { var slot = param.ScanParam.PlcPushAside; if (client.TryReadBool(slot)) { var resetok = client.TryWrite(slot, 0); if (!resetok) { onResetError?.Invoke(); // 复位失败 } return(true); } else { return(false); } }
/// <summary> /// 标签扫描处理完成以后,发消息告知OPC。 /// </summary> /// <param name="area">交地所在的区代码:"A", "B" or "C"</param> /// <param name="numb">交地序号</param> /// <param name="label1">标签前半部分</param> /// <param name="label2">标签后半部分</param> /// <param name="camera">相机号</param> /// <param name="client">opc client</param> /// <param name="param">opc param</param> public static void WriteScanOK(IOpcClient client, OPCParam param, string area, string numb, string label1, string label2, string camera) { // 交地 client.TryWrite(param.ScanParam.ToLocationArea, area); client.TryWrite(param.ScanParam.ToLocationNo, numb); // 标签条码 client.TryWrite(param.ScanParam.ScanLable1, label1); client.TryWrite(param.ScanParam.ScanLable2, label2); // 相机 client.TryWrite(param.ScanParam.PushAside, camera); // 完成信号。 WriteScanOK(client, param); }
/// <summary> /// 抓料处来料信号。 /// </summary> /// <param name="client"></param> /// <param name="pos">抓料处位置编号。</param> /// <param name="param"></param> /// <returns></returns> public static bool ReadItemCatchSignal(IOpcClient client, OPCParam param, int pos) { var slot = ""; if (pos == 1) { slot = param.RobotCarryParam.RobotCarryA; } if (pos == 2) { slot = param.RobotCarryParam.RobotCarryB; } if (slot == "") { throw new Exception("error pos."); } return(client.TryReadBool(slot)); }
/// <summary> /// 复位抓料处信号。 /// </summary> /// <param name="client"></param> /// <param name="pos"></param> /// <param name="param"></param> public static void ResetItemCatchSignal(IOpcClient client, OPCParam param, int pos) { var slot = ""; if (pos == 1) { slot = param.RobotCarryParam.RobotCarryA; } if (pos == 2) { slot = param.RobotCarryParam.RobotCarryB; } if (slot == "") { throw new Exception("error pos."); } client.TryWrite(slot, 0); }
/// <summary> /// 读布卷到达缓冲信号。 /// </summary> /// <param name="client">opc client</param> /// <param name="param">opc param</param> /// <returns></returns> public static bool ReadBeforeCacheSignal(IOpcClient client, OPCParam param) { return(client.TryReadBool(param.CacheParam.BeforCacheStatus)); }
public static void WriteWeighingSignal(IOpcClient client, OPCParam param, bool b) { var val = b ? "0" : "2"; client.TryWrite(param.WeighParam.GetWeigh, val); }
public static int ReadWeighingSignal(IOpcClient client, OPCParam param) { return(client.TryReadInt(param.WeighParam.GetWeigh)); }
public FakeOpcClient(OPCParam param_) { param = param_; }
public void setup(Action <bool, string> errorhandler, Action <string, string, LogViewType> logfunc, IOpcClient c, OPCParam p) { onerror = errorhandler; _log = logfunc; client = c; param = p; }
public static void setup(OPCClient c, OPCParam p, Action <string, string, LogViewType> logfunc) { client = c; param = p; _log = logfunc; }
public static string ReadCacheLabble(IOpcClient client, OPCParam param) { return(client.TryReadString(param.CacheParam.BeforCacheLable1).PadLeft(6, '0') + client.TryReadString(param.CacheParam.BeforCacheLable2).PadLeft(6, '0')); }
/// <summary> /// 缓存处来料信号 /// </summary> /// <param name="client"></param> /// <param name="param"></param> /// <returns></returns> public static bool ReadCacheSignal(IOpcClient client, OPCParam param) { var r = param.CacheParam.PlcSn.ReadSN(client); return(r); }
/// <summary> /// 代替主窗口的同名函数。 /// </summary> /// <param name="client"></param> /// <param name="param"></param> /// <param name="errorCode">错误码</param> public static void ERPAlarmNo(IOpcClient client, OPCParam param, int errorCode) { client.TryWrite(param.None.ERPAlarm, errorCode); }
public static void NotifyBadLayerShape(IOpcClient client, OPCParam param, string tolocation) { const int BAD_SHAPE = 1; client.TryWrite(param.BadShapeLocations[tolocation], BAD_SHAPE); }
/// <summary> /// 删除号码以后,告知opc. /// </summary> /// <param name="client"></param> /// <param name="param"></param> /// <param name="lcode">12位长的号码</param> public static void NotifyLabelCodeDeleted(IOpcClient client, OPCParam param, string lcode) { client.TryWrite(param.DeleteLCode.LCode1, lcode.Substring(0, 6)); client.TryWrite(param.DeleteLCode.LCode2, lcode.Substring(6, 6)); client.TryWrite(param.DeleteLCode.Signal, true); }
public static void ResetBeforeCacheSignal(IOpcClient client, OPCParam param) { client.TryWrite(param.CacheParam.BeforCacheStatus, false); }
/// <summary> /// 读扫描状态信号。 /// </summary> /// <param name="client">opc client.</param> /// <param name="param">opc param.</param> /// <returns></returns> public static bool ReadScanState(IOpcClient client, OPCParam param) { return(client.TryReadBool(param.ScanParam.ScanState)); }
/// <summary> /// 取OPC的diameter和length两个量。 /// 和static getFromOPC函数等价。 /// </summary> public void getFromOPC(IOpcClient client, OPCParam param) { diameter = client.TryReadDecimal(param.ScanParam.Diameter); length = client.TryReadDecimal(param.ScanParam.Length); }
/// <summary> /// 布卷条码扫描完成,令托架放下,传送带动。 /// </summary> /// <param name="client">opc client instance.</param> /// <param name="param">opc param</param> public static void WriteScanOK(IOpcClient client, OPCParam param) { client.TryWrite(param.ScanParam.ScanState, true); }
public static void PushAside(IOpcClient client, OPCParam param) { const int PUSH_ASIDE = 1; client.TryWrite(param.ScanParam.PushAside, PUSH_ASIDE); }