protected bool Write(OutputReport oOutRep)
        {
            bool success = false;

            try
            {
                // ����� �� ������������ ���... HidD_SetOutputReport �������� � ���������� ������ ��� Feature !
                //success = HidD_SetOutputReport(m_hHandle, oOutRep.Buffer, oOutRep.BufferLength);
                if (m_oFile != null)
                {
                    if (m_oFile.CanWrite)
                    {
                        m_oFile.Write(oOutRep.Buffer, 0, oOutRep.BufferLength);
                        success = true;
                    }
                }
            }
            catch (Exception ex)
            {
                // ���� ��������� � ������������ Report ID - �� �� ���������
                if (ex.HResult != -2147024809)
                {
                    HandleDeviceRemoved();
                    OnDeviceRemoved?.Invoke(this, new EventArgs());
                    Dispose();
                }
            }
            return(success);
        }
示例#2
0
 private byte[] CreateReport(OutputReport type)
 {
     byte[] buff = new byte[WiimoteConstants.ReportLength];
     buff[0] = (byte)type;
     buff[1] = GetRumbleBit();
     return(buff);
 }
示例#3
0
    private void databind(string bt, string et)
    {
        DataTable dt;

        //查询检验站点
        if (ddlWorksite.SelectedItem.Text == "AG涂布检验" ||
            ddlWorksite.SelectedItem.Text == "UV背涂检验" ||
            ddlWorksite.SelectedItem.Text == "贴膜检验" ||
            ddlWorksite.SelectedItem.Text == "UV成型检验")
        {
            grd.Visible   = false;
            grdQC.Visible = true;
            if (ddlMethod.SelectedValue == "面积")
            {
                dt = OutputReport.QueryData(bt, et, ddlWOType.SelectedValue, ddlWOProducttype.SelectedValue, ddlWidth.SelectedValue, ddlThinkness.SelectedValue, ddlWorksite.SelectedItem.Value, ddlClass.SelectedValue);
                grdQC.DataSource = dt;
                grdQC.DataBind();
            }
            else if (ddlMethod.SelectedValue == "卷数")
            {
                dt = OutputReport.QueryDataByQty(bt, et, ddlWOType.SelectedValue, ddlWOProducttype.SelectedValue, ddlWidth.SelectedValue, ddlThinkness.SelectedValue, ddlWorksite.SelectedItem.Value, ddlClass.SelectedValue);
                grdQC.DataSource = dt;
                grdQC.DataBind();
            }
        }
        //制造站点
        else
        {
            grd.Visible   = true;
            grdQC.Visible = false;
            if (ddlWorksite.SelectedValue != "M60")
            {
                grd.Columns[7].Visible  = false;
                grd.Columns[8].Visible  = false;
                grd.Columns[9].Visible  = false;
                grd.Columns[10].Visible = false;
                grd.Columns[11].Visible = false;
            }
            else
            {
                grd.Columns[7].Visible  = true;
                grd.Columns[8].Visible  = true;
                grd.Columns[9].Visible  = true;
                grd.Columns[10].Visible = true;
                grd.Columns[11].Visible = true;
            }
            if (ddlMethod.SelectedValue == "面积")
            {
                dt             = OutputReport.QueryData(bt, et, ddlWOType.SelectedValue, ddlWOProducttype.SelectedValue, ddlWidth.SelectedValue, ddlThinkness.SelectedValue, ddlWorksite.SelectedItem.Value, ddlClass.SelectedValue);
                grd.DataSource = dt;
                grd.DataBind();
            }
            else if (ddlMethod.SelectedValue == "卷数")
            {
                dt             = OutputReport.QueryDataByQty(bt, et, ddlWOType.SelectedValue, ddlWOProducttype.SelectedValue, ddlWidth.SelectedValue, ddlThinkness.SelectedValue, ddlWorksite.SelectedItem.Value, ddlClass.SelectedValue);
                grd.DataSource = dt;
                grd.DataBind();
            }
        }
    }
        /// <summary>
        /// Write a report to the Wiimote
        /// </summary>
        private void WriteReport2(OutputReport type, byte[] buff)
        {
            Debug.WriteLine($"WriteReport: {type}");

            // Expand the report to include the report type
            Buffer.BlockCopy(buff, 0, buff, 1, buff.Length - 1);
            buff[0] = (byte)type;

            if (mAltWriteMethod)
            {
                NativeMethods.HidD_SetOutputReport(mHandle.DangerousGetHandle(), buff, buff.Length);
            }
            else if (mStream != null)
            {
                mStream.Write(buff, 0, WiimoteConstants.ReportLength);
            }

            if (type == OutputReport.WriteMemory)
            {
                //Debug.WriteLine("Wait");
                if (!mWriteDone.WaitOne(1000, false))
                {
                    Debug.WriteLine("Wait failed");
                }
                //throw new WiimoteException("Error writing data to Wiimote...is it connected?");
            }
        }
