コード例 #1
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
        /// <summary>
        /// Easy solution to write fields to be sent back to the PLC
        /// </summary>
        /// <param name="theField">Key to be written</param>
        /// <param name="theValue">value to be used</param>
        /// <param name="dataOut">Neutrino to be worked on</param>
        private void WriteField(string theField, string theValue, ref Neutrino dataOut)
        {
            int byteCount = Encoding.GetEncoding(1252).GetByteCount(theValue);

            byte[] data = new byte[byteCount];
            Array.Copy(Encoding.GetEncoding(1252).GetBytes(theValue), data, byteCount);
            dataOut.AddField(theField, data);
        }
コード例 #2
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// Makes it easier to retrieve the most current field values
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 /// <param name="currentLocation">Extracted location from the neutriono</param>
 /// <param name="picValue">Extracted picValue from the neutriono</param>
 /// <param name="barcode">Extracted barcode from the neutriono</param>
 private void GetStandardFields(
     Neutrino dataIn,
     out string currentLocation,
     out string picValue,
     out string barcode)
 {
     byte[] vi = dataIn.GetRawField("SourceLocation");
     currentLocation = Encoding.GetEncoding(1252).GetString(vi);
     vi       = dataIn.GetRawField("PIC");
     picValue = Encoding.GetEncoding(1252).GetString(vi);
     vi       = dataIn.GetRawField("Barcode");
     barcode  = Encoding.GetEncoding(1252).GetString(vi);
 }
コード例 #3
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
        private void OnSortationReport(Neutrino dataIn)
        {
            string currentLocation, picValue, barcode;

            GetStandardFields(dataIn, out currentLocation, out picValue, out barcode);
            string requestedDestination = GetField(dataIn, "RequestedDestination");
            string actualDestination    = GetField(dataIn, "ActualDestination");
            string divertCode           = GetField(dataIn, "DivertCode");

            if (actualDestination != requestedDestination)
            {
                logger.ErrorMethod("Wrong sortation of " + barcode + " at " + currentLocation + " detected.");
            }
        }
コード例 #4
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
        private void CreateDestinationReply(
            string picValue,
            string barcode,
            string sourceLocation,
            string destinationLocation,
            out Neutrino dataOut)
        {
            dataOut = new Neutrino();

            WriteField(StandardTelegramFieldNames.TelegramId, "51", ref dataOut);
            WriteField("PIC", picValue, ref dataOut);
            WriteField("Barcode", barcode, ref dataOut);
            WriteField("SourceLocation", sourceLocation, ref dataOut);
            WriteField("DestinationLocation", destinationLocation, ref dataOut);
        }
コード例 #5
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
        /// <summary>
        /// Tote passed a scanner. PLC is waiting for destination location from MFC
        /// while tote is stopped.
        /// </summary>
        /// <param name="dataIn">data to be analysed</param>
        /// <param name="dataOut">The data to send back. If null then no data will be send back.</param>
        private void OnWaitingPointRequest(Neutrino dataIn, out Neutrino dataOut)
        {
            string currentLocation, picValue, barcode;

            dataOut = null;

            GetStandardFields(dataIn, out currentLocation, out picValue, out barcode);

            // Just an example. Please put your code here...
            if (currentLocation == "010202")
            {
                // Increment tote counter
                toteCounterWaitingPoint++;

                string destinationLocation;
                if (toteCounterWaitingPoint % 10 == 0)
                {
                    // We send every 10th tote to the premium quality check...
                    destinationLocation = "010502";
                }
                else
                {
                    if (barcode.EndsWith("1"))
                    {
                        // In case tote barcode ends by "1", we will send it to reject lane
                        destinationLocation = "010402";
                    }
                    else
                    {
                        // By default, all totes will go straight
                        destinationLocation = "010392";
                    }
                }
                CreateWaitingPointReply(picValue, barcode, currentLocation, destinationLocation, out dataOut);
            }
            // Feel free to check other locations as well...
        }
