/// <summary> /// The button read_ click. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void buttonRead_Click(object sender, EventArgs e) { byte[] vals = this.ReadMICCleanParameter(); this.mCleanParameter = (CleanparaEpsonMicolor)PubFunc.BytesToStruct(vals, typeof(CleanparaEpsonMicolor)); // this.mCleanParameter = (CleanparaEpsonMicolor)PubFunc.BytesToStruct(vals,typeof(CleanparaEpsonMicolor), 93); this.setCleanParameter(this.mCleanParameter); }
private List <int> GetEnumMbID() { List <int> ret = new List <int>(); byte[] val = new byte[Marshal.SizeOf(typeof(SinglepassYataoFactoryParam)) + 2]; uint bufsize = (uint)val.Length; if (CoreInterface.GetEpsonEP0Cmd(0x7b, val, ref bufsize, 0, 1) != 0) { byte[] structData = new byte[Marshal.SizeOf(typeof(SinglepassYataoFactoryParam))]; Buffer.BlockCopy(val, 2, structData, 0, structData.Length); SinglepassYataoFactoryParam obj = (SinglepassYataoFactoryParam)PubFunc.BytesToStruct(structData, typeof(SinglepassYataoFactoryParam)); ret.Add(obj.MbId); } return(ret); }
/// <summary> /// 获取共享内存(MyData结构) /// </summary> /// <returns></returns> public static MyData GetShareMem() { int MemSize = Marshal.SizeOf(typeof(MyData)); Data = new ShareMem(); if (Data.Init("MyData", MemSize) != 0) { return(new MyData(-1)); } byte[] temp = new byte[MemSize]; try { Data.Read(ref temp, 0, temp.Length); MyData stuc = (MyData)PubFunc.BytesToStruct(temp, typeof(MyData)); return(stuc); } catch (Exception) { return(new MyData(-1)); } } //end fun
private void HapondMotorSettingForm_Load(object sender, EventArgs e) { modeBoxs = new List <ComboBox>() { comboBoxMode1, comboBoxMode2, comboBoxMode3, comboBoxMode4, comboBoxMode5, comboBoxMode6 }; dirBoxs = new List <ComboBox>() { comboBoxDir1, comboBoxDir2, comboBoxDir3, comboBoxDir4, comboBoxDir5, comboBoxDir6 }; values = new List <NumericUpDown>() { numericUpDown1, numericUpDown2, numericUpDown3, numericUpDown4, numericUpDown5, numericUpDown6 }; for (int i = 0; i < modeBoxs.Count; i++) { modeBoxs[i].Items.Clear(); WorkMode[] modes = (WorkMode[])Enum.GetValues(typeof(WorkMode)); for (int j = 0; j < modes.Length; j++) { modeBoxs[i].Items.Add(modes[j].ToString()); } dirBoxs[i].Items.Clear(); MotorDIR[] dirs = (MotorDIR[])Enum.GetValues(typeof(MotorDIR)); for (int j = 0; j < dirs.Length; j++) { dirBoxs[i].Items.Add(dirs[j].ToString()); } } hapondPrintParam = new HapondPrintParam() { MotorTors = new MotorTorParam[6] }; byte[] buf = new byte[Marshal.SizeOf(hapondPrintParam) + 2]; uint len = (uint)buf.Length; int ret = CoreInterface.GetEpsonEP0Cmd(0x92, buf, ref len, 0, 0x0100); if (ret != 0) { byte[] data = buf.Skip(2).Take((int)len).ToArray(); hapondPrintParam = (HapondPrintParam)PubFunc.BytesToStruct(data, typeof(HapondPrintParam)); string flag = new string(hapondPrintParam.Flag); if (flag == "HAPD") { for (int i = 0; i < hapondPrintParam.MotorTors.Length; i++) { if (i == 2 || i == 3) { modeBoxs[i].SelectedIndex = hapondPrintParam.MotorTors[i].mode; } else { modeBoxs[i].SelectedIndex = 1; } dirBoxs[i].SelectedIndex = hapondPrintParam.MotorTors[i].dir; values[i].Value = hapondPrintParam.MotorTors[i].value; } } else { MessageBox.Show(@"Get HapondPrintParam Failed"); } } }