示例#5
0
        private int WriteReport(byte[] buff)
        {
            // Automatically do this so we don't have to do it for every report
            buff[1] |= GetRumbleBit();
            OutputReport type = (OutputReport)buff[0];

            return(WiimoteManager.QueueWriteRequest(this, buff));
        }
示例#6
0
        //---#+************************************************************************
        //---NOTATION:
        //-  bool writeData(char[] cDataToWrite)
        //-
        //--- DESCRIPTION:
        //--  writes data to the device and returns true if no error occured
        //                                                             Autor:      F.L.
        //-*************************************************************************+#*
        /// <summary>
        /// Writes the data.
        /// </summary>
        /// <param name="bDataToWrite">The b data to write.</param>
        /// <returns></returns>
        public bool writeData(byte[] bDataToWrite)
        {
            bool success = false;

            if (getConnectionState())
            {
                try
                {
                    //get output report length
                    int myPtrToPreparsedData = -1;

                    // myUSB.CT_HidD_GetPreparsedData(myUSB.HidHandle, ref myPtrToPreparsedData);
                    // int code = myUSB.CT_HidP_GetCaps(myPtrToPreparsedData);

                    int outputReportByteLength = 65;

                    int bytesSend = 0;

                    //if bWriteData is bigger then one report diveide into sevral reports
                    while (bytesSend < bDataToWrite.Length)
                    {
                        // Set the size of the Output report buffer.
                        // byte[] OutputReportBuffer = new byte[myUSB.myHIDP_CAPS.OutputReportByteLength - 1 + 1];
                        byte[] OutputReportBuffer = new byte[outputReportByteLength - 1 + 1];

                        // Store the report ID in the first byte of the buffer:
                        OutputReportBuffer[0] = 0;

                        // Store the report data following the report ID.
                        for (int i = 1; i < OutputReportBuffer.Length; i++)
                        {
                            if (bytesSend < bDataToWrite.Length)
                            {
                                OutputReportBuffer[i] = bDataToWrite[bytesSend];
                                bytesSend++;
                            }
                            else
                            {
                                OutputReportBuffer[i] = 0;
                            }
                        }

                        OutputReport myOutputReport = new OutputReport();
                        success = myOutputReport.Write(OutputReportBuffer, myUSB.HidHandle);
                    }
                }
                catch (AccessViolationException)
                {
                    success = false;
                }
            }
            else
            {
                success = false;
            }
            return(success);
        }
示例#7
0
        private void FillReport(OutputReport report, CoolitCommandOpCode opCode, IConvertible regAddress, byte[] payLoad = null)
        {
            commandWriter.Channel = Channel;
            commandWriter.OpCode  = opCode;
            report.Data.Accept(commandWriter);
            var datawriter = new CoolitRegisterDataWriterVisitor(regAddress.ToRegisterData(), payLoad);

            report.Data.Accept(datawriter);
        }
 public WiimoteReportItem(int index, byte[] data)
 {
     Index       = index;
     Data        = data;
     ReportType  = (OutputReport)Data[0];
     Rumble      = (Data[1] & 0x1) != 0;
     Acknowledge = (Data[1] & 0x2) != 0;
     Enabled     = (Data[1] & 0x4) != 0;
     BuildContents();
     //Header = $"{index}) {ReportType} : {BuildContents()}";
 }
