You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
using System ;
using System.Collections.Generic ;
using System.Net.NetworkInformation ;
using System.Text ;
using System.Linq ;
using System.Data ;
using System.Threading ;
using Mesnac.Action.Base ;
using Mesnac.Controls.Base ;
using System.Windows.Forms ;
using Mesnac.Codd.Session ;
using System.IO ;
using Mesnac.Action.Feeding.BasicInfo ;
namespace Mesnac.Action.Feeding.FeedingPlc
{
/// <summary>
/// 把开始密炼信号下传至PLC
/// </summary>
public class StartMixingToPlc : FeedingAction , IAction
{
/// <summary>
/// 把开始密炼信号下传至PLC 业务入口
/// </summary>
/// <param name="runtime"></param>
public void Run ( RuntimeParameter runtime )
{
base . RunIni ( runtime ) ;
bool IsSuccess = DownloadStartMixing ( ) ;
if ( ! IsSuccess )
{
throw new Exception ( "开始称量信息下载错误!" ) ;
}
}
/// <summary>
/// 把开始密炼信号下传至PLC
/// </summary>
/// <returns>成功返回true, 失败返回false</returns>
public bool DownloadStartMixing ( )
{
try
{
int data = 0 ;
bool isSuccess = int . TryParse ( PlcData . Instance . StartMix . LastValue . ToInt ( ) . ToString ( ) , out data ) ;
//Mesnac.Equips.Factory.Instance.Read();
//bool isSuccess = int.TryParse(PlcData.Instance.StartMix.EquipData.LastBeforeMathValue.FirstOrDefault().ToString(), out data);
if ( isSuccess )
{
data = data | 1 ;
isSuccess = PlcData . Instance . PlcWriteByDataKey ( PlcData . Instance . StartMix , new object [ ] { data } ) ;
if ( isSuccess )
{
ICSharpCode . Core . LoggingService . Debug ( "把开始密炼信号下传至PLC成功!" ) ;
}
else
{
ICSharpCode . Core . LoggingService . Warn ( "把开始密炼信号下传至PLC失败!" ) ;
}
}
else
{
ICSharpCode . Core . LoggingService . Warn ( "把开始密炼信号下传至PLC失败!" ) ;
}
return isSuccess ;
}
catch ( Exception ex )
{
ICSharpCode . Core . LoggingService . Error ( "把开始密炼信号下传至PLC失败: " + ex . Message , ex ) ;
return false ;
}
}
}
}