コード例 #6
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
        /// <summary>
        /// Will be called each time a telegram has arrived.
        /// </summary>
        /// <param name="theInstance">Communication Instance</param>
        /// <param name="dataIn">data to be analysed</param>
        /// <param name="dataOut">The data to send back. If null then no data will be send back.</param>
        public virtual void Process(string theInstance, Neutrino dataIn, out List <Neutrino> dataOut)
        {
            Neutrino theNeutrino = null;

            // Default: We will not send anything back...
            dataOut = null;

            // What kind of telegram came in?
            byte[] vi = dataIn.GetRawField(StandardTelegramFieldNames.TelegramId);
            logger.InfoMethod("Processing " + dataIn.TheName + ".");

            switch (Encoding.GetEncoding(1252).GetString(vi))
            {
            // Tote passed a scanner. PLC is waiting for destination location from MFC.
            case "01":
                OnDestinationRequest(dataIn, out theNeutrino);
                break;

            // Tote passed a waiting point scanner. PLC is waiting for destination location from MFC
            // while having the tote stop.
            case "02":
                OnWaitingPointRequest(dataIn, out theNeutrino);
                break;

            // Tote has passed a message point
            case "03":
                OnMessagePointRequest(dataIn);
                break;

            case "04":
                OnRequestAtToteStart(dataIn, out theNeutrino);
                break;

            // Tote has been sorted out after a destination request
            case "11":
                OnSortationReport(dataIn);
                break;

            // Tote has been sorted out after a waiting point request
            case "12":
                OnSortationReportWaitingPoint(dataIn);
                break;

            case "14":
                OnSortationReportToteStart(dataIn);
                break;

            // MFC State telegram request. MFC is requested to send it's state back to the PLC.
            case "61":
                OnMFCState(dataIn, out theNeutrino);
                break;

            case "81":
                OnPLCLoggingInfo(dataIn);
                break;

            // PLC reports it's state to the MFC.
            case "91":
                OnPLCState(dataIn, out theNeutrino);
                break;

            // Server sends back it's watchdog telegram
            case "98":
                OnWatchdogReply(dataIn, out theNeutrino);
                break;

            // Client should send it's watchdog telegram
            case "99":
                OnWatchdogRequest(dataIn, out theNeutrino);
                break;
            }
            if (theNeutrino != null)
            {
                dataOut = new List <Neutrino>();
                dataOut.Add(theNeutrino);
            }
        }
コード例 #7
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// Tote has passed a message point
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 private void OnMessagePointRequest(Neutrino dataIn)
 {
     // Put your code in here.
 }
コード例 #8
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// Incoming watchdog reply from peer detected.
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 /// <param name="dataOut">The data to send back. If null then no data will be send back.</param>
 private void OnWatchdogReply(Neutrino dataIn, out Neutrino dataOut)
 {
     dataOut = null;
 }
コード例 #9
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// Client is requested to send it's watchdog
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 /// <param name="dataOut">The data to send back. If null then no data will be send back.</param>
 private void OnWatchdogRequest(Neutrino dataIn, out Neutrino dataOut)
 {
     dataOut = null;
     WriteField(StandardTelegramFieldNames.TelegramId, "99", ref dataOut);
 }
コード例 #10
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
        /// <summary>
        /// PLC wants to log some data...
        /// </summary>
        /// <param name="dataIn">data to be analysed</param>
        private void OnPLCLoggingInfo(Neutrino dataIn)
        {
            string theLogInfo = GetField(dataIn, "LoggingData");

            logger.InfoMethod(theLogInfo);
        }
コード例 #11
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// Sortation report after a tote start reply
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 private void OnSortationReportToteStart(Neutrino dataIn)
 {
     // We just call the standard waiting point method. Feel free
     // to implement whatever you like...
     OnSortationReport(dataIn);
 }
コード例 #12
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// PLC State telegram. PLC sends it's state to the MFC.
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 /// <param name="dataOut">The data to send back. If null then no data will be send back.</param>
 private void OnPLCState(Neutrino dataIn, out Neutrino dataOut)
 {
     dataOut = null;
 }
コード例 #13
0
ファイル: PLC_1.cs プロジェクト: guoxianghan/mfc
 /// <summary>
 /// Returns the value of the specified field as a string
 /// </summary>
 /// <param name="dataIn">data to be analysed</param>
 /// <param name="field">Key name for which data should be extracted from the neutrino</param>
 /// <returns>data found for given key</returns>
 private string GetField(Neutrino dataIn, string field)
 {
     return(Encoding.GetEncoding(1252).GetString(dataIn.GetRawField(field)));
 }