示例#9
0
 public bool Equals(OutputReport other)
 {
     if (ReferenceEquals(null, other))
     {
         return(false);
     }
     if (ReferenceEquals(this, other))
     {
         return(true);
     }
     return(Equals(other.ContentType, ContentType) && Equals(other.Contents, Contents));
 }
示例#10
0
        public override void Write(byte[] buffer, int offset, int count)
        {
            //_lastReport = buffer;
            _reportQueue.Enqueue(buffer);
            OutputReport output = (OutputReport)buffer[0];

            switch (output)
            {
            case OutputReport.StatusRequest:
                //NextReport = InputReport.Status;
                _nextQueue.Enqueue(InputReport.Status);
                RumbleByte = buffer[1];
                break;

            case OutputReport.ReadMemory:     // 21 BB BB SE AA AA DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD DD
                //if (NextReport != InputReport.ReadMem)
                if (!_nextQueue.Contains(InputReport.ReadMem))
                {
                    // Extension Step A
                    //NextReport = InputReport.ReadMem;
                    _nextQueue.Enqueue(InputReport.ReadMem);
                }
                else
                {
                    // Extension Step B
                }
                break;

            case OutputReport.LEDs:     // 11 LL
                //NextReport = InputReport.Acknowledge;
                _nextQueue.Enqueue(InputReport.Acknowledge);
                LED_1 = (buffer[1] & 0x10) != 0x00;
                LED_2 = (buffer[1] & 0x20) != 0x00;
                LED_3 = (buffer[1] & 0x30) != 0x00;
                LED_4 = (buffer[1] & 0x40) != 0x00;
                break;

            case OutputReport.DataReportMode:     // 12 TT MM
                DataReportMode = (InputReport)buffer[2];
                //if ((byte)NextReport >= 0x30)
                //{
                //    NextReport = DataReportMode;
                //}
                if (_nextQueue.Count == 0 || (byte)_nextQueue.Peek() >= 0x30)
                {
                    _nextQueue.Enqueue(DataReportMode);
                }
                break;
            }
        }
示例#11
0
        public static IDictionary <string, object> OutputReport(string[] tagFilter = null, string[] transactionIdFilter = null, LogLevel minLogLevel = LogLevel.Info, bool plaintext = true)
        {
            var outputReport = new OutputReport();

            outputReport.MinimumLogLevel = minLogLevel;
            var args = new Dictionary <string, object>()
            {
                { "TagFilter", tagFilter },
                { "TransactionIdFilter", transactionIdFilter },
                { "Plaintext", plaintext },
            };

            return(WorkflowInvoker.Invoke(outputReport, args));
        }
示例#12
0
        public bool writeDataSimple(byte[] bDataToWrite)
        {
            var success = false;

            if (getConnectionState())
            {
                try
                {
                    var myOutputReport = new OutputReport();
                    success = myOutputReport.Write(bDataToWrite, myUSB.HidHandle);
                }
                catch (AccessViolationException ex)
                {
                    success = false;
                }
            }
            return(success);
        }
示例#13
0
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack)
     {
         //绑定查询选项内容
         LineOutputReport.setWorksiteDDL(ddlWorksite);
         //工单类型
         OutputReport.setWOTypeddl(ddlWOType);
         //工单厚度
         OutputReport.setWOddl(ddlThinkness, "mouldthinkness");
         //工单宽度
         OutputReport.setWOddl(ddlWidth, "mouldwidth");
         //工单产品类型
         OutputReport.setWOddl(ddlWOProducttype, "mouldtype");
         //班次
         OutputReport.setClassDDL(ddlClass);
         BindTimeByClass();
     }
 }
示例#14
0
        /// <summary>
        /// Writes data.
        /// </summary>
        /// <param name="data">The data to write.</param>
        /// <returns></returns>
        internal bool WriteData(byte[] data)
        {
            bool bSuccess = false;

            if (IsConnected)
            {
                // Set the size of the Output report buffer.
                byte[] outputReportBuffer = new byte[HIDReportLength];
                Array.Clear(outputReportBuffer, 0, outputReportBuffer.Length);

                // Store the report data following the report ID.
                Array.ConstrainedCopy(data, 0, outputReportBuffer, 1, outputReportBuffer.Length);

                OutputReport report = new OutputReport();
                bSuccess = report.Write(outputReportBuffer, _core._hHid);
            }
            else
            {
                bSuccess = false;
            }
            return(bSuccess);
        }
