Esempio n. 1
0
        // TO TEST: we don't use it.
        public List <ViewSignalProperties> creatListSig(int numSig, int[] minVal, int[] maxVal, int[] resolutionSig, int[] initVal, string[] nameSig, int[] lenSig)
        {
            List <ViewSignalProperties> listSig = new List <ViewSignalProperties>();

            int startBitSig = 0;

            for (int s = 0; s < numSig; s++)
            {
                // mapping data for all command
                List <int>    rawValueList  = new List <int>();
                List <string> physValueList = new List <string>();

                //// REMOVE: data base is mapping value
                //int rawVal = minVal[s];
                //rawValueList.Add(rawVal);
                //if (minVal[s] > maxVal[s])
                //{
                //    Console.WriteLine("data is invalid!");
                //    return null;
                //}
                //while (
                //    (rawVal > minVal[s])
                //    && (rawVal <= maxVal[s])
                //    )
                //{
                //    rawValueList.Add(rawVal);
                //    rawVal = rawVal + resolutionSig[s];
                //}

                ViewSignalProperties signal = new ViewSignalProperties
                {
                    name             = nameSig[s],
                    length           = lenSig[s],
                    startBit         = startBitSig,
                    rawStep          = resolutionSig[s],
                    physStep         = resolutionSig[s],
                    rawVal           = initVal[s],
                    listRawVal       = rawValueList,
                    listPhysVal      = physValueList,
                    valSelectedIndex = -1,          // init value
                    isCreating       = true,
                    minRawVal        = minVal[s],
                    maxRawVal        = maxVal[s]
                };
                listSig.Add(signal);
                startBitSig = startBitSig + lenSig[s];
            }

            return(listSig);
        }
Esempio n. 2
0
        public ViewData[] ParsingJsonDataToView_(CommandJson_[] arrCmdJ)
        {
            ViewData[] arrview = new ViewData[] { };

            List <ViewData> listView   = new List <ViewData>();
            List <string>   listTriger = new List <string>();

            listTriger.Add("Manual");
            listTriger.Add("Preodic: __ms");
            List <string> listType = new List <string>();

            listType.Add("CAN Data");
            listType.Add("CAN FD");
            List <string> listChanel = new List <string>();

            string[] chanelArray = ConfigurationManager.AppSettings["canChanel"].Split(',');
            for (int i = 0; i < chanelArray.Length; i++)
            {
                listChanel.Add(chanelArray[i]);
            }


            for (var i = 0; i < arrCmdJ.Length; i++)
            {
                ViewData view = new ViewData
                {
                    row = i,
                    isSellectedCommand = false,      // init value
                    sendSts            = false,
                    properties         = new ViewCommandProperties
                    {
                        dlc               = arrCmdJ[i].dlc,
                        id                = arrCmdJ[i].id,
                        name              = arrCmdJ[i].name,
                        ide               = false,
                        brs               = false,
                        btr               = false,
                        trigerList        = listTriger,
                        trigerSelectedIdx = 0,
                        chanelList        = listChanel,
                        chanelSelectedIdx = 0,
                        typeList          = listType,
                        typeSelectedIdx   = 0,
                        isCycle           = false,
                        cycle             = 0,
                        sentStatus        = "SEND",
                        isCreating        = false
                    }
                };
                listView.Add(view);
            }

            arrview = listView.ToArray();

            // init binding signal
            for (var j = 0; j < arrCmdJ.Length; j++)
            {
                List <ViewSignalProperties> listSig = new List <ViewSignalProperties>();
                int cnt = arrCmdJ[j].signals.Length;
                for (int s = 0; s < cnt; s++)
                {
                    // mapping data for all command
                    List <int>    rawValueList  = new List <int>();
                    List <string> physValueList = new List <string>();
                    int           sIndex        = 0;

                    if (String.Equals("enum", arrCmdJ[j].signals[s].value_type, StringComparison.CurrentCulture))
                    {
                        for (int num = 0; num < arrCmdJ[j].signals[s].description.Length; num++)
                        {
                            rawValueList.Add(arrCmdJ[j].signals[s].description[num].value);
                            physValueList.Add(arrCmdJ[j].signals[s].description[num].name);
                        }
                    }
                    else
                    {
                        int rawVal = arrCmdJ[j].signals[s].minimum;

                        if (arrCmdJ[j].signals[s].resolution == 0)
                        {
                            Console.WriteLine("CMDID: {0} NAME: {1} SIG: {2} have resolution invalid! ", arrCmdJ[j].id, arrCmdJ[j].name, arrCmdJ[j].signals[s].name);
                            MessageBox.Show("Resolution invalid!");
                            return(null);
                        }
                        while (
                            (rawVal >= arrCmdJ[j].signals[s].minimum) &&
                            (rawVal <= arrCmdJ[j].signals[s].maximum)
                            )
                        {
                            rawValueList.Add(rawVal);
                            rawVal = rawVal + arrCmdJ[j].signals[s].resolution;
                        }
                    }

                    sIndex = rawValueList.IndexOf(arrCmdJ[j].signals[s].init_value);

                    ViewSignalProperties signal = new ViewSignalProperties
                    {
                        name             = arrCmdJ[j].signals[s].name,
                        length           = arrCmdJ[j].signals[s].length,
                        startBit         = arrCmdJ[j].signals[s].start_bit,
                        rawStep          = arrCmdJ[j].signals[s].resolution,
                        physStep         = arrCmdJ[j].signals[s].resolution,
                        rawVal           = arrCmdJ[j].signals[s].init_value,
                        listRawVal       = rawValueList,
                        listPhysVal      = physValueList,
                        valSelectedIndex = sIndex,
                        isCreating       = false,
                        minRawVal        = arrCmdJ[j].signals[s].minimum,
                        maxRawVal        = arrCmdJ[j].signals[s].maximum,
                        isSellectedSig   = false
                    };
                    listSig.Add(signal);
                }
                arrview[j].properties.sigList = listSig;
            }

            return(arrview);
        }