public override void Deserialize(string path) { var data = Solution.Deserialize <SSZNAcquisitionData>(path); Name = data.Name; Type = data.Type; Belong = data.Belong; AllowRepeat = data.AllowRepeat; HeightRange = data.HeightRange; EthernetConfig = data.EthernetConfig; DeviceId = data.DeviceId; dwProfileCnt = data.dwProfileCnt; InitializeComponent(Belong); Connect(DeviceId, EthernetConfig); }
public int Connect(int deviceId, SR7IF_ETHERNET_CONFIG ethernetConfig) { var rc = SR7LinkFunc.SR7IF_EthernetOpen(deviceId, ref ethernetConfig); EthernetConfig = ethernetConfig; DeviceId = deviceId; if (rc < 0) { MessageBox.Show(@"设备连接失败!"); Connected = false; } else { MessageBox.Show(@"设备连接成功!"); Connected = true; //获取型号判断高度范围 var strModel = SR7LinkFunc.SR7IF_GetModels(deviceId); var sModel = Marshal.PtrToStringAnsi(strModel); HeightRange = sModel switch { "SR7050" => 2.5, "SR7080" => 6, "SR7140" => 12, "SR7240" => 20, "SR7400" => 50, _ => 8.4 }; var reT = SR7LinkFunc.SR7IF_HighSpeedDataEthernetCommunicationInitalize(deviceId, ref ethernetConfig, 0, _callback, dwProfileCnt, 0); } return(rc); }
internal static extern int SR7IF_EthernetOpen(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig);
internal static extern int SR7IF_HighSpeedDataEthernetCommunicationInitalize(int lDeviceId, ref SR7IF_ETHERNET_CONFIG pEthernetConfig, int wHighSpeedPortNo, HighSpeedDataCallBack pCallBack, uint dwProfileCnt, uint dwThreadId);