示例#15
0
 protected void CreateReport(OutputReport reportType)
 {
     Array.Clear(OutputBuffer, 0, maximalReportLength);
     OutputBuffer[0] = (byte)reportType;
 }
示例#16
0
 public bool writeDataSimple(byte[] bDataToWrite)
 {
     var success = false;
     if (getConnectionState())
     {
         try
         {
             var myOutputReport = new OutputReport();
             success = myOutputReport.Write(bDataToWrite, myUSB.HidHandle);
         }
         catch (AccessViolationException ex)
         {
             success = false;
         }
     }
     return success;
 }
示例#17
0
        /// <summary>
        /// Writes data.
        /// </summary>
        /// <param name="data">The data to write.</param>
        /// <returns></returns>
        internal bool WriteData(byte[] data)
        {
            bool bSuccess = false;

             if (IsConnected)
             {
            // Set the size of the Output report buffer.
            byte[] outputReportBuffer = new byte[HIDReportLength];
            Array.Clear(outputReportBuffer, 0, outputReportBuffer.Length);

            // Store the report data following the report ID.
            Array.ConstrainedCopy(data, 0, outputReportBuffer, 1, outputReportBuffer.Length);

            OutputReport report = new OutputReport();
            bSuccess = report.Write(outputReportBuffer, _core._hHid);
             }
             else
             {
            bSuccess = false;
             }
             return bSuccess;
        }
示例#18
0
 public bool Equals(OutputReport other)
 {
     if (ReferenceEquals(null, other)) return false;
     if (ReferenceEquals(this, other)) return true;
     return Equals(other.ContentType, ContentType) && Equals(other.Contents, Contents);
 }
示例#19
0
 public void WriteOutput(OutputReport report)
 {
     addDetail().Text("Wrote Output ({0}):".ToFormat(report.ContentType));
     _holderTag.Add("pre").AddClass("content").Text(report.Contents);
 }
        /// <summary>
        /// Parse a report sent by the Wiimote
        /// </summary>
        /// <param name="buff">Data buffer to parse</param>
        /// <returns>Returns a boolean noting whether an event needs to be posted</returns>
        private bool ParseInputReport(byte[] buff)
        {
            //try {
            InputReport         type       = (InputReport)buff[0];
            DataReportAttribute dataReport =
                EnumInfo <InputReport> .TryGetAttribute <DataReportAttribute>(type);

            if (dataReport != null)
            {
                // Buttons are ALWAYS parsed
                if (dataReport.HasButtons)
                {
                    ParseButtons2(buff, dataReport.ButtonsOffset + 1);
                }

                switch (dataReport.Interleave)
                {
                case Interleave.None:
                    if (dataReport.HasAccel)
                    {
                        ParseAccel2(buff, dataReport.AccelOffset + 1);
                    }

                    if (dataReport.HasIR)
                    {
                        ParseIR2(buff, dataReport.IROffset + 1, dataReport.IRSize);
                    }

                    if (dataReport.HasExt)
                    {
                        ParseExtension2(buff, dataReport.ExtOffset + 1, dataReport.ExtSize);
                    }
                    break;

                case Interleave.A:
                    interleavedBufferA = buff;
                    interleavedReportA = dataReport;
                    break;

                case Interleave.B:
                    byte[] buffA = interleavedBufferA;
                    byte[] buffB = buff;
                    DataReportAttribute reportA = interleavedReportA;
                    DataReportAttribute reportB = dataReport;
                    ParseAccelInterleaved2(buffA, buffB, reportA.AccelOffset + 1, reportB.AccelOffset + 1);
                    ParseIRInterleaved2(buffA, buffB, reportA.IROffset + 1, reportB.IROffset + 1);
                    break;
                }

                return(true);
            }
            else
            {
                switch (type)
                {
                case InputReport.Status:
                    Debug.WriteLine("******** STATUS ********");

                    ExtensionType extensionTypeLast = wiimoteState.ExtensionType;
                    bool          extensionLast     = wiimoteState.Status.Extension;
                    ParseButtons2(buff, 1);
                    ParseStatus2(buff, 3);
                    bool extensionNew = WiimoteState.Status.Extension;

                    using (AsyncReadState state = BeginAsyncRead()) {
                        byte extensionType = 0;
                        if (extensionNew)
                        {
                            ReadByte(Registers.ExtensionType2);
                        }

                        Debug.WriteLine($"Extension byte={extensionType:X2}");

                        // extension connected?
                        Debug.WriteLine($"Extension, Old: {extensionLast}, New: {extensionNew}");

                        if (extensionNew != extensionLast || extensionType == 0x04 || extensionType == 0x5)
                        {
                            if (wiimoteState.Extension)
                            {
                                InitializeExtension(extensionType);
                                SetReportType(wiimoteState.ReportType,
                                              wiimoteState.IRState.Sensitivity,
                                              wiimoteState.ContinuousReport);
                            }
                            else
                            {
                                wiimoteState.ExtensionType     = ExtensionType.None;
                                wiimoteState.Nunchuk           = new NunchukState();
                                wiimoteState.ClassicController = new ClassicControllerState();
                                RaiseExtensionChanged(extensionTypeLast, false);
                                SetReportType(wiimoteState.ReportType,
                                              wiimoteState.IRState.Sensitivity,
                                              wiimoteState.ContinuousReport);
                            }
                        }
                    }
                    statusDone.Set();
                    //Respond(OutputReport.Status, true);
                    break;

                case InputReport.ReadData:
                    Debug.WriteLine("******** READ DATA ********");
                    ParseButtons2(buff, 1);
                    ParseReadData(buff);
                    break;

                case InputReport.AcknowledgeOutputReport:
                    Debug.WriteLine("******** ACKNOWLEDGE ********");
                    ParseButtons2(buff, 1);
                    OutputReport outputType = (OutputReport)buff[3];
                    WriteResult  result     = (WriteResult)buff[4];
                    if (outputType == OutputReport.WriteMemory)
                    {
                        writeDone.Set();
                        Debug.WriteLine("Write done");
                    }
                    //Acknowledge(outputType, result);
                    break;

                default:
                    Debug.WriteLine($"Unknown input report: {type}");
                    break;
                }
            }
            //}
            //catch (TimeoutException) { }
            return(true);
        }
示例#21
0
 public void WriteOutput(OutputReport report)
 {
     addDetail().Text("Wrote Output ({0}):".ToFormat(report.ContentType));
     _holderTag.Add("pre").AddClass("content").Text(report.Contents);
 }
示例#22
0
 public LogItem(DateTime dt, String msg, OutputReport data)
 {
     TimeStamp = dt;
     Message   = msg;
     Data      = data;
 }
示例#23
0
        private async Task MoveNext()
        {
            try
            {
                switch (state)
                {
                case 0:
                    //logger.Trace("Open state");
                    device.Open(factory == null ? HidDeviceAccess.Read : HidDeviceAccess.ReadWrite);
                    if (device.IsOpen)
                    {
                        state++;
                    }
                    else
                    {
                        GoToErrorState("Cannot open device");
                    }

                    break;

                case 1:
                    //logger.Trace("Send output report state");
                    if (factory != null)
                    {
                        outReport = factory.Create(command);
                        await device.SendOutputReport(outReport);
                    }

                    state++;
                    break;

                case 2:
                    //logger.Trace("Get input report state");
                    inReport = await device.GetInputReport(0);

                    inReport.Data.Accept(validator);

                    if (validator.IsInvalid)
                    {
                        GoToErrorState("validation failure");
                        break;
                    }
                    else
                    {
                        inReport.Data.Accept(extractor);
                        result = extractor.Data;
                    }

                    state++;
                    break;

                default:
                    return;
                }
            }
            catch (Exception ex)
            {
                //logger.Error("Error MoveNext", ex);
                GoToErrorState(ex.ToString());
            }

            await MoveNext();
        }
        //---#+************************************************************************
        //---NOTATION:
        //-  bool writeData(char[] cDataToWrite)
        //-
        //--- DESCRIPTION:
        //--  writes data to the device and returns true if no error occured
        //                                                             Autor:      F.L.
        //-*************************************************************************+#*
        /// <summary>
        /// Writes the data.
        /// </summary>
        /// <param name="bDataToWrite">The b data to write.</param>
        /// <returns></returns>
        public bool writeData(byte[] bDataToWrite)
        {
            bool success = false;
            if (getConnectionState())
            {
                try
                {
                    //get output report length
                    //int myPtrToPreparsedData = -1;
                    // myUSB.CT_HidD_GetPreparsedData(myUSB.HidHandle, ref myPtrToPreparsedData);
                    // int code = myUSB.CT_HidP_GetCaps(myPtrToPreparsedData);

                    int outputReportByteLength = 65;

                    int bytesSend = 0;
                    //if bWriteData is bigger then one report diveide into sevral reports
                    while (bytesSend < bDataToWrite.Length)
                    {

                        // Set the size of the Output report buffer.
                        // byte[] OutputReportBuffer = new byte[myUSB.myHIDP_CAPS.OutputReportByteLength - 1 + 1];
                        byte[] OutputReportBuffer = new byte[outputReportByteLength - 1 + 1];
                        // Store the report ID in the first byte of the buffer:
                        OutputReportBuffer[0] = 0;

                        // Store the report data following the report ID.
                        for (int i = 1; i < OutputReportBuffer.Length; i++)
                        {
                            if (bytesSend < bDataToWrite.Length)
                            {
                                OutputReportBuffer[i] = bDataToWrite[bytesSend];
                                bytesSend++;
                            }
                            else
                            {
                                OutputReportBuffer[i] = 0;
                            }
                        }

                        OutputReport myOutputReport = new OutputReport();
                        success = myOutputReport.Write(OutputReportBuffer, myUSB.HidHandle);
                    }
                }
                //catch (System.AccessViolationException ex)
                catch
                {
                    success = false;
                }
            }
            else
            {
                success = false;
            }
            return success;
        }
示例#25
0
        /// <summary>
        /// Sends the output of the <see cref="Audit"/> result. Currently only through emails.
        /// </summary>
        /// <param name="auditGroup">The list of <see cref="Audit"/>s that were tested.</param>
        /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
        public static bool SendResult(AuditCollection auditGroup)
        {
            var succeed = false;

            try
            {
                string htmlBody;

                switch (auditGroup.AuditResultOutputType)
                {
                case OutputType.UnitTest:
                    OutputUnitTest unitTest = new OutputUnitTest(auditGroup);
                    htmlBody = unitTest.CreateOutputBody();
                    break;

                case OutputType.Alert:
                    OutputAlert alert = new OutputAlert(auditGroup);
                    htmlBody = alert.CreateOutputBody();
                    break;

                case OutputType.Audit:
                    OutputAudit audit = new OutputAudit(auditGroup);
                    htmlBody = audit.CreateOutputBody();
                    break;

                case OutputType.Report:
                    OutputReport report = new OutputReport(auditGroup);
                    htmlBody = report.CreateOutputBody();
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }

                var mailClient = CreateMailMessage(out var message, auditGroup, htmlBody);

                mailClient.Send(message);

                succeed = true;
            }
            catch (SmtpException smtpEx)
            {
                StringBuilder sb = new StringBuilder();
                sb.AppendLine(smtpEx.Message);

                if (smtpEx.InnerException != null)
                {
                    sb.AppendLine(smtpEx.InnerException.Message);
                }

                succeed = false;

                var logger = GetFileLogger();
                logger.Error(smtpEx, sb.ToString());
            }
            catch (Exception ex)
            {
                succeed = false;

                var logger = GetFileLogger();
                logger.Error(ex, ex.Message);
            }

            return(succeed);
        }
示例#26
0
 public void WriteOutput(OutputReport report)
 {
 }
示例#27
0
 protected void CreateReport(OutputReport reportType)
 {
     Array.Clear(OutputBuffer, 0, maximalReportLength);
     OutputBuffer[0] = (byte)reportType;
 }